From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.678.1631145080893486041 for ; Wed, 08 Sep 2021 16:51:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=c6FmjztC; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: isaac.w.oram@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10101"; a="281646028" X-IronPort-AV: E=Sophos;i="5.85,279,1624345200"; d="scan'208,217";a="281646028" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2021 16:51:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,279,1624345200"; d="scan'208,217";a="525075260" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga004.fm.intel.com with ESMTP; 08 Sep 2021 16:51:18 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Wed, 8 Sep 2021 16:51:18 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Wed, 8 Sep 2021 16:51:18 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.171) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Wed, 8 Sep 2021 16:51:17 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jn+oX9Jtir8wYvIVFLMNSYziSmsEwu7mcKMqgi8ogCxIQKZt2M3/qjBDEUuwJQ5AXPffFTzfMXYwgGsP2ywwElBR2JjA8A22gGtrQwAWwdirB1ME5VvluZypSrJpO0a4/fUvUh1G5YHJmpIHfK2RX9erVTyCUvnSuxHDo07ein3u00a8pbQVMtGDTek8Ndk4L7EgqHPIsveJJyQNpFWLXrfJdOKT2kt+B87BVGx7oQ27fsDUGHu0Ay8AO89ZYDnX/oCT/kUP01rWhwc4HvtO8fuZZdQvLhJZNhfnahCro3OqlAj5LnsAvumZG/uduGLnoSji9o1izup41hcmmWubTA== 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=3jNACnX9/SzCkqwEHd/GmYzNBZL20p4OZ5mIDVdTaAI=; b=JL1YY3Dp8909q1zqh952lZkjnRa3Qcvn+nQ1+0F2mci1JWEMNR9TY1O0YhD7Qs/pAKiFEsR2maQxOiI8BL4wkvVbpfoBtGt1GN5v1xJqrrRezG57UdsbVOKE8VmollH4etIq4Qcwsn7GGSlqrw/gfCAamRNlMKh2JS7J8GaLGzRedS3XT5z9/t7yifF9y+VpEJcRAJkT+1LoUShdLAlGKRXuiFPHp2vUvuHCFP7SeVlVJYMB3B4KZNuzIaLamrhdJI37pd7AQWp+L5XPw0avInNcIR3SnBeQ1LF4qMiLbbgzGs5TSVPOg7/+4x4QlBbAwmghp6L6IImQHpq9lcizcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3jNACnX9/SzCkqwEHd/GmYzNBZL20p4OZ5mIDVdTaAI=; b=c6FmjztCSZ6YP5lUIseWeVp445XJ4OaxQJDuzqWJOBpOnRjB2UnaW46WjOD18BFX6tITwXC3KA/ZJCIeNtdQ1w+VNhls8OyuMJ9ALfbsRpNPFsecQGotmVgqkBcH0n/BJKPkTg8PNXLZxNnj67SUc0RnHlh6GTN8ZsRJY57KG2Q= Received: from MW3PR11MB4747.namprd11.prod.outlook.com (2603:10b6:303:2f::11) by MWHPR11MB0029.namprd11.prod.outlook.com (2603:10b6:301:67::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.20; Wed, 8 Sep 2021 23:51:16 +0000 Received: from MW3PR11MB4747.namprd11.prod.outlook.com ([fe80::6d8b:efd8:62d1:8743]) by MW3PR11MB4747.namprd11.prod.outlook.com ([fe80::6d8b:efd8:62d1:8743%9]) with mapi id 15.20.4478.025; Wed, 8 Sep 2021 23:51:16 +0000 From: "Oram, Isaac W" To: "devel@edk2.groups.io" , "bret.barkelew@microsoft.com" CC: "Chiu, Chasel" , "Desimone, Nathaniel L" , Liming Gao , "Dong, Eric" Subject: Re: [EXTERNAL] [edk2-devel][edk2-platforms][PATCH V1 1/1] MinPlatformPkg/Variable*Lib: Build VariableRead and VariableWrite libs Thread-Topic: [EXTERNAL] [edk2-devel][edk2-platforms][PATCH V1 1/1] MinPlatformPkg/Variable*Lib: Build VariableRead and VariableWrite libs Thread-Index: AQHXpQEI5x+dFsJNbESvD0/tzz75h6uauEvkgAAKHBA= Date: Wed, 8 Sep 2021 23:51:16 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2021-09-08T22:30:39.5564074Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard dlp-product: dlpe-windows dlp-version: 11.5.1.3 dlp-reaction: no-action authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3dd7a864-4342-41db-d4c6-08d973238c22 x-ms-traffictypediagnostic: MWHPR11MB0029: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xifQ0csL3GSIRWcXiMlH3akb5FijYk6pbj+3c2d35yjmn48XgxBmqn6bqWobO6iqDsq/JzJbLMgD8yD1CBNtOPFdOQ1Fm8UknXuJUvvyxjPQyW8VBPgyeAZc7e3TAfW6Cezpr1sGs63jKNxBHzqUpvAccy3fuSbeGm5IbxnbOX0EFilc6ODhdo9GB35Akeky1NK71BqaH4DWze7nPR9ijZhKsAikV0TMAQMetEu4y3/9S3xWdkuwUqlHYmgV7GWpCxYPtox5cFWoWblMK1t5ysrkID9hDkKz+1soO9ooSYImMma9o3rnD3GZKHls9iNTAErTty5YpDqkQUHT0YSQljPtpR8x8RdX3+qADF+Ym6x9jv4Q5WQXjKSoN0PgW0cB4FL5FctPj6sJkYmF3vhAqdY0SiygFPPNlA2GPHDKc9d7Xknd5LtNyGt7BdHhWJZaK5WlOcwRsLeJUaEUZIqaF/J3I/y7gs47FgxP+5MH2wXce8y95ZTYkrxYBrLvcQXqQZIegm+BsQx1EplwJ5oBKdxryCjU2bUQtV/4hb/JPQgXlifJefWhcLjkDtaIKAxm0b8SiWWwhNiKqj4JYtba1/PYyOJ3Y1lpcGUGsa6u2t/knbWhFoqJs5Hjm09yhQslZtDAoLtv0MqHcxh4l8elY8WM/Rp6+oz6YIWtw+CgkuiEi0H19ost3tgfBtRVU4VlWEJVemYAeucCeUq7ZanjoXDyrBprV57OPX8PUUmQ76y6LC0FH7zc7TWUFYF+lXE4YNvCq0Xt0e5kL4QCsv5W7y8FOaDHCB2b1eidw9IgxCQRtmOtdrd/mR/bGu+Sw3S1o6Kyrj0gZGrfSu5hoFklUA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4747.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(376002)(136003)(396003)(346002)(366004)(186003)(26005)(53546011)(2906002)(38070700005)(9686003)(66476007)(8676002)(66446008)(71200400001)(66556008)(64756008)(52536014)(8936002)(54906003)(107886003)(316002)(86362001)(55016002)(76236003)(122000001)(166002)(110136005)(7696005)(76116006)(83380400001)(5660300002)(478600001)(66946007)(4326008)(6506007)(38100700002)(33656002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?8rkM7Viz5WEu+KUOh0ZpyABsH0+WyhiOov1PitgtJuRdWUGERG02elA6gS1z?= =?us-ascii?Q?yWkMzQ0P5LDhpaFtRVwinJXXENev1kTstNgHIk3E2TqwZQxvfkBUywDQxWpd?= =?us-ascii?Q?pW7IhtHyxsXNazmk5s5R7+U/gm4l8sHgEkRjbiWn8jc2/DYyFJiDddxdHfAV?= =?us-ascii?Q?CW/cLBc2a53Gk6pS1ULtPaT55V35VCdYZ7ivQwRBlIgnAy/KaoyATHZulAjw?= =?us-ascii?Q?1KZPccOnz42omKrzDszGO1vUhmBSvjIgkLO/u34Q89fJSfDSIogVYvKUvUCC?= =?us-ascii?Q?01qFI02sarYygBx3mrJibXOu7al3XojWqQG2koP/MmgAcv0HFICbXb9Yiomu?= =?us-ascii?Q?UewFoXlS73dxjEQzs0H/WwCtLcZPrO4u6L87EFEjf92wNurZKnOtOSUxCEh7?= =?us-ascii?Q?ppjr//bP8oWXh7x4R8bh+n0Chhodx7V7O06vCI2+1VZ00jUsKyHl5zKyq3fk?= =?us-ascii?Q?rvvuw970VBxuFjFLFo32u74gPFSW+U27W1KKu/11wx967qazfDbVpNhh9qku?= =?us-ascii?Q?S2oe7b7dGNFIIlH0pQJyvT3t0F+/CUfvc4YNiX+M5iN3peY/J6a9atec5rzn?= =?us-ascii?Q?K04xpFC6G/3GLlX15YNlFlCvkC+eg0gyALOPj+R7B+8Qs4plGBo3iNZ4p1lO?= =?us-ascii?Q?PtDeXZcqcZLTsc0SQDwQaiVUkdJUkzZliG2ru6eakxJa3D1DGVIpX6QqxXDS?= =?us-ascii?Q?2d0ek/DpX/33uI3OO//HBGY+ijb0DtJcc0Iw4vas1ujgLF+KSnFnyFawTfWN?= =?us-ascii?Q?LVYZRebfBWMNZq9acPPTx2rU2W8YQN2wmEE1t20xT6ioeR58P9OjwHhE24lZ?= =?us-ascii?Q?ebexLijTyjVxdvEaMoCIwOlCdpQWO47Kk7ISGHXeoPXWQWl1N0WoyebkF0vY?= =?us-ascii?Q?rxqjHQmDtJdhJuPfNOtPKMYgrwnd7mj2KK4e6kg86385PmdjR6ORtZTbexBt?= =?us-ascii?Q?U59VfaOsfb+vIiWkfPq179tWattXBT/2NGKcL0Pv8Vp4T1DEU+j4CghL78cX?= =?us-ascii?Q?B5XB9a6LcckQM8vWhd7LAzJM+cyJNThk7OqdgQo8Muhw8uommS+Gpar32Zd1?= =?us-ascii?Q?IVOBEMaqIZzztb5KJKKmBCdhTDgagpKaZJ0zhvZS/s1DFpjKvzO+M29iAPLq?= =?us-ascii?Q?O2kn0RFo9ygFLN5orwexWD2hEtz8AltkPswk4njDcXT+YrlxO/Daex7HNlX9?= =?us-ascii?Q?vOLU6zAujt7jrOde46XB6giboV1lJdZDiSP5Zv1UUzB0awA4N8jGTkNS/ODR?= =?us-ascii?Q?2cPJhvwSToxTxZC5sU4UjugAUL+RB4B/D/VGFGvddJsi7UAF6fdQV5vbiSHd?= =?us-ascii?Q?q/anpyppQOqXKvHDAVAmoR3u?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4747.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3dd7a864-4342-41db-d4c6-08d973238c22 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Sep 2021 23:51:16.1091 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ZT0mudMAfiH8At9uAPN+wJZqHJ88lm3enrDaLgktzVoSNNsrMi7C4rU6RBcQdgus7X8GT511AenhHfXJ1UBXqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB0029 Return-Path: isaac.w.oram@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MW3PR11MB4747440E5DDD41AC318DAC26D0D49MW3PR11MB4747namp_" --_000_MW3PR11MB4747440E5DDD41AC318DAC26D0D49MW3PR11MB4747namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable That sounds very reasonable to me. I have done something similar with basi= c PPI/Protocol services to abstract phase specific differences that a lot o= f code simply doesn't need to care about. I even like the idea of a genera= l "phase agnostic services library" that handles these kinds of things that= would suffice for a lot of code that doesn't need driver model complexitie= s or some other phase specific complexities. That would likely be more an = RFC discussion though. I think case by case is also fine and more aligned = with the current library design. Regards, Isaac From: devel@edk2.groups.io On Behalf Of Bret Barkele= w via groups.io Sent: Wednesday, September 8, 2021 3:34 PM To: devel@edk2.groups.io; Oram, Isaac W Cc: Chiu, Chasel ; Desimone, Nathaniel L ; Liming Gao ; Dong, Eric Subject: Re: [EXTERNAL] [edk2-devel][edk2-platforms][PATCH V1 1/1] MinPlatf= ormPkg/Variable*Lib: Build VariableRead and VariableWrite libs Question: I've recently brought up with some that the GetVariable##() functions in Ue= fiLib are probably incorrect as they are written (because they assume thing= s like gRT and gBS availability). Would it perhaps make sense to move this = interface up into the MdePkg scope and leverage it to start removing some o= f those assumptions? I already have a TODO to start splitting UefiLib along phase lines (PEI, DX= E, MM, etc), but that work could largely be obviated with this abstraction. - Bret From: Oram, Isaac W via groups.io Sent: Wednesday, September 8, 2021 3:29 PM To: devel@edk2.groups.io Cc: Chasel Chiu; Desimone, Nathaniel L; Liming Gao; Dong, Eric Subject: [EXTERNAL] [edk2-devel][edk2-platforms][PATCH V1 1/1] MinPlatformP= kg/Variable*Lib: Build VariableRead and VariableWrite libs Add the VariableReadLib and VariableWriteLib instances to Components to ensure build when building MinPlatformPkg.dsc. Add a NULL library instance that provides the non-functional library instance for VariableReadLib designed for all phase use. Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Liming Gao > Cc: Eric Dong > Signed-off-by: Isaac Oram > --- Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariable= ReadLibNull.c | 75 ++++++++++++++++++++ Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariable= ReadLibNull.inf | 37 ++++++++++ Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc = | 6 +- 3 files changed, 117 insertions(+), 1 deletion(-) diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/= BaseVariableReadLibNull.c b/Platform/Intel/MinPlatformPkg/Library/BaseVaria= bleReadLibNull/BaseVariableReadLibNull.c new file mode 100644 index 0000000000..f276b7b6b4 --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVar= iableReadLibNull.c @@ -0,0 +1,75 @@ +/** @file + NULL implementation of Variable Read Lib + + This library provides phase agnostic access to the UEFI Variable Service= s. + This is done by implementing a wrapper on top of the phase specific mech= anism + for reading from UEFI variables. For example, the PEI implementation of = this + library uses EFI_PEI_READ_ONLY_VARIABLE2_PPI. The DXE implementation acc= esses + the UEFI Runtime Services Table, and the SMM implementation uses + EFI_SMM_VARIABLE_PROTOCOL. + + Using this library allows code to be written in a generic manner that ca= n be + used in PEI, DXE, or SMM without modification. + + @copyright + Copyright 2021 Intel Corporation.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include + +/** + Returns the value of a variable. + + @param[in] VariableName A Null-terminated string that is the name= of the vendor's + variable. + @param[in] VendorGuid A unique identifier for the vendor. + @param[out] Attributes If not NULL, a pointer to the memory loca= tion to return the + attributes bitmask for the variable. + @param[in, out] DataSize On input, the size in bytes of the return= Data buffer. + On output the size of data returned in Da= ta. + @param[out] Data The buffer to return the contents of the = variable. May be NULL + with a zero DataSize in order to determin= e the size buffer needed. + + @retval EFI_UNSUPPORTED This function is not implemented by this = instance of the LibraryClass + +**/ +EFI_STATUS +EFIAPI +VarLibGetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + OUT UINT32 *Attributes, OPTIONAL + IN OUT UINTN *DataSize, + OUT VOID *Data OPTIONAL + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Enumerates the current variable names. + + @param[in, out] VariableNameSize The size of the VariableName buffer. T= he size must be large + enough to fit input string supplied in= VariableName buffer. + @param[in, out] VariableName On input, supplies the last VariableNa= me that was returned + by GetNextVariableName(). On output, r= eturns the Nullterminated + string of the current variable. + @param[in, out] VendorGuid On input, supplies the last VendorGuid= that was returned by + GetNextVariableName(). On output, retu= rns the + VendorGuid of the current variable. + + @retval EFI_UNSUPPORTED This function is not implemented by th= is instance of the LibraryClass + +**/ +EFI_STATUS +EFIAPI +VarLibGetNextVariableName ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VendorGuid + ) +{ + return EFI_UNSUPPORTED; +} diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/= BaseVariableReadLibNull.inf b/Platform/Intel/MinPlatformPkg/Library/BaseVar= iableReadLibNull/BaseVariableReadLibNull.inf new file mode 100644 index 0000000000..3a397998a9 --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVar= iableReadLibNull.inf @@ -0,0 +1,37 @@ +## @file +# Component description file for NULL implementation of Variable Read Lib +# +# This library provides phase agnostic access to the UEFI Variable Service= s. +# This is done by implementing a wrapper on top of the phase specific mech= anism +# for reading from UEFI variables. For example, the PEI implementation of = this +# library uses EFI_PEI_READ_ONLY_VARIABLE2_PPI. The DXE implementation acc= esses +# the UEFI Runtime Services Table, and the SMM implementation uses +# EFI_SMM_VARIABLE_PROTOCOL. +# +# Using this library allows code to be written in a generic manner that ca= n be +# used in PEI, DXE, or SMM without modification. +# +# @copyright +# Copyright 2021 Intel Corporation.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +## +## NOTICE: This library is also available in MinPlatformPkg. This copy was= added +## for the convience of those that are using an older MinPlatformP= kg. +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D BaseVariableReadLibNull + FILE_GUID =3D 5C9E2489-329F-4D2A-90F1-F5CB2A88A3E6 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D VariableReadLib + +[Packages] + MdePkg/MdePkg.dec + +[Sources] + BaseVariableReadLibNull.c diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc b/Platform/In= tel/MinPlatformPkg/MinPlatformPkg.dsc index 07b776cecd..a09f8db3ab 100644 --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc @@ -74,7 +74,7 @@ FspWrapperApiTestLib|IntelFsp2WrapperPkg/Library/PeiFspWrapperApiTestLib= /PeiFspWrapperApiTestLib.inf FspWrapperHobProcessLib|MinPlatformPkg/FspWrapper/Library/PeiFspWrapperH= obProcessLib/PeiFspWrapperHobProcessLib.inf PlatformSecLib|MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSe= cLib/SecFspWrapperPlatformSecLib.inf - + VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVaria= bleReadLibNull.inf FspWrapperPlatformLib|MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPla= tformLib/PeiFspWrapperPlatformLib.inf BoardInitLib|MinPlatformPkg/PlatformInit/Library/BoardInitLibNull/BoardI= nitLibNull.inf @@ -214,5 +214,9 @@ MinPlatformPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf MinPlatformPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf + MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.i= nf + MinPlatformPkg/Library/SmmVariableReadLib/StandaloneMmVariableReadLib.in= f + MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMmVariableWriteLib.= inf + [BuildOptions] *_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFACES -- 2.27.0.windows.1 --_000_MW3PR11MB4747440E5DDD41AC318DAC26D0D49MW3PR11MB4747namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

