+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2004 - 2007, Intel Corporation \r
-All rights reserved. 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
-Module Name:\r
-\r
- PeiServicePointer.c\r
-\r
-Abstract:\r
-\r
---*/\r
-\r
-#include "Tiano.h"\r
-#include "PeiApi.h"\r
-#include "PeiLib.h"\r
-\r
-#if (PI_SPECIFICATION_VERSION >= 0x00010000)\r
-\r
-#ifdef EFI_NT_EMULATOR\r
-EFI_PEI_SERVICES **gPeiServices;\r
-#endif\r
-\r
-\r
-VOID\r
-SetPeiServicesTablePointer (\r
- IN EFI_PEI_SERVICES **PeiServices\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Save PeiService pointer so that it can be retrieved anywhere.\r
-\r
-Arguments:\r
-\r
- PeiServices - The direct pointer to PeiServiceTable.\r
- PhyscialAddress - The physcial address of variable PeiServices.\r
- \r
-Returns:\r
- NONE\r
- \r
---*/ \r
-{\r
-\r
-#ifdef EFI_NT_EMULATOR\r
-\r
- //\r
- // For NT32, set EFI_PEI_SERVICES** to global variable.\r
- //\r
- gPeiServices = PeiServices;\r
-#else\r
-\r
- //\r
- // For X86 processor,the EFI_PEI_SERVICES** is stored in the \r
- // 4 bytes immediately preceding the Interrupt Descriptor Table.\r
- //\r
- UINTN IdtBaseAddress;\r
- IdtBaseAddress = (UINTN)ReadIdtBase();\r
- *(UINTN*)(IdtBaseAddress - 4) = (UINTN)PeiServices;\r
-\r
-#endif \r
-}\r
-\r
-\r
-EFI_PEI_SERVICES **\r
-GetPeiServicesTablePointer ( \r
- VOID\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Get PeiService pointer.\r
-\r
-Arguments:\r
-\r
- NONE.\r
- \r
-Returns:\r
- The direct pointer to PeiServiceTable.\r
- \r
---*/ \r
-{\r
- EFI_PEI_SERVICES **PeiServices;\r
-\r
-#ifdef EFI_NT_EMULATOR\r
-\r
- //\r
- // For NT32, set EFI_PEI_SERVICES** to global variable.\r
- //\r
- PeiServices = gPeiServices;\r
-#else\r
-\r
- //\r
- // For X86 processor,the EFI_PEI_SERVICES** is stored in the \r
- // 4 bytes immediately preceding the Interrupt Descriptor Table.\r
- //\r
- UINTN IdtBaseAddress;\r
- IdtBaseAddress = (UINTN)ReadIdtBase();\r
- PeiServices = (EFI_PEI_SERVICES **)(UINTN)(*(UINTN*)(IdtBaseAddress - 4));\r
-#endif\r
- return PeiServices;\r
-}\r
-\r
-\r
-VOID\r
-MigrateIdtTable (\r
- IN EFI_PEI_SERVICES **PeiServices\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Migrate IDT from CAR to real memory where preceded with 4 bytes for\r
- storing PeiService pointer.\r
-\r
-Arguments:\r
-\r
- PeiServices - The direct pointer to PeiServiceTable.\r
- \r
-Returns:\r
-\r
- NONE.\r
- \r
---*/ \r
-{\r
-#ifndef EFI_NT_EMULATOR\r
- UINT16 IdtEntrySize;\r
- UINTN OldIdtBase;\r
- UINTN Size;\r
- VOID *NewIdtBase;\r
- EFI_STATUS Status;\r
- \r
- IdtEntrySize = ReadIdtLimit();\r
- OldIdtBase = ReadIdtBase();\r
- Size = sizeof(PEI_IDT_TABLE) + (IdtEntrySize + 1); \r
- Status = (*PeiServices)->AllocatePool (PeiServices, Size, &NewIdtBase);\r
- ASSERT_PEI_ERROR (PeiServices, Status);\r
- (*PeiServices)->CopyMem ((VOID*)((UINTN)NewIdtBase + sizeof(PEI_IDT_TABLE)), (VOID*)OldIdtBase, (IdtEntrySize + 1));\r
- SetIdtBase(((UINTN)NewIdtBase + sizeof(PEI_IDT_TABLE)), IdtEntrySize);\r
- SetPeiServicesTablePointer(PeiServices);\r
-#endif\r
-}\r
-\r
-#endif\r