]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add support for PI1.2.1 TempRam Done PPI.
authorLiming Gao <liming.gao@intel.com>
Fri, 15 Nov 2013 02:04:57 +0000 (02:04 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 15 Nov 2013 02:04:57 +0000 (02:04 +0000)
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14846 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Ppi/TemporaryRamDone.h [new file with mode: 0644]
MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
MdePkg/MdePkg.dec

diff --git a/MdePkg/Include/Ppi/TemporaryRamDone.h b/MdePkg/Include/Ppi/TemporaryRamDone.h
new file mode 100644 (file)
index 0000000..ea7c2a1
--- /dev/null
@@ -0,0 +1,52 @@
+/** @file\r
+  This file declares Temporary RAM Done PPI.\r
+  The PPI that provides a service to disable the use of Temporary RAM.\r
+\r
+  Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  @par Revision Reference:\r
+  This PPI is introduced in PI Version 1.2.\r
+\r
+**/\r
+\r
+#ifndef __TEMPORARY_RAM_DONE_H__\r
+#define __TEMPORARY_RAM_DONE_H__\r
+\r
+#define EFI_PEI_TEMPORARY_RAM_DONE_PPI_GUID \\r
+  { 0xceab683c, 0xec56, 0x4a2d, { 0xa9, 0x6, 0x40, 0x53, 0xfa, 0x4e, 0x9c, 0x16 } }\r
+\r
+/**\r
+  TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked\r
+  by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed.\r
+\r
+  @retval EFI_SUCCESS           Use of Temporary RAM was disabled.\r
+  @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PEI_TEMPORARY_RAM_DONE) (\r
+  VOID\r
+  );\r
+\r
+///\r
+/// This is an optional PPI that may be produced by SEC or a PEIM. If present, it provide a service to\r
+/// disable the use of Temporary RAM. This service may only be called by the PEI Foundation after the\r
+/// transition from Temporary RAM to Permanent RAM is complete. This PPI provides an alternative\r
+/// to the Temporary RAM Migration PPI for system architectures that allow Temporary RAM and\r
+/// Permanent RAM to be enabled and accessed at the same time with no side effects.\r
+///\r
+typedef struct _EFI_PEI_TEMPORARY_RAM_DONE_PPI {\r
+  EFI_PEI_TEMPORARY_RAM_DONE TemporaryRamDone;\r
+} EFI_PEI_TEMPORARY_RAM_DONE_PPI;\r
+\r
+extern EFI_GUID gEfiTemporaryRamDonePpiGuid;\r
+\r
+#endif\r
index c5fb8f552efe5e8e2d1a255346aee90257c31419..4e3f013ed9cb43b4c2c327b8f5c10037c360d367 100644 (file)
@@ -4,7 +4,7 @@
   According to PI specification, the peiservice pointer is stored prior at IDT\r
   table in IA32 and x64 architecture.\r
   \r
-  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials                          \r
   are licensed and made available under the terms and conditions of the BSD License         \r
   which accompanies this distribution.  The full text of the license may be found at        \r
@@ -20,6 +20,8 @@
 #include <Library/BaseLib.h>\r
 #include <Library/PeiServicesTablePointerLib.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Ppi/TemporaryRamSupport.h>\r
 \r
 /**\r
   Retrieves the cached value of the PEI Services Table pointer.\r
@@ -67,11 +69,43 @@ SetPeiServicesTablePointer (
   IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
   )\r
 {\r
-  IA32_DESCRIPTOR   Idtr;\r
+  IA32_DESCRIPTOR        Idtr;\r
+  EFI_PHYSICAL_ADDRESS   IdtBase;\r
+  EFI_STATUS             Status;\r
+  EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI   *TemporaryRamSupportPpi;\r
   \r
   ASSERT (PeiServicesTablePointer != NULL);\r
   AsmReadIdtr (&Idtr);\r
-  (*(UINTN*)(Idtr.Base - sizeof (UINTN))) = (UINTN)PeiServicesTablePointer;\r
+  if ((*(UINTN*)(Idtr.Base - sizeof (UINTN))) != (UINTN)PeiServicesTablePointer) {\r
+    (*(UINTN*)(Idtr.Base - sizeof (UINTN))) = (UINTN)PeiServicesTablePointer;\r
+    Status = (*PeiServicesTablePointer)->LocatePpi (\r
+                                          PeiServicesTablePointer, \r
+                                          &gEfiTemporaryRamSupportPpiGuid, \r
+                                          0, \r
+                                          NULL, \r
+                                          (VOID**)&TemporaryRamSupportPpi\r
+                                         );\r
+                                      \r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // If TemporaryRamSupportPpi is not found, Idt table needs to be migrated into memory.\r
+      //\r
+      Status = (*PeiServicesTablePointer)->AllocatePages (\r
+                                            PeiServicesTablePointer, \r
+                                            EfiBootServicesCode,\r
+                                            EFI_SIZE_TO_PAGES(Idtr.Limit + 1 + sizeof (UINTN)),\r
+                                            &IdtBase\r
+                                            );\r
+      if (!EFI_ERROR (Status)) {\r
+        //\r
+        // Migrate Idt table\r
+        //\r
+        CopyMem ((VOID *) (UINTN) IdtBase, (VOID *) (Idtr.Base - sizeof (UINTN)), Idtr.Limit + 1 + sizeof (UINTN));\r
+        Idtr.Base = (UINTN) IdtBase + sizeof (UINTN);\r
+        AsmWriteIdtr (&Idtr);\r
+      }\r
+    }\r
+  }\r
 }\r
 \r
 \r
index 1a54bd466750adfc9327298079438066e43cd256..020a7f7e83365a8ccbb1f972ef6c3df191713c90 100644 (file)
@@ -4,7 +4,7 @@
 # PEI Services Table Pointer Library implementation that retrieves a pointer to the PEI\r
 # Services Table from the IDT on IA-32 and x64.\r
 #\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -39,6 +39,7 @@
 [LibraryClasses]\r
   DebugLib\r
   BaseLib\r
+  BaseMemoryLib\r
 \r
-\r
-\r
+[Ppis]\r
+  gEfiTemporaryRamSupportPpiGuid                ## SOMETIMES_CONSUMES\r
index 7c85b2804e17cd2f780778acfcdf4000ac87e0d6..6d3303c7d1ad4ef528b5bf737c69ff6f5c1f2766 100644 (file)
   ## Include/Ppi/PiPcd.h\r
   gEfiPeiPcdPpiGuid                  = { 0x1f34d25, 0x4de2, 0x23ad, { 0x3f, 0xf3, 0x36, 0x35, 0x3f, 0xf3, 0x23, 0xf1 } }\r
 \r
+  ## Include/Ppi/TemporaryRamDone.h\r
+  gEfiTemporaryRamDonePpiGuid        = { 0xceab683c, 0xec56, 0x4a2d, { 0xa9, 0x6, 0x40, 0x53, 0xfa, 0x4e, 0x9c, 0x16 } }\r
+\r
   #\r
   # PPIs defined in PI 1.3.\r
   #\r