That sounds very reasonable to me.  I have done= something similar with basic PPI/Protocol services to abstract phase speci= fic differences that a lot of code simply doesn’t need to care about.=   I even like the idea of a general “phase agnostic services library” that handles these kinds of things that would suff= ice for a lot of code that doesn’t need driver model complexities or = some other phase specific complexities.  That would likely be more an = RFC discussion though.  I think case by case is also fine and more aligned with the current library design.

 

Regards,
Isaac

 

From: devel@edk2.groups.io <devel@edk2.gro= ups.io> On Behalf Of Bret Barkelew via groups.io
Sent: Wednesday, September 8, 2021 3:34 PM
To: devel@edk2.groups.io; Oram, Isaac W <isaac.w.oram@intel.com&g= t;
Cc: Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel = L <nathaniel.l.desimone@intel.com>; Liming Gao <gaoliming@byosoft.= com.cn>; Dong, Eric <eric.dong@intel.com>
Subject: Re: [EXTERNAL] [edk2-devel][edk2-platforms][PATCH V1 1/1] M= inPlatformPkg/Variable*Lib: Build VariableRead and VariableWrite libs<= /o:p>

 

Question:

 

I’ve recently brought up with some that the Ge= tVariable##() functions in UefiLib are probably incorrect as they are writt= en (because they assume things like gRT and gBS availability). Would it per= haps make sense to move this interface up into the MdePkg scope and leverage it to start removing some of those assu= mptions?

 

