summaryrefslogtreecommitdiffstats
path: root/MdePkg
diff options
context:
space:
mode:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2007-10-09 08:16:53 +0000
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2007-10-09 08:16:53 +0000
commit81c7803cf4a49ca2633c706b7630c1cf2d9e9b55 (patch)
treec4f4dd9d4cf3a1e943acbbf85f80cd43a299bc41 /MdePkg
parentd173d9c7616a5e7c3c7758e5692335dacfedebe1 (diff)
downloadedk2-81c7803cf4a49ca2633c706b7630c1cf2d9e9b55.tar.gz
edk2-81c7803cf4a49ca2633c706b7630c1cf2d9e9b55.tar.bz2
edk2-81c7803cf4a49ca2633c706b7630c1cf2d9e9b55.zip
PI Enabling: the address of PeiServices Pointer should be
1) Set to preceding of IDT table in PeiCore's entry 2) Migrate to preceding of new memory IDT table when memory is discovery git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4059 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Include/Library/PeiServicesTablePointerLib.h18
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c21
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibIdt/InternalPeiServicesTablePointer.h12
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c61
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf14
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointer.c14
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c33
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf3
8 files changed, 158 insertions, 18 deletions
diff --git a/MdePkg/Include/Library/PeiServicesTablePointerLib.h b/MdePkg/Include/Library/PeiServicesTablePointerLib.h
index 7a602f9041..f6ced47265 100644
--- a/MdePkg/Include/Library/PeiServicesTablePointerLib.h
+++ b/MdePkg/Include/Library/PeiServicesTablePointerLib.h
@@ -30,11 +30,29 @@ GetPeiServicesTablePointer (
VOID
);
+/**
+ The function set the pointer of PEI services immediately preceding the IDT table
+ according to PI specification.
+
+ @param PeiServices The address of PeiServices pointer.
+**/
VOID
EFIAPI
SetPeiServicesTablePointer (
EFI_PEI_SERVICES ** PeiServicesTablePointer
);
+/**
+ After memory initialization in PEI phase, the IDT table in temporary memory should
+ be migrated to memory, and the address of PeiServicesPointer also need to be updated
+ immediately preceding the new IDT table.
+
+ @param PeiServices The address of PeiServices pointer.
+**/
+VOID
+MigrateIdtTable (
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+
#endif
diff --git a/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
index 54a500a732..871e52a25a 100644
--- a/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
+++ b/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
@@ -20,6 +20,12 @@
static EFI_PEI_SERVICES **gPeiServices;
+/**
+ The function set the pointer of PEI services immediately preceding the IDT table
+ according to PI specification.
+
+ @param PeiServices The address of PeiServices pointer.
+**/
VOID
EFIAPI
SetPeiServicesTablePointer (
@@ -70,3 +76,18 @@ PeiServicesTablePointerLibConstructor (
gPeiServices = PeiServices;
return EFI_SUCCESS;
}
+
+/**
+ After memory initialization in PEI phase, the IDT table in temporary memory should
+ be migrated to memory, and the address of PeiServicesPointer also need to be updated
+ immediately preceding the new IDT table.
+
+ @param PeiServices The address of PeiServices pointer.
+**/
+VOID
+MigrateIdtTable (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+}
+
diff --git a/MdePkg/Library/PeiServicesTablePointerLibIdt/InternalPeiServicesTablePointer.h b/MdePkg/Library/PeiServicesTablePointerLibIdt/InternalPeiServicesTablePointer.h
index e1c74901ac..61bc1ebf41 100644
--- a/MdePkg/Library/PeiServicesTablePointerLibIdt/InternalPeiServicesTablePointer.h
+++ b/MdePkg/Library/PeiServicesTablePointerLibIdt/InternalPeiServicesTablePointer.h
@@ -19,15 +19,11 @@
#include <PiPei.h>
+#include <Library/BaseLib.h>
#include <Library/PeiServicesTablePointerLib.h>
#include <Library/DebugLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/BaseMemoryLib.h>
-extern
-EFI_PEI_SERVICES **
-EFIAPI
-AsmPeiSevicesTablePointer (
- VOID
- );
-
-
+
#endif
diff --git a/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c b/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
index 6a52451381..2536d6a861 100644
--- a/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
+++ b/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
@@ -33,9 +33,66 @@ GetPeiServicesTablePointer (
)
{
EFI_PEI_SERVICES **PeiServices;
-
- PeiServices = (EFI_PEI_SERVICES **) AsmPeiSevicesTablePointer ();
+ IA32_DESCRIPTOR Idtr;
+
+ AsmReadIdtr (&Idtr);
+ PeiServices = (EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.Base - 4));
ASSERT (PeiServices != NULL);
return PeiServices;
}
+/**
+
+ The function returns the pointer to PeiServicee following
+ PI1.0.
+
+ For IA32, the four-bytes field immediately prior to new IDT
+ base addres is used to save the EFI_PEI_SERVICES**.
+ For x64, the eight-bytes field immediately prior to new IDT
+ base addres is used to save the EFI_PEI_SERVICES**
+ @retval The pointer to PeiServices.
+
+**/
+VOID
+EFIAPI
+SetPeiServicesTablePointer (
+ EFI_PEI_SERVICES ** PeiServicesTablePointer
+ )
+{
+ IA32_DESCRIPTOR Idtr;
+
+ AsmReadIdtr (&Idtr);
+ (*(UINTN*)(Idtr.Base - 4)) = (UINTN)PeiServicesTablePointer;
+}
+
+/**
+ After memory initialization in PEI phase, the IDT table in temporary memory should
+ be migrated to memory, and the address of PeiServicesPointer also need to be updated
+ immediately preceding the new IDT table.
+
+ @param PeiServices The address of PeiServices pointer.
+**/
+VOID
+MigrateIdtTable (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+ UINTN Size;
+ VOID *NewBase;
+ EFI_STATUS Status;
+ IA32_DESCRIPTOR Idtr;
+
+ AsmReadIdtr (&Idtr);
+
+ Size = sizeof(UINTN) + (Idtr.Limit + 1);
+
+ Status = PeiServicesAllocatePool (Size, &NewBase);
+ ASSERT_EFI_ERROR (Status);
+
+ CopyMem ((VOID*)((UINTN)NewBase + sizeof(UINTN)), (VOID*)Idtr.Base, (Idtr.Limit + 1));
+
+ Idtr.Base = (UINTN)NewBase + sizeof(UINTN);
+ AsmWriteIdtr (&Idtr);
+ SetPeiServicesTablePointer(PeiServices);
+}
+
diff --git a/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf b/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
index 049f8754e5..6baad7a600 100644
--- a/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
+++ b/MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
@@ -31,16 +31,16 @@
[Packages]
MdePkg/MdePkg.dec
-[Sources.Ia32]
- Ia32/AsmPeiSevicesTablePointer.c|MSFT
- Ia32/AsmPeiSevicesTablePointer.S|GCC
+[Sources]
PeiServicesTablePointer.c
+ InternalPeiServicesTablePointer.h
-[Sources.X64]
- x64/AsmPeiSevicesTablePointer.asm|MSFT
- x64/AsmPeiSevicesTablePointer.S|GCC
- PeiServicesTablePointer.c
[LibraryClasses]
DebugLib
+ BaseMemoryLib
+ PeiServicesLib
+ BaseLib
+
+
diff --git a/MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointer.c b/MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointer.c
index 95d6d25447..5986e54af7 100644
--- a/MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointer.c
+++ b/MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointer.c
@@ -62,4 +62,18 @@ PeiServicesTablePointerLibConstructor (
return EFI_SUCCESS;
}
+/**
+ After memory initialization in PEI phase, the IDT table in temporary memory should
+ be migrated to memory, and the address of PeiServicesPointer also need to be updated
+ immediately preceding the new IDT table.
+
+ @param PeiServices The address of PeiServices pointer.
+**/
+VOID
+MigrateIdtTable (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+}
+
diff --git a/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c b/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c
index 4c439ebd5f..46fe3083b9 100644
--- a/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c
+++ b/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c
@@ -21,6 +21,8 @@
#include <Library/PeiServicesTablePointerLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PeiServicesLib.h>
VOID
EFIAPI
@@ -75,3 +77,34 @@ PeiServicesTablePointerLibConstructor (
AsmWriteMm7 ((UINT64)(UINTN)PeiServices);
return EFI_SUCCESS;
}
+
+/**
+ After memory initialization in PEI phase, the IDT table in temporary memory should
+ be migrated to memory, and the address of PeiServicesPointer also need to be updated
+ immediately preceding the new IDT table.
+
+ @param PeiServices The address of PeiServices pointer.
+**/
+VOID
+MigrateIdtTable (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+ UINTN Size;
+ VOID *NewBase;
+ EFI_STATUS Status;
+ IA32_DESCRIPTOR Idtr;
+
+ AsmReadIdtr (&Idtr);
+
+ Size = Idtr.Limit + 1;
+
+ Status = PeiServicesAllocatePool (Size, &NewBase);
+ ASSERT_EFI_ERROR (Status);
+
+ CopyMem (NewBase, (VOID*)Idtr.Base, Size);
+
+ Idtr.Base = (UINTN)NewBase;
+ AsmWriteIdtr (&Idtr);
+}
+
diff --git a/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf b/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf
index 54edec520d..a0371843d1 100644
--- a/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf
+++ b/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf
@@ -44,4 +44,5 @@
[LibraryClasses]
DebugLib
BaseLib
-
+ BaseMemoryLib
+ PeiServicesLib