From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.46]) by mx.groups.io with SMTP id smtpd.web10.58896.1598895182107296680 for ; Mon, 31 Aug 2020 10:33:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@vmware.com header.s=selector2 header.b=BKedySQ1; spf=pass (domain: vmware.com, ip: 40.107.92.46, mailfrom: awarkentin@vmware.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fw/OTf/AoifP9SWkLG72GVlKBP4h1PMSe7Wkvqd7Tlq/p1bIDgO73oeNtLY2+AkcPB2RL6DHAvISKrSRer/HUJLLvmEM0iaw7hoYJ6DSGQfCD3y+onfqjQ5MHmR9fJU4bZMZg61nXME18rUU3nTfAmbJk8M05a2m+2zYfh7jWCML4y2i9vB5DZ1t9OJ5GjbawAEx+Yc1BOjw+6fTa+AfUfTA+M4lHuwGRMcj3RJi2Abtb7GeU/7AC2UoKbeOrTAb8T7CgG9Vgl8tCIW3thqcWZdBM+t5obQpjeq1uA6UH97PWPn2pId0qgNyggw+5by2r5I7YISNj/VrS0YVQESBXg== 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=cyFYohzPmoX52kAIz3XVrGFdoHtBu4xNlHH29MutiGs=; b=HKul9Twp6lWs1p9p9KA0AV0aggJyC6Pxy8ZNx/YIKj7vV3CpXpOXJiPaFU9eo/9I8/a0zbCOCq/7Y+aKYoCWpcVN4MM8UL4FWjXv9wY0rhcRUieFFllinsU2alGQuqQ2ziCDMpsXp5HSvDMKP0rH2A8aWLzm2sn1NgJi13vf6gk4mtOj/QEJEgoo6VknCFST2ZncgSBh8WkALUO4BTegunRbw8TJ++4Ue2O+TC4JTEJdKGeRUydc97vKHqV102Dmm5FqBoPzW2k5N4oiuF0jslc8SGaVYr8d5eqJZ4sxMWz5utc+XwS1bf7OSQFxRx9L82m+LLDNOpxCwxDTH9FZpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cyFYohzPmoX52kAIz3XVrGFdoHtBu4xNlHH29MutiGs=; b=BKedySQ1EUEyROuc6UQDTmGTaXxyAIPr+uXGIEZRBxT6+pxlgeyo5LvWm9IR+2Gl6K8xBCyDhjqm+6hOX6T9Tg272bqmpv3l+5l2ToCahb4lAnRUM03+dcAgs3eXpYTCfxUC6k2uDNj/7M1M6+cGUHLr8pCD8hN4W5BDBoRFt+Y= Received: from CY4PR05MB3413.namprd05.prod.outlook.com (2603:10b6:910:59::21) by CY4PR05MB3527.namprd05.prod.outlook.com (2603:10b6:910:55::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.10; Mon, 31 Aug 2020 17:32:59 +0000 Received: from CY4PR05MB3413.namprd05.prod.outlook.com ([fe80::9da9:ad5f:1db4:446e]) by CY4PR05MB3413.namprd05.prod.outlook.com ([fe80::9da9:ad5f:1db4:446e%4]) with mapi id 15.20.3326.016; Mon, 31 Aug 2020 17:32:59 +0000 From: "Andrei Warkentin" To: Jeremy Linton , "devel@edk2.groups.io" CC: Leif Lindholm , Pete Batard , Ard Biesheuvel , Samer El-Haj-Mahmoud Subject: Re: [PATCH v4 2/6] Platform/RaspberryPi: Monitor ACPI Table installs Thread-Topic: [PATCH v4 2/6] Platform/RaspberryPi: Monitor ACPI Table installs Thread-Index: AQHWf7vPDZ3Dg7PaoU+ao1LA9QUBp6lSebK8 Date: Mon, 31 Aug 2020 17:32:59 +0000 Message-ID: References: <20200831172549.24079-1-jeremy.linton@arm.com>,<20200831172549.24079-3-jeremy.linton@arm.com> In-Reply-To: <20200831172549.24079-3-jeremy.linton@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=vmware.com; x-originating-ip: [98.214.99.181] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5c470d5f-9077-4bcb-6f26-08d84dd3e7ab x-ms-traffictypediagnostic: CY4PR05MB3527: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: L2zpj6P9eHVaW74xIbsRUAXgpOqeBuq6GGcXFKNmF3gOstLox1WRFaWAggKdTkLDhR96P9QByc4IHbyKTLjkg7/CnhopGpcNUf2dLhoAhcnvQsathbcDkox+fjVLFvTQO0Pi7fNtcBcurAEuzcdYD72Oq+F2pSgGVOSjjclcxH9xDsnDoO0DFzN8vK887VeRB+mQ6wJbjQo48+/5bUzcIYtsehZZ1SFZi6Nph97VWG4XSgpZJ0Ql2rw8L5m4FHqlwDSNCbWTwoeqk+SVzlZ6fwUwfrVzIsIUIlysUF1vDfeoPQ8n2I7yLaooY9Edolcc1Mmxg+nLuwrqA3/A8WA71m6PULN87XExFQizsrdW5f4AzaQhG1wUXhPPVXAYkESf x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR05MB3413.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(366004)(346002)(376002)(136003)(39860400002)(54906003)(478600001)(86362001)(9686003)(8936002)(66446008)(64756008)(66556008)(66476007)(55016002)(5660300002)(8676002)(4326008)(33656002)(19627405001)(186003)(6506007)(26005)(110136005)(53546011)(316002)(71200400001)(76116006)(2906002)(52536014)(7696005)(91956017)(66946007)(83380400001)(309714004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: ltQx2t0Lv59ybSz7rq4fqBMWpGvNnmwMqZvA22IB4fy4Gmusy/l1PjWbcSXZsB/Vmxij45IVoupGs9I2Qe/ZkQWr3sOWWhvym+uIkj6y3nL+mZEAXR5eO33dfa++pDI4ObGdwWHftQwDrKskrcEn1UwQ40+4tDcbjB/0FH/RrFz782NbZTrIOWher5ZExVbMd+I62sYkapXzrCJl3Ikmb/RD53aUJndGQ1Cv8YWAb8G4RBXAbq4oc7sxNj/7YonDdWZzlOiqElj6b155nIin63bY6aN0rhvjrwR51BZ0/AlVffGjs9hNMHoz1yUsiPkW8Q5ogKLF09BCRILA88niRGrCEtHlltYlONhcjSCrXiqfKhdR4jPKnpq0eyN/aTAyOAwyPylH5/tUaul2+IhIx7XwjRxn7fuJsG1xZshr2f7V95Q2ZFf9I5ASM1dJuDgR2gnT04oAH9C5ogqxsW86gRTYMnJJM0EBUJ4G5GFWTH0fvXD9XcnJV8ZpJkkiOPSEGXVmbBB8ePMkH7p5P+1l1prXdt+wna8TTNHN8u+sB44wYc6T03QuVbK46+KCfWgIkUK/5R6Y5lec7TDM58vdKunqWw9qBSk56Y6zigW9CoLGATMpdv5s4l9kinYvRM34fL01EvkMpnv/jBnabrtpNQ== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR05MB3413.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c470d5f-9077-4bcb-6f26-08d84dd3e7ab X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Aug 2020 17:32:59.2475 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ip8ESWE3l3S2gN5cRqQUZEORexSlsa5Gf05dI9hl5986tbktTaUcnMgO1fj8+Lj1CzojXAP6cjb6JGoahSUbBg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR05MB3527 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CY4PR05MB3413B3B6A4A9DCEB302EFB7CB9510CY4PR05MB3413namp_" --_000_CY4PR05MB3413B3B6A4A9DCEB302EFB7CB9510CY4PR05MB3413namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This is really cool. Can be useful in a number of other places down the lin= e (e.g. MAC address via device properties). Reviewed-by: Andrei Warkentin ________________________________ From: Jeremy Linton Sent: Monday, August 31, 2020 12:25 PM To: devel@edk2.groups.io Cc: Jeremy Linton ; Leif Lindholm ; Pete Batard ; Andrei Warkentin ; Ar= d Biesheuvel ; Samer El-Haj-Mahmoud Subject: [PATCH v4 2/6] Platform/RaspberryPi: Monitor ACPI Table installs Hook the ACPI table install sequence and add some basic conditional and AML NameOp update logic. If a table has a non-zero PCD declared that pcd is checked for a non-zero value before allowing the table to be installed. We also add a table of NameOp to PCD's which will be written into a DSDT/SSDT table as part of its install process. With this change we can declare something in ASL like: Name (VARN, 0x1234) and then add a table entry like: {"VARN", PcdToken(PcdVarn)} and the value of PcdVarn will replace the 0x1234 declared in the ASL above. Cc: Leif Lindholm Cc: Pete Batard Cc: Andrei Warkentin Cc: Ard Biesheuvel Cc: Samer El-Haj-Mahmoud Signed-off-by: Jeremy Linton Reviewed-by: Pete Batard <@pbatard> --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 153 +++++++++++++++++= +++- 1 file changed, 152 insertions(+), 1 deletion(-) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index af54136ade..9e5d9734ca 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -568,6 +568,156 @@ ApplyVariables ( } +typedef struct { + CHAR8 Name[4]; + UINTN PcdToken; +} AML_NAME_OP_REPLACE; + +typedef struct { + UINT64 OemTableId; + UINTN PcdToken; + AML_NAME_OP_REPLACE *SdtNameOpReplace; +} NAMESPACE_TABLES; + +#define SSDT_PATTERN_LEN 5 +#define AML_NAMEOP_8 0x0A +#define AML_NAMEOP_16 0x0B +#define AML_NAMEOP_32 0x0C +#define AML_NAMEOP_STR 0x0D +/* + * Scan the given namespace table (DSDT/SSDT) for AML NameOps + * listed in the NameOpReplace structure. If one is found then + * update the value in the table from the specified Pcd + * + * This allows us to have conditionals in AML controlled + * by options in the BDS or detected during firmware bootstrap. + * We could extend this concept for strings/etc but due to len + * variations its probably easier to encode the strings + * in the ASL and pick the correct one based off a variable. + */ +STATIC VOID +UpdateSdtNameOps( + EFI_ACPI_DESCRIPTION_HEADER *AcpiTable, + AML_NAME_OP_REPLACE *NameOpReplace + ) +{ + UINTN Idx; + UINTN Index; + CHAR8 Pattern[SSDT_PATTERN_LEN]; + UINTN PcdVal; + UINT8 *SdtPtr; + UINT32 SdtSize; + + SdtSize =3D AcpiTable->Length; + + if (SdtSize > 0) { + SdtPtr =3D (UINT8*)AcpiTable; + + for (Idx =3D 0; NameOpReplace && NameOpReplace[Idx].PcdToken; Idx++) { + /* + * Do a single NameOp variable replacement these are of the + * form 08 XXXX SIZE VAL, where SIZE is 0A=3Dbyte, 0B=3Dword, 0C=3Dd= word + * and XXXX is the name and VAL is the value + */ + Pattern[0] =3D 0x08; + Pattern[1] =3D NameOpReplace[Idx].Name[0]; + Pattern[2] =3D NameOpReplace[Idx].Name[1]; + Pattern[3] =3D NameOpReplace[Idx].Name[2]; + Pattern[4] =3D NameOpReplace[Idx].Name[3]; + + for (Index =3D 0; Index < (SdtSize - SSDT_PATTERN_LEN); Index++) { + if (CompareMem (SdtPtr + Index, Pattern, SSDT_PATTERN_LEN) =3D=3D = 0) { + PcdVal =3D LibPcdGet32 (NameOpReplace[Idx].PcdToken); + switch (SdtPtr[Index + SSDT_PATTERN_LEN]) { + case AML_NAMEOP_32: + SdtPtr[Index + SSDT_PATTERN_LEN + 4] =3D (PcdVal >> 24) & 0xFF= ; + SdtPtr[Index + SSDT_PATTERN_LEN + 3] =3D (PcdVal >> 16) & 0xFF= ; + // Fallthrough + case AML_NAMEOP_16: + SdtPtr[Index + SSDT_PATTERN_LEN + 2] =3D (PcdVal >> 8) & 0xFF; + // Fallthrough + case AML_NAMEOP_8: + SdtPtr[Index + SSDT_PATTERN_LEN + 1] =3D PcdVal & 0xFF; + break; + case 0: + case 1: + SdtPtr[Index + SSDT_PATTERN_LEN + 1] =3D !!PcdVal; + break; + case AML_NAMEOP_STR: + /* + * If the string val is added to the NameOpReplace, we can + * dynamically update things like _HID too as long as the + * string length matches. + */ + break; + } + break; + } + } + } + } +} + + +STATIC BOOLEAN +VerifyUpdateTable( + IN EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader, + IN NAMESPACE_TABLES *SdtTable + ) +{ + BOOLEAN ret; + + ret =3D TRUE; + if (SdtTable->PcdToken && !LibPcdGet32 (SdtTable->PcdToken)) { + ret =3D FALSE; + } + if (ret && SdtTable->SdtNameOpReplace) { + UpdateSdtNameOps (AcpiHeader, SdtTable->SdtNameOpReplace); + } + + return ret; +} + + +STATIC NAMESPACE_TABLES SdtTables[] =3D { + { + SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0), + 0, + NULL + }, + { } +}; + +/* + * Monitor the ACPI tables being installed and when + * a DSDT/SSDT is detected validate that we want to + * install it, and if so update any "NameOp" defined + * variables contained in the table from PCD values + */ +STATIC BOOLEAN +HandleDynamicNamespace ( + IN EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader + ) +{ + UINTN Tables; + + switch (AcpiHeader->Signature) { + case SIGNATURE_32 ('D', 'S', 'D', 'T'): + case SIGNATURE_32 ('S', 'S', 'D', 'T'): + for (Tables =3D 0; SdtTables[Tables].OemTableId; Tables++) { + if (AcpiHeader->OemTableId =3D=3D SdtTables[Tables].OemTableId) { + return VerifyUpdateTable (AcpiHeader, &SdtTables[Tables]); + } + } + DEBUG ((DEBUG_ERROR, "Found namespace table not in table list.\n")); + + return FALSE; + } + + return TRUE; +} + + EFI_STATUS EFIAPI ConfigInitialize ( @@ -618,7 +768,8 @@ ConfigInitialize ( if (PcdGet32 (PcdSystemTableMode) =3D=3D SYSTEM_TABLE_MODE_ACPI || PcdGet32 (PcdSystemTableMode) =3D=3D SYSTEM_TABLE_MODE_BOTH) { - Status =3D LocateAndInstallAcpiFromFv (&mAcpiTableFile); + Status =3D LocateAndInstallAcpiFromFvConditional (&mAcpiTableFile, + &HandleDynamicNamespa= ce); ASSERT_EFI_ERROR (Status); } -- 2.13.7 --_000_CY4PR05MB3413B3B6A4A9DCEB302EFB7CB9510CY4PR05MB3413namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
This is really cool. Can be useful in a number of other places down the lin= e (e.g. MAC address via device properties).

Reviewed-by: Andrei Warkentin <andrey.warkentin@gmail.com>

From: Jeremy Linton <jer= emy.linton@arm.com>
Sent: Monday, August 31, 2020 12:25 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Jeremy Linton <jeremy.linton@arm.com>; Leif Lindholm <l= eif@nuviainc.com>; Pete Batard <pete@akeo.ie>; Andrei Warkentin &l= t;awarkentin@vmware.com>; Ard Biesheuvel <ard.biesheuvel@arm.com>;= Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Subject: [PATCH v4 2/6] Platform/RaspberryPi: Monitor ACPI Table ins= talls
 
Hook the ACPI table install sequence and add some<= br> basic conditional and AML NameOp update logic. If
a table has a non-zero PCD declared that pcd is
checked for a non-zero value before allowing the table
to be installed. We also add a table of NameOp to
PCD's which will be written into a DSDT/SSDT table
as part of its install process.

With this change we can declare something in
ASL like:

Name (VARN, 0x1234)

and then add a table entry like:

{"VARN", PcdToken(PcdVarn)}

and the value of PcdVarn will replace the
0x1234 declared in the ASL above.

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Pete Batard <pete@akeo.ie>
Cc: Andrei Warkentin <awarkentin@vmware.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Pete Batard <@pbatard>
---
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 153 ++++++++++++= ++++++++-
 1 file changed, 152 insertions(+), 1 deletion(-)

diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
index af54136ade..9e5d9734ca 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
@@ -568,6 +568,156 @@ ApplyVariables (
 }

 

 

+typedef struct {

+  CHAR8 Name[4];

+  UINTN PcdToken;

+} AML_NAME_OP_REPLACE;

+

+typedef struct {

+  UINT64          &= nbsp;   OemTableId;

+  UINTN          &n= bsp;    PcdToken;

+  AML_NAME_OP_REPLACE *SdtNameOpReplace;

+} NAMESPACE_TABLES;

+

+#define SSDT_PATTERN_LEN 5

+#define AML_NAMEOP_8   0x0A

+#define AML_NAMEOP_16  0x0B

+#define AML_NAMEOP_32  0x0C

+#define AML_NAMEOP_STR 0x0D

+/*

+ * Scan the given namespace table (DSDT/SSDT) for AML NameOps

+ * listed in the NameOpReplace structure. If one is found then

+ * update the value in the table from the specified Pcd

+ *

+ * This allows us to have conditionals in AML controlled

+ * by options in the BDS or detected during firmware bootstrap.

+ * We could extend this concept for strings/etc but due to len

+ * variations its probably easier to encode the strings

+ * in the ASL and pick the correct one based off a variable.

+ */

+STATIC VOID

+UpdateSdtNameOps(

+  EFI_ACPI_DESCRIPTION_HEADER  *AcpiTable,

+  AML_NAME_OP_REPLACE        =   *NameOpReplace

+  )

+{

+  UINTN  Idx;

+  UINTN  Index;

+  CHAR8  Pattern[SSDT_PATTERN_LEN];

+  UINTN  PcdVal;

+  UINT8  *SdtPtr;

+  UINT32 SdtSize;

+

+  SdtSize =3D AcpiTable->Length;

+

+  if (SdtSize > 0) {

+    SdtPtr =3D (UINT8*)AcpiTable;

+

+    for (Idx =3D 0; NameOpReplace && NameOpReplace[= Idx].PcdToken; Idx++) {

+      /*

+       * Do a single NameOp variable replace= ment these are of the

+       * form 08 XXXX SIZE VAL, where SIZE i= s 0A=3Dbyte, 0B=3Dword, 0C=3Ddword

+       * and XXXX is the name and VAL is the= value

+      */

+      Pattern[0] =3D 0x08;

+      Pattern[1] =3D NameOpReplace[Idx].Name[0];<= br>
+      Pattern[2] =3D NameOpReplace[Idx].Name[1];<= br>
+      Pattern[3] =3D NameOpReplace[Idx].Name[2];<= br>
+      Pattern[4] =3D NameOpReplace[Idx].Name[3];<= br>
+

+      for (Index =3D 0; Index < (SdtSize - SSD= T_PATTERN_LEN); Index++) {

+        if (CompareMem (SdtPtr + Index,= Pattern, SSDT_PATTERN_LEN) =3D=3D 0) {

+          PcdVal =3D LibPcdGe= t32 (NameOpReplace[Idx].PcdToken);

+          switch (SdtPtr[Inde= x + SSDT_PATTERN_LEN]) {

+          case AML_NAMEOP_32:=

+            SdtPtr[= Index + SSDT_PATTERN_LEN + 4] =3D (PcdVal >> 24) & 0xFF;

+            SdtPtr[= Index + SSDT_PATTERN_LEN + 3] =3D (PcdVal >> 16) & 0xFF;

+            // Fall= through

+          case AML_NAMEOP_16:=

+            SdtPtr[= Index + SSDT_PATTERN_LEN + 2] =3D (PcdVal >> 8) & 0xFF;

+            // Fall= through

+          case AML_NAMEOP_8:<= br>
+            SdtPtr[= Index + SSDT_PATTERN_LEN + 1] =3D PcdVal & 0xFF;

+            break;<= br>
+          case 0:

+          case 1:

+            SdtPtr[= Index + SSDT_PATTERN_LEN + 1] =3D !!PcdVal;

+            break;<= br>
+          case AML_NAMEOP_STR= :

+            /*

+             *= If the string val is added to the NameOpReplace, we can

+             *= dynamically update things like _HID too as long as the

+             *= string length matches.

+             *= /

+            break;<= br>
+          }

+          break;

+        }

+      }

+    }

+  }

+}

+

+

+STATIC BOOLEAN

+VerifyUpdateTable(

+  IN  EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader,

+  IN  NAMESPACE_TABLES *SdtTable

+  )

+{

+  BOOLEAN ret;

+

+  ret =3D TRUE;

+  if (SdtTable->PcdToken && !LibPcdGet32 (SdtTable->Pcd= Token)) {

+    ret =3D FALSE;

+  }

+  if (ret && SdtTable->SdtNameOpReplace) {

+    UpdateSdtNameOps (AcpiHeader, SdtTable->SdtNameOpRep= lace);

+  }

+

+  return ret;

+}

+

+

+STATIC NAMESPACE_TABLES SdtTables[] =3D {

+  {

+    SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),

+    0,

+    NULL

+  },

+  { }

+};

+

+/*

+ * Monitor the ACPI tables being installed and when

+ * a DSDT/SSDT is detected validate that we want to

+ * install it, and if so update any "NameOp" defined

+ * variables contained in the table from PCD values

+ */

+STATIC BOOLEAN

+HandleDynamicNamespace (

+  IN  EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader

+  )

+{

+  UINTN Tables;

+

+  switch (AcpiHeader->Signature) {

+  case SIGNATURE_32 ('D', 'S', 'D', 'T'):

+  case SIGNATURE_32 ('S', 'S', 'D', 'T'):

+    for (Tables =3D 0; SdtTables[Tables].OemTableId; Tables= ++) {

+      if (AcpiHeader->OemTableId =3D=3D SdtTab= les[Tables].OemTableId) {

+        return VerifyUpdateTable (AcpiH= eader, &SdtTables[Tables]);

+      }

+    }

+    DEBUG ((DEBUG_ERROR, "Found namespace table not in= table list.\n"));

+

+    return FALSE;

+  }

+

+  return TRUE;

+}

+

+

 EFI_STATUS

 EFIAPI

 ConfigInitialize (

@@ -618,7 +768,8 @@ ConfigInitialize (
 

   if (PcdGet32 (PcdSystemTableMode) =3D=3D SYSTEM_TABLE_MODE_ACP= I ||

       PcdGet32 (PcdSystemTableMode) =3D=3D S= YSTEM_TABLE_MODE_BOTH) {

-     Status =3D LocateAndInstallAcpiFromFv (&mAcpi= TableFile);

+     Status =3D LocateAndInstallAcpiFromFvConditional = (&mAcpiTableFile,

+            &n= bsp;            = ;            &n= bsp;            = ;   &HandleDynamicNamespace);

      ASSERT_EFI_ERROR (Status);

   }

 

--
2.13.7

--_000_CY4PR05MB3413B3B6A4A9DCEB302EFB7CB9510CY4PR05MB3413namp_--