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
#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
/** @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
\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
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
\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