summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
diff options
context:
space:
mode:
authorGao, Liming <liming.gao@intel.com>2014-01-15 02:16:57 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2014-01-15 02:16:57 +0000
commitffdb421ca50c3bb4b31f89707da4c99ca8299a77 (patch)
treef59cbbd9efb598405fab4a349918ec756724ab82 /MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
parent2405af19936960172d3ad0ae895691bd273a3215 (diff)
downloadedk2-ffdb421ca50c3bb4b31f89707da4c99ca8299a77.tar.gz
edk2-ffdb421ca50c3bb4b31f89707da4c99ca8299a77.tar.bz2
edk2-ffdb421ca50c3bb4b31f89707da4c99ca8299a77.zip
1. Add new API MigratePeiServicesTablePointer() in PeiServicesTablePointerLib class.
2. PeiCore will call this API to migrate the PEI Services Table pointer from temporary RAM to permanent RAM. Signed-off-by: Gao, Liming <liming.gao@intel.com> Reviewed-by: Kinney, Michael D <michael.d.kinney@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15114 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c')
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c89
1 files changed, 54 insertions, 35 deletions
diff --git a/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c b/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
index 4e3f013ed9..1ce3c727e1 100644
--- a/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
+++ b/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
@@ -4,7 +4,7 @@
According to PI specification, the peiservice pointer is stored prior at IDT
table in IA32 and x64 architecture.
- Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -21,7 +21,6 @@
#include <Library/PeiServicesTablePointerLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
-#include <Ppi/TemporaryRamSupport.h>
/**
Retrieves the cached value of the PEI Services Table pointer.
@@ -70,42 +69,62 @@ SetPeiServicesTablePointer (
)
{
IA32_DESCRIPTOR Idtr;
- EFI_PHYSICAL_ADDRESS IdtBase;
- EFI_STATUS Status;
- EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI *TemporaryRamSupportPpi;
ASSERT (PeiServicesTablePointer != NULL);
AsmReadIdtr (&Idtr);
- if ((*(UINTN*)(Idtr.Base - sizeof (UINTN))) != (UINTN)PeiServicesTablePointer) {
- (*(UINTN*)(Idtr.Base - sizeof (UINTN))) = (UINTN)PeiServicesTablePointer;
- Status = (*PeiServicesTablePointer)->LocatePpi (
- PeiServicesTablePointer,
- &gEfiTemporaryRamSupportPpiGuid,
- 0,
- NULL,
- (VOID**)&TemporaryRamSupportPpi
- );
-
- if (EFI_ERROR (Status)) {
- //
- // If TemporaryRamSupportPpi is not found, Idt table needs to be migrated into memory.
- //
- Status = (*PeiServicesTablePointer)->AllocatePages (
- PeiServicesTablePointer,
- EfiBootServicesCode,
- EFI_SIZE_TO_PAGES(Idtr.Limit + 1 + sizeof (UINTN)),
- &IdtBase
- );
- if (!EFI_ERROR (Status)) {
- //
- // Migrate Idt table
- //
- CopyMem ((VOID *) (UINTN) IdtBase, (VOID *) (Idtr.Base - sizeof (UINTN)), Idtr.Limit + 1 + sizeof (UINTN));
- Idtr.Base = (UINTN) IdtBase + sizeof (UINTN);
- AsmWriteIdtr (&Idtr);
- }
- }
- }
+ (*(UINTN*)(Idtr.Base - sizeof (UINTN))) = (UINTN)PeiServicesTablePointer;
+}
+
+/**
+ Perform CPU specific actions required to migrate the PEI Services Table
+ pointer from temporary RAM to permanent RAM.
+
+ For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
+ immediately preceding the Interrupt Descriptor Table (IDT) in memory.
+ For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
+ immediately preceding the Interrupt Descriptor Table (IDT) in memory.
+ For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
+ a dedicated CPU register. This means that there is no memory storage
+ associated with storing the PEI Services Table pointer, so no additional
+ migration actions are required for Itanium or ARM CPUs.
+
+ If The cached PEI Services Table pointer is NULL, then ASSERT().
+ If the permanent memory is allocated failed, then ASSERT().
+**/
+VOID
+EFIAPI
+MigratePeiServicesTablePointer (
+ )
+{
+ EFI_STATUS Status;
+ IA32_DESCRIPTOR Idtr;
+ EFI_PHYSICAL_ADDRESS IdtBase;
+ CONST EFI_PEI_SERVICES **PeiServices;
+
+ //
+ // Get PEI Services Table pointer
+ //
+ AsmReadIdtr (&Idtr);
+ PeiServices = (CONST EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.Base - sizeof (UINTN)));
+ ASSERT (PeiServices != NULL);
+ //
+ // Allocate the permanent memory.
+ //
+ Status = (*PeiServices)->AllocatePages (
+ PeiServices,
+ EfiBootServicesCode,
+ EFI_SIZE_TO_PAGES(Idtr.Limit + 1 + sizeof (UINTN)),
+ &IdtBase
+ );
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Idt table needs to be migrated into memory.
+ //
+ CopyMem ((VOID *) (UINTN) IdtBase, (VOID *) (Idtr.Base - sizeof (UINTN)), Idtr.Limit + 1 + sizeof (UINTN));
+ Idtr.Base = (UINTN) IdtBase + sizeof (UINTN);
+ AsmWriteIdtr (&Idtr);
+
+ return;
}