From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web12.7248.1604022148146292627 for ; Thu, 29 Oct 2020 18:42:28 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=Zn0nJJ1S; spf=pass (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=0572814f16=abner.chang@hpe.com) Received: from pps.filterd (m0148663.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09U1cPjj016422 for ; Fri, 30 Oct 2020 01:42:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=xG1uC66pcyP2PV8dGtnJ1pqAQPUd+VIfqmSh3wvaqTU=; b=Zn0nJJ1S1D5GTpInlKhaFebVqacxttUD1G2tyncMSZTdpU5U7skfUg5QVxuHKma1hRSn E7TFQSWtxDA+Vt1zTwBgT8L97YTOAlskxDh4uQyQnWXH0LIlErJYFUME+xpuOCEEY5jf XPM39eT4k24fH/ud8VJns84UAqC4/G4llXcVqojCuNxmp1wyUkMyA/H8UpV5MY9QShag 5iAMM67VY+vNwwrAkqhs4E9poc2V8VVui2atr+F5jyPDnBZkHGGUm0kNnEDB9tIe34zt MovLVLA6qTPzBxQZgdpgoNhcRYrwgIF5joHx+CoN47SuSv3Kbcpq0lOKDRTQrknCg1xI VA== Received: from g2t2354.austin.hpe.com (g2t2354.austin.hpe.com [15.233.44.27]) by mx0a-002e3701.pphosted.com with ESMTP id 34ftfkqe8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 30 Oct 2020 01:42:27 +0000 Received: from G1W8106.americas.hpqcorp.net (g1w8106.austin.hp.com [16.193.72.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2354.austin.hpe.com (Postfix) with ESMTPS id 8EE85BA for ; Fri, 30 Oct 2020 01:42:26 +0000 (UTC) Received: from G9W9210.americas.hpqcorp.net (16.220.66.155) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 30 Oct 2020 01:42:21 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (15.241.52.12) by G9W9210.americas.hpqcorp.net (16.220.66.155) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Fri, 30 Oct 2020 01:42:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=awVkZuBLByFh4yAW8s7tumi8FjQDGlg0zPbPsUqyT2QS9mvW+aBA8Tr9TwWOPEmH/ItqDMhTbztCIlEYu+tKeQyfN3bvywBUc4PPoeZB3F5bSqy8SiF+m/eb872yJ9VzID8wLA64Ql8bch5ihKEf6Yw8EIOMN2Y4R8YyMuy2QwykZChlG1X82z/Pr/4jvI8M9XIXSOOYJBIFPvDXQBXdDHPQ2mzvST1OCDogBnMPqdEi4ml1RV8mKpCwifeE/jymhEt7enMV8Qi6VMadPjV79M0pCwTg9j8jc9qfIjawtUZdbIbCkJdJHeIxIzKMOr9W+hN44LAi9EevrFauBSGpuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jPVJW02d8Y3KQJk/NCbUxIRov5SFiUv9Ona1uYQzeHo=; b=I2Nyg8e/t2i60FhnL01Q0iaIZb5BvLoLpSpkZW84HQem21/65z96QckcqeiO2EOvkisxtzp3glCXtMr5HBTfOQkMJSUlOUwFG+R4sGrpB+DT57wMVE2S11fO6YplIV5vT9gHHKKh1mgdAbWcGOkCA0iwBu//AVQRjj+ivyvVR6liMMNE+RTeIF1CHKkqwoKItrv7gDC8mAm7CSpHBqGK4HigU3PWXU5+mJSehqlZQ9la4MRWAvcSJL/GnSlTku8blnFv7rNgW3olOyGsWeco9urO+DT7mxsCScuzUY6MZDW19K+bfFACU6p2iJ7b8cQxcsgSHlyLaMYaUY2Nx6qXAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7508::16) by CS1PR8401MB1237.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7514::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Fri, 30 Oct 2020 01:42:19 +0000 Received: from CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::f4a5:2722:be1c:7222]) by CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::f4a5:2722:be1c:7222%6]) with mapi id 15.20.3477.035; Fri, 30 Oct 2020 01:42:19 +0000 From: "Abner Chang" To: "devel@edk2.groups.io" , "Chang, Abner (HPS SW/FW Technologist)" , "Wang, Nickle (HPS SW)" CC: Jiaxin Wu , Siyuan Fu , Fan Wang , Jiewen Yao Subject: Re: [edk2-devel] [RestJsonStructureDxe PATCH v3 2/3] RedfishPkg/RestJsonStructureDxe: EFI REST JSON Structure Protocol Thread-Topic: [edk2-devel] [RestJsonStructureDxe PATCH v3 2/3] RedfishPkg/RestJsonStructureDxe: EFI REST JSON Structure Protocol Thread-Index: AQHWoxEFKAtTeOWcQki1RbLJfNzAx6muOspwgAE498CAAAEEgA== Date: Fri, 30 Oct 2020 01:42:19 +0000 Message-ID: References: <20201015154928.16211-1-abner.chang@hpe.com> <20201015154928.16211-3-abner.chang@hpe.com> <1642A15CB7E86403.17837@groups.io> In-Reply-To: <1642A15CB7E86403.17837@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=hpe.com; x-originating-ip: [1.34.113.40] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 0ab67b2e-4ff2-4ffb-575f-08d87c7509f6 x-ms-traffictypediagnostic: CS1PR8401MB1237: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:13; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: IXe5ni+4A9/OJoHjVligvuzhDGk36Bx1lRxOiUloyJK8zecW2pKivXe7VSy6HYDNugDGjNIxNINnrd1vScIvQoSTzpAUtl9cTFIrxspuq/70woh447ugyC9qEBoslScxObsppN0ZEofi1AThkmut026Z9FtLeUmC0rohkqXStYm2XIg36r7zsOUr8G2XT/b6zdt/ornR0f9gyr+II+jHc92KsEQCKNyEAUIbM4V1ZPNx1gbGTBdD85XdZrTLos3T/6Iq9t3TRq0y1gBFtUcevPftNkuHuG1DMtM39MVQvLU5LH0aJPZpVaQ3jjTjY3QqaRrTN0b5OqQe0vcsdM/wpm0tbhdV7ry3AfRyeeBwb/8m5zojUYmCYml7LBU2Lklzh4E9IEs0O/LQzciFjqwqbA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(396003)(39860400002)(366004)(376002)(346002)(136003)(53546011)(7696005)(6506007)(66446008)(64756008)(66556008)(71200400001)(52536014)(66476007)(83380400001)(478600001)(66946007)(76116006)(966005)(4326008)(54906003)(33656002)(110136005)(9686003)(26005)(6636002)(186003)(55016002)(8676002)(86362001)(8936002)(2906002)(19627235002)(5660300002)(316002)(30864003)(579004)(559001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: UhuR7qZ968hNFm6SzWyTVFjmZ+nYezpk4c57Gp2QiCF54iMRzSI3TzxdLHAHl5eXyUaMSY0qJM7ThsMufWXaZJt349rIAxeL1YERKfaXOu6F6GMobxkelN/IcN4aK+FUHFHSF9QJXcZf8CXXDr7t2y1HRMFikOcPzDZMIUux/cKqRXai9jQCbAXEoKkOhI0mvmn/QZQaaupNmb8B6nHbcKNCWj5soxY9fwn9RgRyk/Q6ViFD7q+F0JAkpCX6WPh1oq7wYZL40/V28PPF+d9+09t8nBRlfGaMjTOF9QoXY25olStFjKpzSXCptzUExVmqnquS0gorLd5sDT2QravxWfxrcWnDSeNsJig0OzBG/gTmAeDjpZQ3p4r/0PmM7/SSV+Xkv3Jl/BEI0OMzFekUwsozmCVrUFRYAliPR6tDyzamLdYesWjABYzTPQr5jenVElHAlq8mJIe+6FZ0lik5S/FLsKzXXH9fy5iLWINJGLV3+DlkOmMY1KRsXEHBC0t+r3XPlh+7UtoaRHqRZyLiuB16z44kMRLDe8wPKz7sNNBGNTTWsSeMcV9S2WGRPW5hbJLV1GOvZ3zSjmOshny3f4Ci7Jb3grCnMRiFUfWfg5qkstJzsgToRH3CMzMPKeAM9BZizeyMKOvpotnBahM8Xg== X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 0ab67b2e-4ff2-4ffb-575f-08d87c7509f6 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2020 01:42:19.2152 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 3hLavB/9W/rDGtZyIFubqSCR0KxjHFhFPz71JIbqOFG93367Le6HGCc+esQW8ySY5B5dOehrpe4uL6ntELk6Ug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR8401MB1237 X-OriginatorOrg: hpe.com X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-10-29_12:2020-10-29,2020-10-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 adultscore=0 suspectscore=1 clxscore=1015 impostorscore=0 spamscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010300009 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable It's weird that I didn't send any patch of v3, please ignore this one. Thanks > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > Abner Chang > Sent: Friday, October 30, 2020 9:37 AM > To: Wang, Nickle (HPS SW) ; devel@edk2.groups.io > Cc: Jiaxin Wu ; Siyuan Fu ; Fa= n > Wang ; Jiewen Yao > Subject: Re: [edk2-devel] [RestJsonStructureDxe PATCH v3 2/3] > RedfishPkg/RestJsonStructureDxe: EFI REST JSON Structure Protocol >=20 > > -----Original Message----- > > From: Wang, Nickle (HPS SW) > > Sent: Thursday, October 29, 2020 2:58 PM > > To: Chang, Abner (HPS SW/FW Technologist) ; > > devel@edk2.groups.io > > Cc: Jiaxin Wu ; Siyuan Fu ; > > Fan Wang ; Jiewen Yao > > Subject: RE: [RestJsonStructureDxe PATCH v3 2/3] > > RedfishPkg/RestJsonStructureDxe: EFI REST JSON Structure Protocol > > > > Hi Abner, > > > > I have comment for function RestJsonStructureUnload(). Please check my > > inline comment below. > > > > Thanks, > > Nickle > > > > > -----Original Message----- > > > From: Chang, Abner (HPS SW/FW Technologist) > > > > Sent: Thursday, October 15, 2020 11:49 PM > > > To: devel@edk2.groups.io > > > Cc: Jiaxin Wu ; Siyuan Fu > > > ; Fan Wang ; Jiewen Yao > > > ; Wang, Nickle (HPS SW) > > > > Subject: [RestJsonStructureDxe PATCH v3 2/3] > > > RedfishPkg/RestJsonStructureDxe: EFI REST JSON Structure Protocol > > > > > > Implementation of EFI_REST_JSON_STRUCTURE_PROTOCOL, refer to > UEFI > > spec > > > 2.8 Section 29.7.3 EFI REST JSON Resource to C Structure Converter. > > > > > > Signed-off-by: Abner Chang > > > > > > Cc: Jiaxin Wu > > > Cc: Siyuan Fu > > > Cc: Fan Wang > > > Cc: Jiewen Yao > > > Cc: Nickle Wang > > > --- > > > RedfishPkg/RedfishPkg.dsc | 11 + > > > .../RestJsonStructureDxe.c | 585 +++++++++++++++= +++ > > > .../RestJsonStructureDxe.inf | 40 ++ > > > .../RestJsonStructureInternal.h | 33 + > > > 4 files changed, 669 insertions(+) > > > create mode 100644 > > > RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.c > > > create mode 100644 > > > RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.inf > > > create mode 100644 > > > RedfishPkg/RestJsonStructureDxe/RestJsonStructureInternal.h > > > > > > diff --git a/RedfishPkg/RedfishPkg.dsc b/RedfishPkg/RedfishPkg.dsc > > > index 8acadddefc..f0c6740fac 100644 > > > --- a/RedfishPkg/RedfishPkg.dsc > > > +++ b/RedfishPkg/RedfishPkg.dsc > > > @@ -38,3 +38,14 @@ > > > > > > > > > DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTabl > > > eLib.inf > > > DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf > > > > > > > > > ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/Dx > > > eReportStatusCodeLib.inf > > > + > > > +[LibraryClasses.ARM, LibraryClasses.AARCH64] > > > + # > > > + # This library provides the instrinsic functions generated by a > > > +given > > > compiler. > > > + # > > > + > > > + NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.in > > > + f NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf > > > + > > > + ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf > > > + > > > +[Components] > > > + RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.inf > > > diff --git a/RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.c > > > b/RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.c > > > new file mode 100644 > > > index 0000000000..03fbecf993 > > > --- /dev/null > > > +++ b/RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.c > > > @@ -0,0 +1,585 @@ > > > +/** @file > > > + > > > + The implementation of EFI REST Resource JSON to C structure > > > + convertor Protocol. > > > + > > > + (C) Copyright 2020 Hewlett Packard Enterprise Development LP
> > > + > > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > > + > > > +**/ > > > + > > > +#include > > > +#include #include > > > +"RestJsonStructureInternal.h" > > > + > > > +LIST_ENTRY mRestJsonStructureList; > > > +EFI_HANDLE mProtocolHandle; > > > + > > > +/** > > > + This function registers Restful resource interpreter for the > > > + specific schema. > > > + > > > + @param[in] This This is the > > > EFI_REST_JSON_STRUCTURE_PROTOCOL instance. > > > + @param[in] JsonStructureSupported The type and version of RE= ST > > JSON > > > resource which this converter > > > + supports. > > > + @param[in] ToStructure The function to convert RE= ST JSON > > > resource to structure. > > > + @param[in] ToJson The function to convert RE= ST JSON > > structure > > > to JSON in text format. > > > + @param[in] DestroyStructure Destroy REST JSON structur= e > > returned > > > in ToStructure() function. > > > + > > > + @retval EFI_SUCCESS Register successfully. > > > + @retval Others Fail to register. > > > + > > > +**/ > > > +EFI_STATUS > > > +EFIAPI > > > +RestJsonStructureRegister ( > > > + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, > > > + IN EFI_REST_JSON_STRUCTURE_SUPPORTED > > *JsonStructureSupported, > > > + IN EFI_REST_JSON_STRUCTURE_TO_STRUCTURE ToStructure, > > > + IN EFI_REST_JSON_STRUCTURE_TO_JSON ToJson, > > > + IN EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE > DestroyStructure > > > +) > > > +{ > > > + UINTN NumberOfNS; > > > + UINTN Index; > > > + LIST_ENTRY *ThisList; > > > + REST_JSON_STRUCTURE_INSTANCE *Instance; > > > + EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER > *CloneSupportedInterpId; > > > + EFI_REST_JSON_STRUCTURE_SUPPORTED *ThisSupportedInterp; > > > + > > > + if (This =3D=3D NULL || > > > + ToStructure =3D=3D NULL || > > > + ToJson =3D=3D NULL || > > > + DestroyStructure =3D=3D NULL || > > > + JsonStructureSupported =3D=3D NULL > > > + ) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > + // > > > + // Check how many name space interpreter can interpret. > > > + // > > > + ThisList =3D &JsonStructureSupported->NextSupportedRsrcInterp; > > > + NumberOfNS =3D 1; > > > + while (TRUE) { > > > + if (ThisList->ForwardLink =3D=3D &JsonStructureSupported- > > > >NextSupportedRsrcInterp) { > > > + break; > > > + } else { > > > + ThisList =3D ThisList->ForwardLink; > > > + NumberOfNS ++; > > > + } > > > + }; > > > + > > > + Instance =3D > > > + (REST_JSON_STRUCTURE_INSTANCE *)AllocateZeroPool (sizeof > > > (REST_JSON_STRUCTURE_INSTANCE) + NumberOfNS * sizeof > > > (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER)); > > > + if (Instance =3D=3D NULL) { > > > + return EFI_OUT_OF_RESOURCES; > > > + } > > > + InitializeListHead (&Instance->NextRestJsonStructureInstance); > > > + Instance->NumberOfNameSpaceToConvert =3D NumberOfNS; > > > + Instance->SupportedRsrcIndentifier =3D > > > (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER > > > *)((REST_JSON_STRUCTURE_INSTANCE *)Instance + 1); > > > + // > > > + // Copy supported resource identifer interpreter. > > > + // > > > + CloneSupportedInterpId =3D Instance->SupportedRsrcIndentifier; > > > + ThisSupportedInterp =3D JsonStructureSupported; for (Index =3D 0= ; > > > + Index < NumberOfNS; Index ++) { > > > + CopyMem ((VOID *)CloneSupportedInterpId, (VOID > > > *)&ThisSupportedInterp->RestResourceInterp, sizeof > > > (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER)); > > > + ThisSupportedInterp =3D (EFI_REST_JSON_STRUCTURE_SUPPORTED > > > *)ThisSupportedInterp->NextSupportedRsrcInterp.ForwardLink; > > > + CloneSupportedInterpId ++; > > > + } > > > + Instance->JsonToStructure =3D ToStructure; > > > + Instance->StructureToJson =3D ToJson; Instance->DestroyStructure = = =3D > > > + DestroyStructure; InsertTailList (&mRestJsonStructureList, > > > + &Instance- > > > >NextRestJsonStructureInstance); > > > + return EFI_SUCCESS; > > > +} > > > + > > > +/** > > > + This function check if this interpreter instance support the > > > +given > > > namesapce. > > > + > > > + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCO= L > > > instance. > > > + @param[in] InterpreterInstance REST_JSON_STRUCTURE_INSTANCE > > > + @param[in] RsrcTypeIdentifier Resource type identifier. > > > + @param[in] ResourceRaw Given Restful resource. > > > + @param[out] RestJSonHeader Property interpreted from given > > > ResourceRaw. > > > + > > > + @retval EFI_SUCCESS > > > + @retval Others. > > > + > > > +**/ > > > +EFI_STATUS > > > +InterpreterInstanceToStruct ( > > > + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, > > > + IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance, > > > + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier > > > OPTIONAL, > > > + IN CHAR8 *ResourceRaw, > > > + OUT EFI_REST_JSON_STRUCTURE_HEADER **RestJSonHeader > > > + ) > > > +{ > > > + UINTN Index; > > > + EFI_STATUS Status; > > > + EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER > > *ThisSupportedRsrcTypeId; > > > + > > > + if (This =3D=3D NULL || > > > + InterpreterInstance =3D=3D NULL || > > > + ResourceRaw =3D=3D NULL || > > > + RestJSonHeader =3D=3D NULL > > > + ) { > > > + return EFI_INVALID_PARAMETER; } > > > + > > > + Status =3D EFI_UNSUPPORTED; > > > + if (RsrcTypeIdentifier =3D=3D NULL) { > > > + // > > > + // No resource type identifier, send to intepreter anyway. > > > + // Interpreter may recognize this resource. > > > + // > > > + Status =3D InterpreterInstance->JsonToStructure ( > > > + This, > > > + NULL, > > > + ResourceRaw, > > > + RestJSonHeader > > > + ); > > > + } else { > > > + // > > > + // Check if the namesapce and version is supported by this inte= rpreter. > > > + // > > > + ThisSupportedRsrcTypeId =3D InterpreterInstance- > > > >SupportedRsrcIndentifier; > > > + for (Index =3D 0; Index < InterpreterInstance- > > > >NumberOfNameSpaceToConvert; Index ++){ > > > + if (AsciiStrCmp ( > > > + RsrcTypeIdentifier->NameSpace.ResourceTypeName, > > > + ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) = =3D=3D > 0){ > > > + if ((RsrcTypeIdentifier->NameSpace.MajorVersion =3D=3D NULL= ) && > > > + (RsrcTypeIdentifier->NameSpace.MinorVersion =3D=3D NULL= ) && > > > + (RsrcTypeIdentifier->NameSpace.ErrataVersion =3D=3D NUL= L) > > > + ) { > > > + // > > > + // Don't check version of this resource type identifier. > > > + // > > > + Status =3D InterpreterInstance->JsonToStructure ( > > > + This, > > > + RsrcTypeIdentifier, > > > + ResourceRaw, > > > + RestJSonHeader > > > + ); > > > + break; > > > + } else { > > > + // > > > + // Check version. > > > + // > > > + if ((AsciiStrCmp ( > > > + RsrcTypeIdentifier->NameSpace.MajorVersion, > > > + ThisSupportedRsrcTypeId->NameSpace.MajorVersion) = =3D=3D 0) && > > > + (AsciiStrCmp ( > > > + RsrcTypeIdentifier->NameSpace.MinorVersion, > > > + ThisSupportedRsrcTypeId->NameSpace.MinorVersion) = =3D=3D 0) && > > > + (AsciiStrCmp ( > > > + RsrcTypeIdentifier->NameSpace.ErrataVersion, > > > + ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) = =3D=3D 0)) { > > > + Status =3D InterpreterInstance->JsonToStructure ( > > > + This, > > > + RsrcTypeIdentifier, > > > + ResourceRaw, > > > + RestJSonHeader > > > + ); > > > + break; > > > + } > > > + } > > > + } > > > + ThisSupportedRsrcTypeId ++; > > > + } > > > + } > > > + return Status; > > > +} > > > +/** > > > + This function converts JSON C structure to JSON property. > > > + > > > + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOC= OL > > > instance. > > > + @param[in] InterpreterInstance REST_JSON_STRUCTURE_INSTANCE > > > + @param[in] RestJSonHeader Resource type identifier. > > > + @param[out] ResourceRaw Output in JSON text format. > > > + > > > + @retval EFI_SUCCESS > > > + @retval Others. > > > + > > > +**/ > > > +EFI_STATUS > > > +InterpreterEfiStructToInstance ( > > > + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, > > > + IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance, > > > + IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader, > > > + OUT CHAR8 **ResourceRaw > > > +) > > > +{ > > > + UINTN Index; > > > + EFI_STATUS Status; > > > + EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER > > *ThisSupportedRsrcTypeId; > > > + EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier; > > > + > > > + if (This =3D=3D NULL || > > > + InterpreterInstance =3D=3D NULL || > > > + RestJSonHeader =3D=3D NULL || > > > + ResourceRaw =3D=3D NULL > > > + ) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + RsrcTypeIdentifier =3D &RestJSonHeader->JsonRsrcIdentifier; > > > + if (RsrcTypeIdentifier =3D=3D NULL || > > > + RsrcTypeIdentifier->NameSpace.ResourceTypeName =3D=3D NULL || > > > + RsrcTypeIdentifier->NameSpace.MajorVersion =3D=3D NULL || > > > + RsrcTypeIdentifier->NameSpace.MinorVersion =3D=3D NULL || > > > + RsrcTypeIdentifier->NameSpace.ErrataVersion =3D=3D NULL > > > + ) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > + // > > > + // Check if the namesapce and version is supported by this interp= reter. > > > + // > > > + Status =3D EFI_UNSUPPORTED; > > > + ThisSupportedRsrcTypeId =3D InterpreterInstance- > > > >SupportedRsrcIndentifier; > > > + for (Index =3D 0; Index < InterpreterInstance- > > > >NumberOfNameSpaceToConvert; Index ++){ > > > + if (AsciiStrCmp ( > > > + RsrcTypeIdentifier->NameSpace.ResourceTypeName, > > > + ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) =3D= =3D > 0){ > > > + // > > > + // Check version. > > > + // > > > + if ((AsciiStrCmp ( > > > + RsrcTypeIdentifier->NameSpace.MajorVersion, > > > + ThisSupportedRsrcTypeId->NameSpace.MajorVersion) =3D=3D= 0) && > > > + (AsciiStrCmp ( > > > + RsrcTypeIdentifier->NameSpace.MinorVersion, > > > + ThisSupportedRsrcTypeId->NameSpace.MinorVersion) =3D=3D= 0) && > > > + (AsciiStrCmp ( > > > + RsrcTypeIdentifier->NameSpace.ErrataVersion, > > > + ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) =3D= =3D 0)) { > > > + Status =3D InterpreterInstance->StructureToJson ( > > > + This, > > > + RestJSonHeader, > > > + ResourceRaw > > > + ); > > > + break; > > > + } > > > + } > > > + ThisSupportedRsrcTypeId ++; > > > + } > > > + return Status; > > > +} > > > + > > > +/** > > > + This function destory REST property structure. > > > + > > > + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOC= OL > > > instance. > > > + @param[in] InterpreterInstance REST_JSON_STRUCTURE_INSTANCE > > > + @param[in] RestJSonHeader Property interpreted from give= n > > > ResourceRaw. > > > + > > > + @retval EFI_SUCCESS > > > + @retval Others. > > > + > > > +**/ > > > +EFI_STATUS > > > +InterpreterInstanceDestoryJsonStruct ( > > > + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, > > > + IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance, > > > + IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader > > > + ) > > > +{ > > > + UINTN Index; > > > + EFI_STATUS Status; > > > + EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER > > *ThisSupportedRsrcTypeId; > > > + > > > + if (This =3D=3D NULL || > > > + InterpreterInstance =3D=3D NULL || > > > + RestJSonHeader =3D=3D NULL > > > + ) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > + Status =3D EFI_UNSUPPORTED; > > > + // > > > + // Check if the namesapce and version is supported by this interp= reter. > > > + // > > > + ThisSupportedRsrcTypeId =3D InterpreterInstance- > > > >SupportedRsrcIndentifier; > > > + for (Index =3D 0; Index < InterpreterInstance- > > > >NumberOfNameSpaceToConvert; Index ++){ > > > + if (AsciiStrCmp ( > > > + RestJSonHeader- > > >JsonRsrcIdentifier.NameSpace.ResourceTypeName, > > > + ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) =3D= =3D 0) > { > > > + if > > > + ((RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion > > > + =3D=3D > > > NULL) && > > > + > > > + (RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion > > > + =3D=3D > > > NULL) && > > > + > > > + (RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion > > > + =3D=3D > > > NULL) > > > + ) { > > > + // > > > + // Don't check version of this resource type identifier. > > > + // > > > + Status =3D InterpreterInstance->DestroyStructure ( > > > + This, > > > + RestJSonHeader > > > + ); > > > + break; > > > + } else { > > > + // > > > + // Check version. > > > + // > > > + if ((AsciiStrCmp ( > > > + RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVer= sion, > > > + ThisSupportedRsrcTypeId->NameSpace.MajorVersion) =3D= =3D 0) && > > > + (AsciiStrCmp ( > > > + RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVer= sion, > > > + ThisSupportedRsrcTypeId->NameSpace.MinorVersion) =3D= =3D 0) && > > > + (AsciiStrCmp ( > > > + RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVe= rsion, > > > + ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) =3D= = =3D 0)) { > > > + Status =3D InterpreterInstance->DestroyStructure ( > > > + This, > > > + RestJSonHeader > > > + ); > > > + break; > > > + } > > > + } > > > + } > > > + ThisSupportedRsrcTypeId ++; > > > + } > > > + return Status; > > > +} > > > + > > > +/** > > > + This function translates the given JSON text to JSON C Structure. > > > + > > > + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCO= L > > > instance. > > > + @param[in] RsrcTypeIdentifier Resource type identifier. > > > + @param[in] ResourceJsonText Given Restful resource. > > > + @param[out] JsonStructure Property interpreted from given > > > ResourceRaw. > > > + > > > + @retval EFI_SUCCESS > > > + @retval Others. > > > + > > > +**/ > > > +EFI_STATUS > > > +EFIAPI > > > +RestJsonStructureToStruct ( > > > + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, > > > + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier > > > OPTIONAL, > > > + IN CHAR8 *ResourceJsonText, > > > + OUT EFI_REST_JSON_STRUCTURE_HEADER **JsonStructure > > > +) > > > +{ > > > + EFI_STATUS Status; > > > + REST_JSON_STRUCTURE_INSTANCE *Instance; > > > + > > > + if (This =3D=3D NULL || > > > + ResourceJsonText =3D=3D NULL || > > > + JsonStructure =3D=3D NULL > > > + ) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > + if (IsListEmpty (&mRestJsonStructureList)) { > > > + return EFI_UNSUPPORTED; > > > + } > > > + Status =3D EFI_SUCCESS; > > > + Instance =3D (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode > > > (&mRestJsonStructureList); > > > + while (TRUE) { > > > + Status =3D InterpreterInstanceToStruct ( > > > + This, > > > + Instance, > > > + RsrcTypeIdentifier, > > > + ResourceJsonText, > > > + JsonStructure > > > + ); > > > + if (!EFI_ERROR (Status)) { > > > + break; > > > + } > > > + if (IsNodeAtEnd(&mRestJsonStructureList, &Instance- > > > >NextRestJsonStructureInstance)) { > > > + Status =3D EFI_UNSUPPORTED; > > > + break; > > > + } > > > + Instance =3D (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode > > > (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); > > > + }; > > > + return Status; > > > +} > > > + > > > +/** > > > + This function destory REST property EFI structure which returned > > > +in > > > + JsonToStructure(). > > > + > > > + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL > > instance. > > > + @param[in] RestJSonHeader Property to destory. > > > + > > > + @retval EFI_SUCCESS > > > + @retval Others > > > + > > > +**/ > > > +EFI_STATUS > > > +EFIAPI > > > +RestJsonStructureDestroyStruct ( > > > + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, > > > + IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader > > > +) > > > +{ > > > + EFI_STATUS Status; > > > + REST_JSON_STRUCTURE_INSTANCE *Instance; > > > + > > > + if (This =3D=3D NULL || RestJSonHeader =3D=3D NULL) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > + if (IsListEmpty (&mRestJsonStructureList)) { > > > + return EFI_UNSUPPORTED; > > > + } > > > + Status =3D EFI_SUCCESS; > > > + Instance =3D (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode > > > (&mRestJsonStructureList); > > > + while (TRUE) { > > > + Status =3D InterpreterInstanceDestoryJsonStruct ( > > > + This, > > > + Instance, > > > + RestJSonHeader > > > + ); > > > + if (!EFI_ERROR (Status)) { > > > + break; > > > + } > > > + if (IsNodeAtEnd(&mRestJsonStructureList, &Instance- > > > >NextRestJsonStructureInstance)) { > > > + Status =3D EFI_UNSUPPORTED; > > > + break; > > > + } > > > + Instance =3D (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode > > > (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); > > > + }; > > > + return Status; > > > +} > > > + > > > +/** > > > + This function translates the given JSON C Structure to JSON text. > > > + > > > + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL > > instance. > > > + @param[in] RestJSonHeader Given Restful resource. > > > + @param[out] ResourceRaw Resource in RESTfuls service orient= ed. > > > + > > > + @retval EFI_SUCCESS > > > + @retval Others Fail to remove the entry > > > + > > > +**/ > > > +EFI_STATUS > > > +EFIAPI > > > +RestJsonStructureToJson ( > > > + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, > > > + IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader, > > > + OUT CHAR8 **ResourceRaw > > > +) > > > +{ > > > + EFI_STATUS Status; > > > + REST_JSON_STRUCTURE_INSTANCE *Instance; > > > + > > > + if (This =3D=3D NULL || RestJSonHeader =3D=3D NULL || ResourceRaw= =3D=3D NULL) > { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > + if (IsListEmpty (&mRestJsonStructureList)) { > > > + return EFI_UNSUPPORTED; > > > + } > > > + Status =3D EFI_SUCCESS; > > > + Instance =3D (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode > > > (&mRestJsonStructureList); > > > + while (TRUE) { > > > + Status =3D InterpreterEfiStructToInstance ( > > > + This, > > > + Instance, > > > + RestJSonHeader, > > > + ResourceRaw > > > + ); > > > + if (!EFI_ERROR (Status)) { > > > + break; > > > + } > > > + if (IsNodeAtEnd(&mRestJsonStructureList, &Instance- > > > >NextRestJsonStructureInstance)) { > > > + Status =3D EFI_UNSUPPORTED; > > > + break; > > > + } > > > + Instance =3D (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode > > > (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); > > > + }; > > > + return Status; > > > +} > > > + > > > +EFI_REST_JSON_STRUCTURE_PROTOCOL mRestJsonStructureProtocol =3D > { > > > + RestJsonStructureRegister, > > > + RestJsonStructureToStruct, > > > + RestJsonStructureToJson, > > > + RestJsonStructureDestroyStruct > > > +}; > > > + > > > +/** > > > + This is the declaration of an EFI image entry point. > > > + > > > + @param ImageHandle The firmware allocated handle for t= he UEFI > > > image. > > > + @param SystemTable A pointer to the EFI System Table. > > > + > > > + @retval EFI_SUCCESS The operation completed successfull= y. > > > + @retval Others An unexpected error occurred. > > > +**/ > > > +EFI_STATUS > > > +EFIAPI > > > +RestJsonStructureEntryPoint ( > > > + IN EFI_HANDLE ImageHandle, > > > + IN EFI_SYSTEM_TABLE *SystemTable > > > + ) > > > +{ > > > + EFI_STATUS Status; > > > + > > > + InitializeListHead (&mRestJsonStructureList); > > > + // > > > + // Install the Restful Resource Interpreter Protocol. > > > + // > > > + mProtocolHandle =3D NULL; > > > + Status =3D gBS->InstallProtocolInterface ( > > > + &mProtocolHandle, > > > + &gEfiRestJsonStructureProtocolGuid, > > > + EFI_NATIVE_INTERFACE, > > > + (VOID *)&mRestJsonStructureProtocol > > > + ); > > > + return Status; > > > +} > > > + > > > +/** > > > + This is the unload handle for Redfish discover module. > > > + > > > + Disconnect the driver specified by ImageHandle from all the > > > + devices in the > > > handle database. > > > + Uninstall all the protocols installed in the driver entry point. > > > + > > > + @param[in] ImageHandle The drivers' driver image. > > > + > > > + @retval EFI_SUCCESS The image is unloaded. > > > + @retval Others Failed to unload the image. > > > + > > > +**/ > > > +EFI_STATUS > > > +EFIAPI > > > +RestJsonStructureUnload ( > > > + IN EFI_HANDLE ImageHandle > > > + ) > > > +{ > > > + EFI_STATUS Status; > > > + REST_JSON_STRUCTURE_INSTANCE *Instance; > > > + REST_JSON_STRUCTURE_INSTANCE *NextInstance; > > > + > > > + if (IsListEmpty (&mRestJsonStructureList)) { > > > + return EFI_SUCCESS; > > > + } > > We still need to uninstall REST Json Structure Protocol when list is > > empty, right? The protocol is installed on driver entry when list is e= mpty. > [Chang, Abner] > Thanks for catching this. That issue is fixed in V4 (just sent) of patch= es set. >=20 > Abner >=20 > > > > > + // > > > + // Free memory of REST_JSON_STRUCTURE_INSTANCE instance. > > > + // > > > + Instance =3D (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode > > > (&mRestJsonStructureList); > > > + do { > > > + NextInstance =3D NULL; > > > + if (!IsNodeAtEnd(&mRestJsonStructureList, &Instance- > > > >NextRestJsonStructureInstance)) { > > > + NextInstance =3D (REST_JSON_STRUCTURE_INSTANCE > *)GetNextNode > > > (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); > > > + } > > > + FreePool ((VOID *)Instance); > > > + Instance =3D NextInstance; > > > + } while (Instance !=3D NULL); > > > + > > > + Status =3D gBS->UninstallProtocolInterface ( > > > + mProtocolHandle, > > > + &gEfiRestJsonStructureProtocolGuid, > > > + (VOID *)&mRestJsonStructureProtocol > > > + ); > > > + return Status; > > > +} > > > diff --git > > > a/RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.inf > > > b/RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.inf > > > new file mode 100644 > > > index 0000000000..2ab1e3bc45 > > > --- /dev/null > > > +++ b/RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.inf > > > @@ -0,0 +1,40 @@ > > > +## @file > > > +# Implementation of EFI REST JSON Structure Protocol. > > > +# > > > +# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
> > > +# > > > +SPDX-License-Identifier: BSD-2-Clause-Patent # ## > > > + > > > +[Defines] > > > + INF_VERSION =3D 0x00010005 > > > + BASE_NAME =3D RestJsonStructureDxe > > > + FILE_GUID =3D 83FAAFBF-FC4B-469F-892A-798E66A6F50= A > > > + MODULE_TYPE =3D DXE_DRIVER > > > + VERSION_STRING =3D 1.0 > > > + ENTRY_POINT =3D RestJsonStructureEntryPoint > > > + UNLOAD_IMAGE =3D RestJsonStructureUnload > > > + > > > +[Packages] > > > + MdePkg/MdePkg.dec > > > + MdeModulePkg/MdeModulePkg.dec > > > + RedfishPkg/RedfishPkg.dec > > > + > > > +[Sources] > > > + RestJsonStructureDxe.c > > > + RestJsonStructureInternal.h > > > + > > > +[LibraryClasses] > > > + BaseLib > > > + BaseMemoryLib > > > + MemoryAllocationLib > > > + UefiBootServicesTableLib > > > + UefiDriverEntryPoint > > > + UefiLib > > > + > > > +[Protocols] > > > + gEfiRestJsonStructureProtocolGuid ## Producing > > > + > > > +[Depex] > > > + TRUE > > > + > > > diff --git > > > a/RedfishPkg/RestJsonStructureDxe/RestJsonStructureInternal.h > > > b/RedfishPkg/RestJsonStructureDxe/RestJsonStructureInternal.h > > > new file mode 100644 > > > index 0000000000..e8a3408404 > > > --- /dev/null > > > +++ b/RedfishPkg/RestJsonStructureDxe/RestJsonStructureInternal.h > > > @@ -0,0 +1,33 @@ > > > +/** @file > > > + The internal definitions of EFI REST Resource JSON to C structure > > > +convertor > > > + Protocol. > > > + > > > + (C) Copyright 2020 Hewlett Packard Enterprise Development LP
> > > + > > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > > + > > > +**/ > > > + > > > +#ifndef EFI_REST_JSON_STRUCTURE_INTERNAL_H_ > > > +#define EFI_REST_JSON_STRUCTURE_INTERNAL_H_ > > > + > > > +#include > > > +#include > > > +#include > > > +#include #include > > > + #include > > > + > > > +/// > > > +/// Internal structure to maintain the information of JSON to /// C > > > +structure convertor. > > > +/// > > > +typedef struct _REST_JSON_STRUCTURE_INSTANCE { > > > + LIST_ENTRY NextRestJsonStructureInstance; ///< Next convertor > > instance > > > + UINTN NumberOfNameSpaceToConvert; ///< Number of resourc= e > > > type this convertor supports. > > > + EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER > > > *SupportedRsrcIndentifier; ///< The resource type linklist > > > + EFI_REST_JSON_STRUCTURE_TO_STRUCTURE JsonToStructure; > > > ///< JSON to C structure function > > > + EFI_REST_JSON_STRUCTURE_TO_JSON StructureToJson; > ///< > > C > > > structure to JSON function > > > + EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE DestroyStructure; > > > ///< Destory C struture function. > > > +} REST_JSON_STRUCTURE_INSTANCE; > > > +#endif > > > -- > > > 2.17.1 >=20 >=20 >=20 >=20 >=20