]> git.proxmox.com Git - mirror_edk2.git/commitdiff
PrmPkg: Publish PRM operation region to support PRM ACPI _DSM invocation
authorLiu <yun.y.liu@intel.com>
Thu, 7 May 2020 06:42:03 +0000 (14:42 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 5 Apr 2022 00:42:38 +0000 (00:42 +0000)
A PRM Handler has a 1-to-1 mapping to the corresponding _DSM method.
The UUID of the _DSM Method will be passed by the ASL code to the
OpRegionHandler which will look up the PRMT Table to extract the
pointer of the corresponding PRM Handler.

PRM loader pre-builds an SSDT that includes this PRM operation region.
In boot time, the PRM loader will load and publish this SSDT, so that
in OS runtime ACPI _DSM can invoke the PRM handler by pass the UUID to
PRM operation region.

The pre-build SSDT also includes a PRMT device as a Sample ACPI _DSM to
invoke PRM handler.

Cc: Andrew Fish <afish@apple.com>
Cc: Kang Gao <kang.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Liu Yun <yun.y.liu@intel.com>
Cc: Ankit Sinha <ankit.sinha@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Liu Yun <yun.y.liu@intel.com>
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
Acked-by: Liming Gao <gaoliming@byosoft.com.cn>
Acked-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Ankit Sinha <ankit.sinha@intel.com>
PrmPkg/PrmLoaderDxe/Prm.asl [new file with mode: 0644]
PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c
PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf

diff --git a/PrmPkg/PrmLoaderDxe/Prm.asl b/PrmPkg/PrmLoaderDxe/Prm.asl
new file mode 100644 (file)
index 0000000..76b56de
--- /dev/null
@@ -0,0 +1,87 @@
+/** @file\r
+  The definition block in ACPI table for PRM Operation Region\r
+\r
+  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+DefinitionBlock (\r
+    "Prm.aml",\r
+    "SSDT",\r
+    0x01,\r
+    "OEMID",\r
+    "PRMOPREG",\r
+    0x3000\r
+    )\r
+{\r
+    Scope (\_SB)\r
+    {\r
+        //\r
+        // PRM Bridge Device\r
+        //\r
+\r
+        Device (PRMB)\r
+        {\r
+            Name (_HID, "80860222")\r
+            Name (_CID, "80860222")\r
+            Name (_DDN, "PRM Bridge Device")\r
+            Name (_STA, 0xF)\r
+            OperationRegion (OPR1, 0x80, 0, 16)\r
+            Field (OPR1, DWordAcc, NoLock, Preserve) //Make it ByteAcc for parameter validation\r
+            {\r
+                Var0, 128\r
+            }\r
+            Method (SETV, 1, Serialized)\r
+            {\r
+                CopyObject (Arg0, \_SB.PRMB.Var0)\r
+            }\r
+        }\r
+\r
+        //\r
+        // PRM Test Device\r
+        //\r
+\r
+        Device (PRMT)\r
+        {\r
+            Name (_HID, "80860223")\r
+            Name (_CID, "80860223")\r
+            Name (_DDN, "PRM Test Device")\r
+            Name (_STA, 0xF)\r
+            Name (BUF1, Buffer(16)\r
+            {\r
+                0x5F, 0xAD, 0xF2, 0xD5, 0x47, 0xA3, 0x3E, 0x4D, //Guid_0\r
+                0x87, 0xBC, 0xC2, 0xCE, 0x63, 0x02, 0x9C, 0xC8, //Guid_1\r
+            })\r
+            Name (BUF2, Buffer(16)\r
+            {\r
+                0xC3, 0xAD, 0xE7, 0xA9, 0xD0, 0x8C, 0x9A, 0x42, //Guid_0\r
+                0x89, 0x15, 0x10, 0x94, 0x6E, 0xBD, 0xE3, 0x18, //Guid_1\r
+            })\r
+            Name (BUF3, Buffer(16)\r
+            {\r
+                0x14, 0xC2, 0x88, 0xB6, 0x81, 0x40, 0xEB, 0x4E, //Guid_0\r
+                0x8D, 0x26, 0x1E, 0xB5, 0xA3, 0xBC, 0xF1, 0x1A, //Guid_1\r
+            })\r
+            Method (NTST)\r
+            {\r
+                \_SB.PRMB.SETV (BUF1)\r
+            }\r
+            Method (TST1)\r
+            {\r
+                \_SB.PRMB.SETV (BUF1)\r
+            }\r
+            Method (TST2)\r
+            {\r
+                \_SB.PRMB.SETV (BUF2)\r
+            }\r
+            Method (TST3)\r
+            {\r
+                \_SB.PRMB.SETV (BUF3)\r
+            }\r
+        }\r
+    }\r
+\r
+} // End of Definition Block\r
+\r
+\r
+\r
index 5fda4c1b01daf38f784fe5f8391e80b3bd580f31..5e14b8e09dd01733122c0e8998844ee4170bdfdf 100644 (file)
@@ -3,6 +3,7 @@
   This file contains the implementation for a Platform Runtime Mechanism (PRM)\r
   loader driver.\r
 \r
+  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
   Copyright (c) Microsoft Corporation\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -19,6 +20,7 @@
 #include <Library/PrmContextBufferLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiLib.h>\r
+#include <Library/DxeServicesLib.h>\r
 #include <Protocol/AcpiTable.h>\r
 #include <Protocol/LoadedImage.h>\r
 #include <Protocol/PrmConfig.h>\r
@@ -809,6 +811,8 @@ PublishPrmAcpiTable (
   EFI_STATUS                              Status;\r
   EFI_ACPI_TABLE_PROTOCOL                 *AcpiTableProtocol;\r
   UINTN                                   TableKey;\r
+  EFI_ACPI_DESCRIPTION_HEADER             *Ssdt;\r
+  UINTN                                   SsdtSize;\r
 \r
   if (PrmAcpiDescriptionTable == NULL || PrmAcpiDescriptionTable->Header.Signature != PRM_TABLE_SIGNATURE) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -832,6 +836,36 @@ PublishPrmAcpiTable (
   }\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  //\r
+  // Load SSDT\r
+  //\r
+  Status = GetSectionFromFv (\r
+               &gEfiCallerIdGuid,\r
+               EFI_SECTION_RAW,\r
+               0,\r
+               (VOID **) &Ssdt,\r
+               &SsdtSize\r
+               );\r
+  ASSERT_EFI_ERROR (Status);\r
+  DEBUG ((DEBUG_INFO, "%a %a: SSDT loaded ...\n", _DBGMSGID_, __FUNCTION__));\r
+\r
+  //\r
+  // Update OEM ID\r
+  //\r
+  CopyMem (&Ssdt->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (Ssdt->OemId));\r
+\r
+  //\r
+  // Publish the SSDT. Table is re-checksumed.\r
+  //\r
+  TableKey = 0;\r
+  Status = AcpiTableProtocol->InstallAcpiTable (\r
+                        AcpiTableProtocol,\r
+                        Ssdt,\r
+                        SsdtSize,\r
+                        &TableKey\r
+                        );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   return Status;\r
 }\r
 \r
index 643e1a7989f263753149865fc3fce67926fec7d5..016ced4b37322f7c76c4d819baa630ca536f10f6 100644 (file)
@@ -5,6 +5,7 @@
 #  PRM handlers within those modules into a PRMT ACPI table such that the handlers are\r
 #  made available for invocation in the OS.\r
 #\r
+#  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
 #  Copyright (c) Microsoft Corporation\r
 #\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
@@ -23,6 +24,7 @@
   PrmAcpiTable.h\r
   PrmLoader.h\r
   PrmLoaderDxe.c\r
+  Prm.asl\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
@@ -42,6 +44,8 @@
   UefiBootServicesTableLib\r
   UefiDriverEntryPoint\r
   UefiLib\r
+  DxeServicesLib\r
+  PcdLib\r
 \r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId            ## CONSUMES\r