]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Store PeiServices** when updating IDT table in DxeIplPeim before transfer to long...
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 27 Oct 2011 05:26:02 +0000 (05:26 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 27 Oct 2011 05:26:02 +0000 (05:26 +0000)
Signed-off-by: vanjeff
Reviewed-by: rsun3
Reviewed-by: mdkinney
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12580 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c

index d25f0d5a6f7aa722eabdda335efd082555e56314..97086345ad9d2fc03e27fb5cbbbe73d6189a8eeb 100644 (file)
@@ -2,7 +2,7 @@
   Master header file for DxeIpl PEIM. All source files in this module should\r
   include this file for common definitions.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, 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
@@ -46,6 +46,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/S3Lib.h>\r
 #include <Library/RecoveryLib.h>\r
 #include <Library/DebugAgentLib.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
 \r
 #define STACK_SIZE      0x20000\r
 #define BSP_STORE_SIZE  0x4000\r
index 7717d0a8d5aa8acfc3dc187444f13acfb16630e7..f39251f3c90949e24b6e6f3fe6e24ab0909c11cc 100644 (file)
@@ -73,6 +73,7 @@
   PeimEntryPoint\r
   DebugLib\r
   DebugAgentLib\r
+  PeiServicesTablePointerLib\r
 \r
 [Ppis]\r
   gEfiDxeIplPpiGuid                 ## PRODUCES\r
index 6898bd9c92a1a55189eaafb163513d411e0a99b2..b121e2439bb67e3547af74d1d07dec723b288722 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Ia32-specific functionality for DxeLoad.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, 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
@@ -17,6 +17,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #define IDT_ENTRY_COUNT       32\r
 \r
+typedef struct _X64_IDT_TABLE {\r
+  //\r
+  // Reserved 4 bytes preceding PeiService and IdtTable,\r
+  // since IDT base address should be 8-byte alignment.\r
+  //\r
+  UINT32                   Reserved;\r
+  CONST EFI_PEI_SERVICES   **PeiService;\r
+  X64_IDT_GATE_DESCRIPTOR  IdtTable[IDT_ENTRY_COUNT];\r
+} X64_IDT_TABLE;\r
+\r
 //\r
 // Global Descriptor Table (GDT)\r
 //\r
@@ -72,6 +82,7 @@ HandOffToDxeCore (
   VOID                      *TemplateBase;\r
   EFI_PHYSICAL_ADDRESS      VectorAddress;\r
   UINT32                    Index;\r
+  X64_IDT_TABLE             *IdtTableForX64;\r
 \r
   Status = PeiServicesAllocatePages (EfiBootServicesData, EFI_SIZE_TO_PAGES (STACK_SIZE), &BaseOfStack);\r
   ASSERT_EFI_ERROR (Status);\r
@@ -120,12 +131,19 @@ HandOffToDxeCore (
 \r
     Status = PeiServicesAllocatePages (\r
                EfiBootServicesData,\r
-               EFI_SIZE_TO_PAGES((SizeOfTemplate + sizeof (X64_IDT_GATE_DESCRIPTOR)) * IDT_ENTRY_COUNT),\r
-               &VectorAddress\r
+               EFI_SIZE_TO_PAGES(sizeof (X64_IDT_TABLE) + SizeOfTemplate * IDT_ENTRY_COUNT),\r
+               (EFI_PHYSICAL_ADDRESS *) &IdtTableForX64\r
                );\r
     ASSERT_EFI_ERROR (Status);\r
 \r
-    IdtTable      = (X64_IDT_GATE_DESCRIPTOR *) (UINTN) (VectorAddress + SizeOfTemplate * IDT_ENTRY_COUNT);\r
+    //\r
+    // Store EFI_PEI_SERVICES** in the 4 bytes immediately preceding IDT to avoid that\r
+    // it may not be gotten correctly after IDT register is re-written.\r
+    //\r
+    IdtTableForX64->PeiService = GetPeiServicesTablePointer ();\r
+\r
+    VectorAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) (IdtTableForX64 + 1);\r
+    IdtTable      = IdtTableForX64->IdtTable;\r
     for (Index = 0; Index < IDT_ENTRY_COUNT; Index++) {\r
       IdtTable[Index].Ia32IdtEntry.Bits.GateType    =  0x8e;\r
       IdtTable[Index].Ia32IdtEntry.Bits.Reserved_0  =  0;\r