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.web08.8494.1623129673490752064 for ; Mon, 07 Jun 2021 22:21:13 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=dmA3oBLR; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: hao.a.wu@intel.com) IronPort-SDR: T2nHq49xGqZOeNsivCKlfV3XEDUsADimfUhDyBywOAyqEC8/qh4qIRJYsPI6nmfPH/EIIasygH iHVPSgyUzqcQ== X-IronPort-AV: E=McAfee;i="6200,9189,10008"; a="265925231" X-IronPort-AV: E=Sophos;i="5.83,256,1616482800"; d="scan'208";a="265925231" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2021 22:21:12 -0700 IronPort-SDR: lBPD0tU0G7TZCV+XOVlpvtzGtdnAnuxv19blLVLAjuk0rusSWs75RsrYkYDT2WlAmyzBQbYt1Z c+9HvIE220TQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,256,1616482800"; d="scan'208";a="637521567" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by fmsmga005.fm.intel.com with ESMTP; 07 Jun 2021 22:21:12 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 7 Jun 2021 22:21:11 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 7 Jun 2021 22:21:11 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Mon, 7 Jun 2021 22:21:11 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.169) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.4; Mon, 7 Jun 2021 22:21:11 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kTuQ9ISg+ubOklINCF/H96lOuKpHLmFFFYUT1pYsQ64zOUCrSBcJ3dWOMUAc1ZFj/1wv5Eoa+VN1eMgLAImFDQmKUD9oQ5wtju8okJKf8gbOrbYsr3KWq9Lc4CkwFnOZN8PeXA2q4Mp8PLqqSlxo+8mlR/wpIOqFA10P27T7hfOJK4ke4toxKdSGeCSGq7SsrFDYFiWKx8HP+sXfE9n9avD5Q1biE7iWf0tcgL7iadeMBhPi2XSTRGu46kCD0XL59JLEMVsIvoDv+ssPu7OS+fWM7PlsHOGPf8eQ9prHgxTMJ+KlKUvjjrNnjuwtvSNHfV//eIWTe56iT6fC0SifmQ== 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=qUibsrrXx4nIRCgPAnrgXaN6xuzBgOPvDn25SMoXiT0=; b=R58B0wR8YJvLUEOgnvRRGIrT6RtO2DxnjbZ85T4NfBddYEqy9Qmb4ziO+ncbIC1iSzTJtxKlODEwzSC5aFT0WLm5SEy/02yADljZYMnTT0GRxMhYfgegQcR/U5tXXqj0QZ3HO6Z8oVLO/ue3TORE9AZY+43DRMe5mpDsvMG8ks5yns72sMNuanaqAMJwPUSrf3wmEdZaSG50pOQQfjoogJ5A/JWtxwhnu4Yuux2xFz/TANkUUyEbfLPN1U9R4T/TE/6GKpmisVy/edS6n5koxUxFioHmYpywEdvNgffsISXj6A4ev3gAUPRiVCOZUktCd6aDletRrt3B9GJy9eBEqQ== 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=qUibsrrXx4nIRCgPAnrgXaN6xuzBgOPvDn25SMoXiT0=; b=dmA3oBLRrPrM6qyOdgSNru4aTvOhNR02Ly3CDD1RSSwSX++SXdiFngZDFMAFZSxGthD4fAvA8fFQrZE/VKfQXqEvpkA4ZuJv+8EWu5+mVKFwICkocU5MQa8H8BElhxkxvVw81sRuJBx98TKIX9Cp7u8Y0E+0ny34Usuw6vrWu2A= Received: from BN8PR11MB3666.namprd11.prod.outlook.com (2603:10b6:408:8c::19) by BN6PR1101MB2355.namprd11.prod.outlook.com (2603:10b6:404:94::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.22; Tue, 8 Jun 2021 05:21:09 +0000 Received: from BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::b9d0:5694:1b70:c031]) by BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::b9d0:5694:1b70:c031%4]) with mapi id 15.20.4195.030; Tue, 8 Jun 2021 05:21:09 +0000 From: "Wu, Hao A" To: "Liu, Zhiguang" , "devel@edk2.groups.io" CC: "Wang, Jian J" , "Bi, Dandan" , Liming Gao , "Ni, Ray" Subject: Re: [Patch V3 8/9] MdeModulePkg/ACPI: Install ACPI table from HOB. Thread-Topic: [Patch V3 8/9] MdeModulePkg/ACPI: Install ACPI table from HOB. Thread-Index: AQHXWSX/97OL3s0mLEicOYT4sfjLWqsJmaHg Date: Tue, 8 Jun 2021 05:21:09 +0000 Message-ID: References: <20210604094227.1890-1-zhiguang.liu@intel.com> <20210604094227.1890-9-zhiguang.liu@intel.com> In-Reply-To: <20210604094227.1890-9-zhiguang.liu@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.143.16] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 57ba4134-7dd7-4531-ff8c-08d92a3d398b x-ms-traffictypediagnostic: BN6PR1101MB2355: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:133; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: HkjNlegCCKBjHy9xJnVFxNdp3VICFg6KM4DOKdpjghRmh6IGHqJHZaeiIYhCk520nu0tPNBs6LlEdGKqbC3OFzw3WhTLUQNpxfOwYTRIx7I+O/w0215ZjIWVHIkEhGU3+ZN6evV1bjBxV8/gdEZV0EC9lwk02pGgER+PVQPuXRh+nT2jtvPV26F9whEiePUl4uLKsVaNXHTxZnascAZm3yNT1eM+fXo20MndUN+9kxgIPm8ChPscUdmcZZsgZZwxf1HkJgomGjFYx8RdCw3aEZII/AVJS/n3dDTed7XW9RYt7hsSOg3Ok/4FsqnSEntWSoONiO95LuAE+4Hu6RVnhw4M2avyoiDBDWrB74wSTBXw9Hhxwoy7PPx/iZby1F+3PzUdAkM+UQcHAeWp79JY1IlF1D8EitoB5ezot3AZRJbddrwfCyg0Sdi+JS7MOtRHqOQE13sF0W9Ihu3NHOSioA0E6+ls+VgVhrG6D8n/P+3ldFKJE/SuQlBE/D4BgzjKHcprJCm79kGVVXJgF/hP/jIOXQZbhcfBpJhDxE14I9OwOBKq2b/3iMsdkh1z6lhA6SM7UgZ7FnmXcdtV9Ucg4faIaEin8+JfALBxLPCwaQQ= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR11MB3666.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(396003)(366004)(376002)(346002)(136003)(86362001)(110136005)(55016002)(316002)(54906003)(7696005)(30864003)(52536014)(33656002)(53546011)(6506007)(5660300002)(186003)(26005)(38100700002)(8676002)(2906002)(64756008)(66476007)(66446008)(66946007)(76116006)(9686003)(66556008)(83380400001)(8936002)(107886003)(71200400001)(122000001)(478600001)(4326008)(19627235002)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?xsKPqIFCXRjsWoNZIHgokim9EJDzlGy7wBZjIlt4mcpihBl/DYtP587rbXVT?= =?us-ascii?Q?Xf2HL69W10mMqrbv4WjzXQ9CIZAV62I/t3DK4ADr2PnHgpte+RCx1TwMjgaT?= =?us-ascii?Q?rFW4jt2cz/ObeO4dDr6DN3rGtdwQTUvYeCqEaP/vzf4AlsMktSVhdDxbnBko?= =?us-ascii?Q?Pe/OqcC1nhYDS/i79AN9J3ytZ9ewHIZClgWng1aSpq+fX5yOQNusImELAlSo?= =?us-ascii?Q?Rx2O6H82hU+NNUPdJX2kDJLgusq1zj3M+Q8grOqHZGKxbOdOUgYf+jMDINVe?= =?us-ascii?Q?P+ueCjhq709q3jQ+24Ymj9Tb2z79oCgEqgL1antwWq+wQZpF4T4kqhQ5KaQU?= =?us-ascii?Q?0SRPMf1WNOViHoLbrtg15VtkmPeRCedI5Gvk8sknP0uyafqvNXn7iOBvVX5V?= =?us-ascii?Q?nHh3QXmvNFa4qPQui+3d5n5v4ZxJA1m5W4a2i8Ff5C8Z8RZ5F8/Rfr8u6IC9?= =?us-ascii?Q?YpVEKiIwtnpi3a8ifWo0jGxqUuHqGDPilP89YY2vjEUi4oVQzOxdIfUJaeMI?= =?us-ascii?Q?GOp8H3TvtChnbsYS7kLR2rH73hJOCIIn8zdaimX+ReKVAmt6GS4D85x4kmF1?= =?us-ascii?Q?hV1C4WZl0uH6bES6OBdyrFsBYxUURPQiKlR8oTNTBsjIxJF9Fgy5hk09Znt+?= =?us-ascii?Q?sazLezZfxGa5V7uKHA3t3NlegiQUxfBBp5MtTSTfVFXINFKtVdcViGsRVMVd?= =?us-ascii?Q?DY7MMhaa2pjuO295KrfbtqhkUGP3TeMyBc3gbQM6U4TunL1Q+sUb7+VlHOhV?= =?us-ascii?Q?qg1T2Azk/VOdB4P8Z1udkyBjU6RLLdvCtEskkpw4Dx2q5y6Y7kqi3EYXYeDJ?= =?us-ascii?Q?ULUiTiwwPpZHzyMxNkdJUc6QnPcDBP0AJ4amvSYd2fCz0MNuHQz8cmHOre8b?= =?us-ascii?Q?4wcdAT8/vGgovNu6Ut4w0f+ShUFD1jHf0fzVCALrx7Ckk/FSmdR8hqX2RjBv?= =?us-ascii?Q?vytKo0lmqOJDaeALL64NECUa9TjH/9ApQWYfXUxP8yEz/URHnu0aG6ts9BOG?= =?us-ascii?Q?gxLfWMmLkOh858OV5Y2ZaRvwU9XdL5269GAEE/8sHIc9y1tvoLULfb/B9oyS?= =?us-ascii?Q?DyTlW2tsHwGroluhSQRxIpNz/OVMUs5y4vCd/9JDdknN9KAsn4NvrrEs8HFI?= =?us-ascii?Q?UV9bHM6NR4KIhyzxFcU5GOfAuf4+XkgnnLPIkgXAAckNvfQrUVDr0r0RrutE?= =?us-ascii?Q?YsvZDWS28l/e4FkDLArJMnwgR93nLgIyipQGtOtsV76Vaawmw0OoS0ceFwOf?= =?us-ascii?Q?4ak14jSfXqfVp+NEpjkWIJySUu4uUdr/zXOYMo292NBsBOzORfiiqykqFDzo?= =?us-ascii?Q?wuad9ic/1BzufqUEQ5hFlbgG?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN8PR11MB3666.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57ba4134-7dd7-4531-ff8c-08d92a3d398b X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jun 2021 05:21:09.5064 (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: qTUrmAamLEIbw9cRHIwBIkijtCF1Npnm1pre+Rr4j8d0/ER4x63bvOYnkvnt027RzQJfFULO7aNdeyj4nuCphA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1101MB2355 Return-Path: hao.a.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Liu, Zhiguang > Sent: Friday, June 4, 2021 5:42 PM > To: devel@edk2.groups.io > Cc: Wang, Jian J ; Wu, Hao A ; > Bi, Dandan ; Liming Gao > ; Ni, Ray > Subject: [Patch V3 8/9] MdeModulePkg/ACPI: Install ACPI table from HOB. >=20 > V1: > If HOB contains APCI table information, entry point of AcpiTableDxe.inf > should parse the APCI table from HOB, and install these tables. > We assume the whole ACPI table (starting with > EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER) > is contained by a single gEfiAcpiTableGuid HOB. >=20 > V2: > If error happens when installing ACPI table, stop installing and removing= all > the tables that > are already added. Reviewed-by: Hao A Wu Best Regards, Hao Wu >=20 > Cc: Jian J Wang > Cc: Hao A Wu > Cc: Dandan Bi > Cc: Liming Gao > Cc: Ray Ni > Signed-off-by: Zhiguang Liu > --- > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c | 92 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > +++++++--------------------------- > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h | 38 > +++++++++++++++++++++++++++++++++++++- > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf | 8 > +++++--- > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 171 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++++++++++++++++++++++++++++++++++++++++++++++++------- > 4 files changed, 271 insertions(+), 38 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c > b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c > index 14ced68e64..d98573d613 100644 > --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c > +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c > @@ -1,7 +1,7 @@ > /** @file >=20 > ACPI Sdt Protocol Driver >=20 >=20 >=20 > - Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. >=20 > + Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved. >=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 >=20 >=20 > **/ >=20 > @@ -191,8 +191,7 @@ SdtNotifyAcpiList ( > /** >=20 > Returns a requested ACPI table. >=20 >=20 >=20 > - The GetAcpiTable() function returns a pointer to a buffer containing t= he > ACPI table associated >=20 > - with the Index that was input. The following structures are not consid= ered > elements in the list of >=20 > + The following structures are not considered elements in the list of >=20 > ACPI tables: >=20 > - Root System Description Pointer (RSD_PTR) >=20 > - Root System Description Table (RSDT) >=20 > @@ -201,42 +200,32 @@ SdtNotifyAcpiList ( > member. For tables installed via the > EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface, >=20 > the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion. >=20 >=20 >=20 > - @param[in] Index The zero-based index of the table to retriev= e. >=20 > - @param[out] Table Pointer for returning the table buffer. >=20 > - @param[out] Version On return, updated with the ACPI versions to > which this table belongs. Type >=20 > - EFI_ACPI_TABLE_VERSION is defined in "Relate= d Definitions" > in the >=20 > - EFI_ACPI_SDT_PROTOCOL. >=20 > - @param[out] TableKey On return, points to the table key for the > specified ACPI system definition table. >=20 > - This is identical to the table key used in t= he > EFI_ACPI_TABLE_PROTOCOL. >=20 > - The TableKey can be passed to > EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable() >=20 > - to uninstall the table. >=20 > - @retval EFI_SUCCESS The function completed successfully. >=20 > - @retval EFI_NOT_FOUND The requested index is too large and a table > was not found. >=20 > + @param[in] AcpiTableInstance ACPI table Instance. >=20 > + @param[in] Index The zero-based index of the table to = retrieve. >=20 > + @param[out] Table Pointer for returning the table buffe= r. >=20 > + @param[out] Version On return, updated with the ACPI vers= ions to > which this table belongs. Type >=20 > + EFI_ACPI_TABLE_VERSION is defined in = "Related > Definitions" in the >=20 > + EFI_ACPI_SDT_PROTOCOL. >=20 > + @param[out] TableKey On return, points to the table key fo= r the > specified ACPI system definition table. >=20 > + This is identical to the table key us= ed in the > EFI_ACPI_TABLE_PROTOCOL. >=20 > + The TableKey can be passed to > EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable() >=20 > + to uninstall the table. >=20 > + @retval EFI_SUCCESS The function completed successfully. >=20 > + @retval EFI_NOT_FOUND The requested index is too large and = a > table was not found. >=20 > **/ >=20 > EFI_STATUS >=20 > -EFIAPI >=20 > -GetAcpiTable2 ( >=20 > +SdtGetAcpiTable ( >=20 > + IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance, >=20 > IN UINTN Index, >=20 > OUT EFI_ACPI_SDT_HEADER **Table, >=20 > OUT EFI_ACPI_TABLE_VERSION *Version, >=20 > OUT UINTN *TableKey >=20 > ) >=20 > { >=20 > - EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance; >=20 > UINTN TableIndex; >=20 > LIST_ENTRY *CurrentLink; >=20 > LIST_ENTRY *StartLink; >=20 > EFI_ACPI_TABLE_LIST *CurrentTable; >=20 > - >=20 > - ASSERT (Table !=3D NULL); >=20 > - ASSERT (Version !=3D NULL); >=20 > - ASSERT (TableKey !=3D NULL); >=20 > - >=20 > - // >=20 > - // Get the instance of the ACPI Table >=20 > - // >=20 > - AcpiTableInstance =3D SdtGetAcpiTableInstance (); >=20 > - >=20 > // >=20 > // Find the table >=20 > // >=20 > @@ -270,6 +259,55 @@ GetAcpiTable2 ( > return EFI_SUCCESS; >=20 > } >=20 >=20 >=20 > +/** >=20 > + Returns a requested ACPI table. >=20 > + >=20 > + The GetAcpiTable() function returns a pointer to a buffer containing t= he > ACPI table associated >=20 > + with the Index that was input. The following structures are not consid= ered > elements in the list of >=20 > + ACPI tables: >=20 > + - Root System Description Pointer (RSD_PTR) >=20 > + - Root System Description Table (RSDT) >=20 > + - Extended System Description Table (XSDT) >=20 > + Version is updated with a bit map containing all the versions of ACPI = of > which the table is a >=20 > + member. For tables installed via the > EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface, >=20 > + the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion. >=20 > + >=20 > + @param[in] Index The zero-based index of the table to retriev= e. >=20 > + @param[out] Table Pointer for returning the table buffer. >=20 > + @param[out] Version On return, updated with the ACPI versions to > which this table belongs. Type >=20 > + EFI_ACPI_TABLE_VERSION is defined in "Relate= d Definitions" > in the >=20 > + EFI_ACPI_SDT_PROTOCOL. >=20 > + @param[out] TableKey On return, points to the table key for the > specified ACPI system definition table. >=20 > + This is identical to the table key used in t= he > EFI_ACPI_TABLE_PROTOCOL. >=20 > + The TableKey can be passed to > EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable() >=20 > + to uninstall the table. >=20 > + @retval EFI_SUCCESS The function completed successfully. >=20 > + @retval EFI_NOT_FOUND The requested index is too large and a table > was not found. >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +GetAcpiTable2 ( >=20 > + IN UINTN Index, >=20 > + OUT EFI_ACPI_SDT_HEADER **Table, >=20 > + OUT EFI_ACPI_TABLE_VERSION *Version, >=20 > + OUT UINTN *TableKey >=20 > + ) >=20 > +{ >=20 > + EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance; >=20 > + >=20 > + ASSERT (Table !=3D NULL); >=20 > + ASSERT (Version !=3D NULL); >=20 > + ASSERT (TableKey !=3D NULL); >=20 > + >=20 > + // >=20 > + // Get the instance of the ACPI Table >=20 > + // >=20 > + AcpiTableInstance =3D SdtGetAcpiTableInstance (); >=20 > + >=20 > + return SdtGetAcpiTable (AcpiTableInstance, Index, Table, Version, > TableKey); >=20 > +} >=20 > + >=20 > + >=20 > /** >=20 > Register a callback when an ACPI table is installed. >=20 >=20 >=20 > diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h > b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h > index 9d7cf7ccfc..0af2d11a1a 100644 > --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h > +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h > @@ -1,7 +1,7 @@ > /** @file >=20 > ACPI Table Protocol Driver >=20 >=20 >=20 > - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
>=20 > + Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 >=20 >=20 > **/ >=20 > @@ -24,6 +24,8 @@ > #include >=20 > #include >=20 > #include >=20 > +#include >=20 > +#include >=20 >=20 >=20 > // >=20 > // Statements that include other files >=20 > @@ -228,6 +230,40 @@ SdtAcpiTableAcpiSdtConstructor ( > IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance >=20 > ); >=20 >=20 >=20 > +/** >=20 > + Returns a requested ACPI table. >=20 > + >=20 > + The following structures are not considered elements in the list of >=20 > + ACPI tables: >=20 > + - Root System Description Pointer (RSD_PTR) >=20 > + - Root System Description Table (RSDT) >=20 > + - Extended System Description Table (XSDT) >=20 > + Version is updated with a bit map containing all the versions of ACPI = of > which the table is a >=20 > + member. For tables installed via the > EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface, >=20 > + the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion. >=20 > + >=20 > + @param[in] AcpiTableInstance ACPI table Instance. >=20 > + @param[in] Index The zero-based index of the table to = retrieve. >=20 > + @param[out] Table Pointer for returning the table buffe= r. >=20 > + @param[out] Version On return, updated with the ACPI vers= ions to > which this table belongs. Type >=20 > + EFI_ACPI_TABLE_VERSION is defined in = "Related > Definitions" in the >=20 > + EFI_ACPI_SDT_PROTOCOL. >=20 > + @param[out] TableKey On return, points to the table key fo= r the > specified ACPI system definition table. >=20 > + This is identical to the table key us= ed in the > EFI_ACPI_TABLE_PROTOCOL. >=20 > + The TableKey can be passed to > EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable() >=20 > + to uninstall the table. >=20 > + @retval EFI_SUCCESS The function completed successfully. >=20 > + @retval EFI_NOT_FOUND The requested index is too large and = a > table was not found. >=20 > +**/ >=20 > +EFI_STATUS >=20 > +SdtGetAcpiTable ( >=20 > + IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance, >=20 > + IN UINTN Index, >=20 > + OUT EFI_ACPI_SDT_HEADER **Table, >=20 > + OUT EFI_ACPI_TABLE_VERSION *Version, >=20 > + OUT UINTN *TableKey >=20 > + ); >=20 > + >=20 > // >=20 > // export PrivateData symbol, because we need that in AcpiSdtProtol > implementation >=20 > // >=20 > diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf > b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf > index d341df439e..9e34f8ea41 100644 > --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf > +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf > @@ -4,7 +4,7 @@ > # This driver initializes ACPI tables (Rsdp, Rsdt and Xsdt) and produce= s > UEFI/PI >=20 > # services to install/uninstall/manage ACPI tables. >=20 > # >=20 > -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. >=20 > +# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved. >=20 > # Copyright (c) 2016, Linaro Ltd. All rights reserved.
>=20 > # SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > # >=20 > @@ -51,10 +51,12 @@ > DebugLib >=20 > BaseLib >=20 > PcdLib >=20 > + HobLib >=20 >=20 >=20 > [Guids] >=20 > - gEfiAcpi10TableGuid ## PRODUCES ## SystemTab= le >=20 > - gEfiAcpiTableGuid ## PRODUCES ## SystemTab= le >=20 > + gEfiAcpi10TableGuid ## PRODUCES ##= SystemTable >=20 > + gEfiAcpiTableGuid ## PRODUCES ##= SystemTable >=20 > + gPldAcpiTableGuid ## SOMETIMES_CONSUMES ##= HOB >=20 >=20 >=20 > [FeaturePcd] >=20 > gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol ## > CONSUMES >=20 > diff --git > a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > index 5a2afdff27..cd79a1082c 100644 > --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > @@ -1,7 +1,7 @@ > /** @file >=20 > ACPI Table Protocol Implementation >=20 >=20 >=20 > - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
>=20 > + Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
>=20 > Copyright (c) 2016, Linaro Ltd. All rights reserved.
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 >=20 >=20 > @@ -30,6 +30,7 @@ STATIC EFI_ALLOCATE_TYPE mAcpiTableAllocType; > @param Table Table to add. >=20 > @param Checksum Does the table require checksumming. >=20 > @param Version The version of the list to add the t= able to. >=20 > + @param IsFromHob True, if add Apci Table from Hob Lis= t. >=20 > @param Handle Pointer for returning the handle. >=20 >=20 >=20 > @return EFI_SUCCESS The function completed successfully. >=20 > @@ -44,6 +45,7 @@ AddTableToList ( > IN VOID *Table, >=20 > IN BOOLEAN Checksum, >=20 > IN EFI_ACPI_TABLE_VERSION Version, >=20 > + IN BOOLEAN IsFromHob, >=20 > OUT UINTN *Handle >=20 > ); >=20 >=20 >=20 > @@ -238,6 +240,7 @@ InstallAcpiTable ( > AcpiTableBufferConst, >=20 > TRUE, >=20 > Version, >=20 > + FALSE, >=20 > TableKey >=20 > ); >=20 > if (!EFI_ERROR (Status)) { >=20 > @@ -472,6 +475,7 @@ FreeTableMemory ( > @param Table Table to add. >=20 > @param Checksum Does the table require checksumming. >=20 > @param Version The version of the list to add the t= able to. >=20 > + @param IsFromHob True, if add Apci Table from Hob Lis= t. >=20 > @param Handle Pointer for returning the handle. >=20 >=20 >=20 > @return EFI_SUCCESS The function completed successfully. >=20 > @@ -487,6 +491,7 @@ AddTableToList ( > IN VOID *Table, >=20 > IN BOOLEAN Checksum, >=20 > IN EFI_ACPI_TABLE_VERSION Version, >=20 > + IN BOOLEAN IsFromHob, >=20 > OUT UINTN *Handle >=20 > ) >=20 > { >=20 > @@ -553,12 +558,17 @@ AddTableToList ( > // SMM communication ACPI table. >=20 > // >=20 > ASSERT ((EFI_PAGE_SIZE % 64) =3D=3D 0); >=20 > - Status =3D gBS->AllocatePages ( >=20 > - AllocateMaxAddress, >=20 > - EfiACPIMemoryNVS, >=20 > - EFI_SIZE_TO_PAGES (CurrentTableList->TableSize), >=20 > - &AllocPhysAddress >=20 > - ); >=20 > + if (IsFromHob){ >=20 > + AllocPhysAddress =3D (UINTN)Table; >=20 > + Status =3D EFI_SUCCESS; >=20 > + } else { >=20 > + Status =3D gBS->AllocatePages ( >=20 > + AllocateMaxAddress, >=20 > + EfiACPIMemoryNVS, >=20 > + EFI_SIZE_TO_PAGES (CurrentTableList->TableSize), >=20 > + &AllocPhysAddress >=20 > + ); >=20 > + } >=20 > } else if (mAcpiTableAllocType =3D=3D AllocateAnyPages) { >=20 > // >=20 > // If there is no allocation limit, there is also no need to use pag= e >=20 > @@ -1689,6 +1699,151 @@ ChecksumCommonTables ( > return EFI_SUCCESS; >=20 > } >=20 >=20 >=20 > +/** >=20 > + This function will find gPldAcpiTableGuid Guid Hob, and install Acpi t= able > from it. >=20 > + >=20 > + @param AcpiTableInstance Protocol instance private data. >=20 > + >=20 > + @return EFI_SUCCESS The function completed successfully. >=20 > + @return EFI_NOT_FOUND The function doesn't find the > gEfiAcpiTableGuid Guid Hob. >=20 > + @return EFI_ABORTED The function could not complete successfull= y. >=20 > + >=20 > +**/ >=20 > +EFI_STATUS >=20 > +InstallAcpiTableFromHob ( >=20 > + EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance >=20 > + ) >=20 > +{ >=20 > + EFI_HOB_GUID_TYPE *GuidHob; >=20 > + EFI_ACPI_TABLE_VERSION Version; >=20 > + EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; >=20 > + EFI_ACPI_DESCRIPTION_HEADER *Rsdt; >=20 > + EFI_ACPI_DESCRIPTION_HEADER *ChildTable; >=20 > + UINT64 ChildTableAddress; >=20 > + UINTN Count; >=20 > + UINTN Index; >=20 > + UINTN TableKey; >=20 > + EFI_STATUS Status; >=20 > + UINTN EntrySize; >=20 > + PLD_ACPI_TABLE *AcpiTableAdress; >=20 > + VOID *TableToInstall; >=20 > + EFI_ACPI_SDT_HEADER *Table; >=20 > + PLD_GENERIC_HEADER *GenericHeader; >=20 > + >=20 > + TableKey =3D 0; >=20 > + Version =3D PcdGet32 (PcdAcpiExposedTableVersions); >=20 > + Status =3D EFI_SUCCESS; >=20 > + // >=20 > + // HOB only contains the ACPI table in 2.0+ format. >=20 > + // >=20 > + GuidHob =3D GetFirstGuidHob (&gPldAcpiTableGuid); >=20 > + if (GuidHob =3D=3D NULL) { >=20 > + return EFI_NOT_FOUND; >=20 > + } >=20 > + >=20 > + GenericHeader =3D (PLD_GENERIC_HEADER *) GET_GUID_HOB_DATA > (GuidHob); >=20 > + if ((sizeof (PLD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE > (GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE > (GuidHob))) { >=20 > + return EFI_NOT_FOUND; >=20 > + } >=20 > + if (GenericHeader->Revision =3D=3D PLD_ACPI_TABLE_REVISION) { >=20 > + // >=20 > + // PLD_ACPI_TABLE structure is used when Revision equals to > PLD_ACPI_TABLE_REVISION >=20 > + // >=20 > + AcpiTableAdress =3D (PLD_ACPI_TABLE *) GET_GUID_HOB_DATA > (GuidHob); >=20 > + if (AcpiTableAdress->PldHeader.Length < PLD_SIZEOF_THROUGH_FIELD > (PLD_ACPI_TABLE, Rsdp)) { >=20 > + // >=20 > + // Retrun if can't find the ACPI Info Hob with enough length >=20 > + // >=20 > + return EFI_NOT_FOUND; >=20 > + } >=20 > + Rsdp =3D (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) (UINTN) > (AcpiTableAdress->Rsdp); >=20 > + >=20 > + // >=20 > + // An ACPI-compatible OS must use the XSDT if present. >=20 > + // It shouldn't happen that XsdtAddress points beyond 4G range in 32= -bit > environment. >=20 > + // >=20 > + ASSERT ((UINTN) Rsdp->XsdtAddress =3D=3D Rsdp->XsdtAddress); >=20 > + >=20 > + EntrySize =3D sizeof (UINT64); >=20 > + Rsdt =3D (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress; >=20 > + if (Rsdt =3D=3D NULL) { >=20 > + // >=20 > + // XsdtAddress is zero, then we use Rsdt which has 32 bit entry >=20 > + // >=20 > + Rsdt =3D (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress= ; >=20 > + EntrySize =3D sizeof (UINT32); >=20 > + } >=20 > + >=20 > + if (Rsdt->Length <=3D sizeof (EFI_ACPI_DESCRIPTION_HEADER)) { >=20 > + return EFI_ABORTED; >=20 > + } >=20 > + >=20 > + Count =3D (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / > EntrySize; >=20 > + >=20 > + for (Index =3D 0; Index < Count; Index++){ >=20 > + ChildTableAddress =3D 0; >=20 > + CopyMem (&ChildTableAddress, (UINT8 *) (Rsdt + 1) + EntrySize * In= dex, > EntrySize); >=20 > + // >=20 > + // If the address is of UINT64 while this module runs at 32 bits, >=20 > + // make sure the upper bits are all-zeros. >=20 > + // >=20 > + ASSERT (ChildTableAddress =3D=3D (UINTN) ChildTableAddress); >=20 > + if (ChildTableAddress !=3D (UINTN) ChildTableAddress) { >=20 > + Status =3D EFI_ABORTED; >=20 > + break; >=20 > + } >=20 > + >=20 > + ChildTable =3D (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) > ChildTableAddress; >=20 > + Status =3D AddTableToList (AcpiTableInstance, ChildTable, TRUE, Ve= rsion, > TRUE, &TableKey); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACPI > table at 0x%p\n", ChildTable)); >=20 > + ASSERT_EFI_ERROR (Status); >=20 > + break; >=20 > + } >=20 > + if (ChildTable->Signature =3D=3D > EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE){ >=20 > + // >=20 > + // Add the FACS and DSDT tables if it is not NULL. >=20 > + // >=20 > + if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)- > >FirmwareCtrl !=3D 0) { >=20 > + TableToInstall =3D (VOID *) (UINTN) > ((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)- > >FirmwareCtrl; >=20 > + Status =3D AddTableToList (AcpiTableInstance, TableToInstall, = TRUE, > Version, TRUE, &TableKey); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add A= CPI > table FACS\n")); >=20 > + ASSERT_EFI_ERROR (Status); >=20 > + break; >=20 > + } >=20 > + } >=20 > + >=20 > + if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)- > >Dsdt !=3D 0) { >=20 > + TableToInstall =3D (VOID *) (UINTN) > ((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)->Dsdt; >=20 > + Status =3D AddTableToList (AcpiTableInstance, TableToInstall, = TRUE, > Version, TRUE, &TableKey); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add A= CPI > table DSDT\n")); >=20 > + ASSERT_EFI_ERROR (Status); >=20 > + break; >=20 > + } >=20 > + } >=20 > + } >=20 > + } >=20 > + } else { >=20 > + return EFI_NOT_FOUND; >=20 > + } >=20 > + >=20 > + if (EFI_ERROR (Status)) { >=20 > + // >=20 > + // Error happens when trying to add ACPI table to the list. >=20 > + // Remove all of them from list because at this time, no other table= s > except from HOB are in the list >=20 > + // >=20 > + while (SdtGetAcpiTable (AcpiTableInstance, 0, &Table, &Version, > &TableKey) =3D=3D EFI_SUCCESS) { >=20 > + RemoveTableFromList (AcpiTableInstance, Version, TableKey); >=20 > + } >=20 > + } else { >=20 > + Status =3D PublishTables (AcpiTableInstance, Version); >=20 > + } >=20 > + >=20 > + ASSERT_EFI_ERROR (Status); >=20 > + return Status; >=20 > +} >=20 >=20 >=20 > /** >=20 > Constructor for the ACPI table protocol. Initializes instance >=20 > @@ -1918,6 +2073,8 @@ AcpiTableAcpiTableConstructor ( >=20 >=20 > ChecksumCommonTables (AcpiTableInstance); >=20 >=20 >=20 > + InstallAcpiTableFromHob (AcpiTableInstance); >=20 > + >=20 > // >=20 > // Completed successfully >=20 > // >=20 > -- > 2.30.0.windows.2