I already have a TODO to start splitting UefiLib alo= ng phase lines (PEI, DXE, MM, etc), but that work could largely be obviated= with this abstraction.

 

- Bret

 

From: Oram, Isaac W via groups.io
Sent: Wednesday, September 8, 2021 3:29 PM
To: devel@edk2.groups.io=
Cc: Chasel Chiu; Desimone, Nathaniel L; Limi= ng Gao; Dong, Eric
Subject: [EXTERNAL] [edk2-devel][edk2-platforms][PATCH V1 1/1] MinPl= atformPkg/Variable*Lib: Build VariableRead and VariableWrite libs

 

Add the VariableReadL= ib and VariableWriteLib instances to Components to
ensure build when building MinPlatformPkg.dsc.
Add a NULL library instance that provides the non-functional library
instance for VariableReadLib designed for all phase use.

Cc: Chasel Chiu <chasel.chiu@in= tel.com>
Cc: Nate DeSimone <nat= haniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@by= osoft.com.cn>
Cc: Eric Dong <eric.dong@intel.co= m>
Signed-off-by: Isaac Oram <isa= ac.w.oram@intel.com>
---
 Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVar= iableReadLibNull.c   | 75 ++++++++++++++++++++
 Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVar= iableReadLibNull.inf | 37 ++++++++++
 Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc   &nb= sp;            =             &nb= sp;            = |  6 +-
 3 files changed, 117 insertions(+), 1 deletion(-)

diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/= BaseVariableReadLibNull.c b/Platform/Intel/MinPlatformPkg/Library/BaseVaria= bleReadLibNull/BaseVariableReadLibNull.c
new file mode 100644
index 0000000000..f276b7b6b4
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVar= iableReadLibNull.c
@@ -0,0 +1,75 @@
+/** @file
+  NULL implementation of Variable Read Lib
+
+  This library provides phase agnostic access to the UEFI Variable Se= rvices.
+  This is done by implementing a wrapper on top of the phase specific= mechanism
+  for reading from UEFI variables. For example, the PEI implementatio= n of this
+  library uses EFI_PEI_READ_ONLY_VARIABLE2_PPI. The DXE implementatio= n accesses
+  the UEFI Runtime Services Table, and the SMM implementation uses +  EFI_SMM_VARIABLE_PROTOCOL.
+
+  Using this library allows code to be written in a generic manner th= at can be
+  used in PEI, DXE, or SMM without modification.
+
+  @copyright
+  Copyright 2021 Intel Corporation. <BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Uefi/UefiBaseType.h>
+
+/**
+  Returns the value of a variable.
+
+  @param[in]       VariableName  A= Null-terminated string that is the name of the vendor's
+            &n= bsp;            = ;        variable.
+  @param[in]       VendorGuid &nbs= p;  A unique identifier for the vendor.
+  @param[out]      Attributes  &nb= sp; If not NULL, a pointer to the memory location to return the
+            &n= bsp;            = ;        attributes bitmask for the vari= able.
+  @param[in, out]  DataSize      On inp= ut, the size in bytes of the return Data buffer.
+            &n= bsp;            = ;        On output the size of data retu= rned in Data.
+  @param[out]      Data   &nb= sp;      The buffer to return the contents of the = variable. May be NULL
+            &n= bsp;            = ;        with a zero DataSize in order t= o determine the size buffer needed.
+
+  @retval EFI_UNSUPPORTED        T= his function is not implemented by this instance of the LibraryClass
+
+**/
+EFI_STATUS
+EFIAPI
+VarLibGetVariable (
+  IN     CHAR16     &nbs= p;            &= nbsp;   *VariableName,
+  IN     EFI_GUID     &n= bsp;            = ;  *VendorGuid,
+  OUT    UINT32      &nb= sp;            =    *Attributes,    OPTIONAL
+  IN OUT UINTN         &= nbsp;           &nbs= p; *DataSize,
+  OUT    VOID       = ;            &n= bsp;    *Data        = ;   OPTIONAL
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Enumerates the current variable names.
+
+  @param[in, out]  VariableNameSize The size of the VariableName= buffer. The size must be large
+            &n= bsp;            = ;           enough to fit= input string supplied in VariableName buffer.
+  @param[in, out]  VariableName     On input= , supplies the last VariableName that was returned
+            &n= bsp;            = ;           by GetNextVar= iableName(). On output, returns the Nullterminated
+            &n= bsp;            = ;           string of the= current variable.
+  @param[in, out]  VendorGuid      = ; On input, supplies the last VendorGuid that was returned by
+            &n= bsp;            = ;           GetNextVariab= leName(). On output, returns the
+            &n= bsp;            = ;           VendorGuid of= the current variable.
+
+  @retval EFI_UNSUPPORTED       &n= bsp;   This function is not implemented by this instance of the L= ibraryClass
+
+**/
+EFI_STATUS
+EFIAPI
+VarLibGetNextVariableName (
+  IN OUT UINTN         &= nbsp;          *VariableNameSi= ze,
+  IN OUT CHAR16         =           *VariableName,
+  IN OUT EFI_GUID        &nbs= p;        *VendorGuid
+  )
+{
+  return EFI_UNSUPPORTED;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/= BaseVariableReadLibNull.inf b/Platform/Intel/MinPlatformPkg/Library/BaseVar= iableReadLibNull/BaseVariableReadLibNull.inf
new file mode 100644
index 0000000000..3a397998a9
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVar= iableReadLibNull.inf
@@ -0,0 +1,37 @@
+## @file
+# Component description file for NULL implementation of Variable Read Lib<= br> +#
+# This library provides phase agnostic access to the UEFI Variable Service= s.
+# This is done by implementing a wrapper on top of the phase specific mech= anism
+# for reading from UEFI variables. For example, the PEI implementation of = this
+# library uses EFI_PEI_READ_ONLY_VARIABLE2_PPI. The DXE implementation acc= esses
+# the UEFI Runtime Services Table, and the SMM implementation uses
+# EFI_SMM_VARIABLE_PROTOCOL.
+#
+# Using this library allows code to be written in a generic manner that ca= n be
+# used in PEI, DXE, or SMM without modification.
+#
+# @copyright
+# Copyright 2021 Intel Corporation. <BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+##
+## NOTICE: This library is also available in MinPlatformPkg. This copy was= added
+##         for the convience of th= ose that are using an older MinPlatformPkg.
+##
+
+[Defines]
+  INF_VERSION         &n= bsp;          =3D 0x00010005 +  BASE_NAME         &nbs= p;            =3D Ba= seVariableReadLibNull
+  FILE_GUID         &nbs= p;            =3D 5C= 9E2489-329F-4D2A-90F1-F5CB2A88A3E6
+  VERSION_STRING         = ;        =3D 1.0
+  MODULE_TYPE         &n= bsp;          =3D BASE
+  LIBRARY_CLASS         =          =3D VariableReadLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[Sources]
+  BaseVariableReadLibNull.c
diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc b/Platform/In= tel/MinPlatformPkg/MinPlatformPkg.dsc
index 07b776cecd..a09f8db3ab 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
@@ -74,7 +74,7 @@
   FspWrapperApiTestLib|IntelFsp2WrapperPkg/Library/PeiFspWrapper= ApiTestLib/PeiFspWrapperApiTestLib.inf
   FspWrapperHobProcessLib|MinPlatformPkg/FspWrapper/Library/PeiF= spWrapperHobProcessLib/PeiFspWrapperHobProcessLib.inf
   PlatformSecLib|MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/SecFspWrapperPlatformSecLib.inf
-
+  VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/Base= VariableReadLibNull.inf
   FspWrapperPlatformLib|MinPlatformPkg/FspWrapper/Library/PeiFsp= WrapperPlatformLib/PeiFspWrapperPlatformLib.inf
 
   BoardInitLib|MinPlatformPkg/PlatformInit/Library/BoardInitLibN= ull/BoardInitLibNull.inf
@@ -214,5 +214,9 @@
   MinPlatformPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf
   MinPlatformPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf
 
+  MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibN= ull.inf
+  MinPlatformPkg/Library/SmmVariableReadLib/StandaloneMmVariableReadL= ib.inf
+  MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMmVariableWrit= eLib.inf
+
 [BuildOptions]
   *_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFACES
--
2.27.0.windows.1




 

--_000_MW3PR11MB4747440E5DDD41AC318DAC26D0D49MW3PR11MB4747namp_--