diff options
author | klu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-02-29 18:24:43 +0000 |
---|---|---|
committer | klu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-02-29 18:24:43 +0000 |
commit | 58dcdada561c36394c819d3105e867208b84227d (patch) | |
tree | 8e3b31896fffa7004a608746d8b99806ce3f1631 /Nt32Pkg | |
parent | bc4cb041a3236518393b1ca475a3069b128fb88a (diff) | |
download | edk2-platforms-58dcdada561c36394c819d3105e867208b84227d.tar.xz |
Merge Temporary Ram support patch.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4782 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Nt32Pkg')
-rw-r--r-- | Nt32Pkg/Include/Library/EdkGenericBdsLib.h | 21 | ||||
-rw-r--r-- | Nt32Pkg/Nt32Pkg.dec | 2 | ||||
-rw-r--r-- | Nt32Pkg/Nt32Pkg.dsc | 1 | ||||
-rw-r--r-- | Nt32Pkg/Nt32Pkg.fdf | 2 | ||||
-rw-r--r-- | Nt32Pkg/Sec/SecMain.c | 85 | ||||
-rw-r--r-- | Nt32Pkg/Sec/SecMain.h | 9 | ||||
-rw-r--r-- | Nt32Pkg/Sec/SecMain.inf | 6 | ||||
-rw-r--r-- | Nt32Pkg/Sec/Stack.asm | 94 |
8 files changed, 198 insertions, 22 deletions
diff --git a/Nt32Pkg/Include/Library/EdkGenericBdsLib.h b/Nt32Pkg/Include/Library/EdkGenericBdsLib.h index bc2066fc46..bfdcbe3111 100644 --- a/Nt32Pkg/Include/Library/EdkGenericBdsLib.h +++ b/Nt32Pkg/Include/Library/EdkGenericBdsLib.h @@ -1,4 +1,7 @@ -/*++
+/*! \addtogroup Library EdkGenericBdsLib */
+/*@{ */
+/**@file
+ BDS library definition, include the file and data structure
Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
@@ -9,15 +12,7 @@ http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- BdsLib.h
-
-Abstract:
-
- BDS library definition, include the file and data structure
-
---*/
+**/
#ifndef _BDS_LIB_H_
#define _BDS_LIB_H_
@@ -110,6 +105,11 @@ BdsLibBootNext ( VOID
);
+/*!
+ \fn BdsLibBootViaBootOption
+ \param BDS_COMMON_OPTION
+ \param EFI_DEVICE_PATH_PROTOCOL
+*/
EFI_STATUS
BdsLibBootViaBootOption (
IN BDS_COMMON_OPTION * Option,
@@ -394,3 +394,4 @@ BdsLibGetHiiHandles ( );
#endif // _BDS_LIB_H_
+/*@} */
\ No newline at end of file diff --git a/Nt32Pkg/Nt32Pkg.dec b/Nt32Pkg/Nt32Pkg.dec index f54d7ea733..2d87f2d4f5 100644 --- a/Nt32Pkg/Nt32Pkg.dec +++ b/Nt32Pkg/Nt32Pkg.dec @@ -15,6 +15,7 @@ #
#**/
+
################################################################################
#
# Defines Section - statements that will be processed to create a Makefile.
@@ -22,6 +23,7 @@ ################################################################################
[Defines]
+
DEC_SPECIFICATION = 0x00010005
PACKAGE_NAME = Nt32Pkg
PACKAGE_GUID = 0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3
diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc index e34191bcc9..2287ae725f 100644 --- a/Nt32Pkg/Nt32Pkg.dsc +++ b/Nt32Pkg/Nt32Pkg.dsc @@ -247,6 +247,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|TRUE
[PcdsFixedAtBuild.IA32]
+ #gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize|0x20000
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeRuntimeMemorySize|128
gEfiNt32PkgTokenSpaceGuid.PcdWinNtMemorySizeForSecMain|L"64!64"|VOID*|12
diff --git a/Nt32Pkg/Nt32Pkg.fdf b/Nt32Pkg/Nt32Pkg.fdf index b931f803b8..edd69ad173 100644 --- a/Nt32Pkg/Nt32Pkg.fdf +++ b/Nt32Pkg/Nt32Pkg.fdf @@ -162,9 +162,9 @@ INF IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.inf INF Nt32Pkg/BootModePei/BootModePei.inf
INF Nt32Pkg/WinNtFlashMapPei/WinNtFlashMapPei.inf
INF MdeModulePkg/Universal/MemoryTest/BaseMemoryTestPei/BaseMemoryTestPei.inf
-INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
INF Nt32Pkg/WinNtAutoScanPei/WinNtAutoScanPei.inf
INF Nt32Pkg/WinNtFirmwareVolumePei/WinNtFirmwareVolumePei.inf
+INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
INF Nt32Pkg/WinNtThunkPPIToProtocolPei/WinNtThunkPPIToProtocolPei.inf
INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
diff --git a/Nt32Pkg/Sec/SecMain.c b/Nt32Pkg/Sec/SecMain.c index 4054d61bd0..ccfc6bb3f8 100644 --- a/Nt32Pkg/Sec/SecMain.c +++ b/Nt32Pkg/Sec/SecMain.c @@ -58,6 +58,7 @@ EFI_PEI_PROGRESS_CODE_PPI mSecStatusCodePpi = { SecPeiReport NT_FWH_PPI mSecFwhInformationPpi = { SecWinNtFdAddress };
+TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {SecTemporaryRamSupport};
EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] = {
{
@@ -86,6 +87,11 @@ EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] = { &mSecStatusCodePpi
},
{
+ EFI_PEI_PPI_DESCRIPTOR_PPI,
+ &gEfiTemporaryRamSupportPpiGuid,
+ &mSecTemporaryRamSupportPpi
+ },
+ {
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gNtFwhPpiGuid,
&mSecFwhInformationPpi
@@ -116,7 +122,12 @@ UINTN mPdbNameModHandleArraySize = 0; PDB_NAME_TO_MOD_HANDLE *mPdbNameModHandleArray = NULL;
-
+VOID
+EFIAPI
+SecSwitchStack (
+ UINT32 TemporaryMemoryBase,
+ UINT32 PermenentMemoryBase
+ );
INTN
EFIAPI
@@ -566,18 +577,31 @@ Returns: EFI_PHYSICAL_ADDRESS PeiCoreEntryPoint;
EFI_PHYSICAL_ADDRESS PeiImageAddress;
EFI_SEC_PEI_HAND_OFF *SecCoreData;
+ UINTN PeiStackSize;
//
// Compute Top Of Memory for Stack and PEI Core Allocations
//
- TopOfMemory = LargestRegion + LargestRegionSize;
+ TopOfMemory = LargestRegion + LargestRegionSize;
+ PeiStackSize = (UINTN)RShiftU64((UINT64)STACK_SIZE,1);
//
- // Allocate 128KB for the Stack
+ // |-----------| <---- TemporaryRamBase + TemporaryRamSize
+ // | Heap |
+ // | |
+ // |-----------| <---- StackBase / PeiTemporaryMemoryBase
+ // | |
+ // | Stack |
+ // |-----------| <---- TemporaryRamBase
+ //
+ TopOfStack = (VOID *)(LargestRegion + PeiStackSize);
+ TopOfMemory = LargestRegion + PeiStackSize;
+
//
- TopOfStack = (VOID *)((UINTN)TopOfMemory - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);
+ // Reservet space for storing PeiCore's parament in stack.
+ //
+ TopOfStack = (VOID *)((UINTN)TopOfStack - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
- TopOfMemory = TopOfMemory - STACK_SIZE;
//
// Patch value in dispatch table values
@@ -591,12 +615,12 @@ Returns: SecCoreData->DataSize = sizeof(EFI_SEC_PEI_HAND_OFF);
SecCoreData->BootFirmwareVolumeBase = (VOID*)BootFirmwareVolumeBase;
SecCoreData->BootFirmwareVolumeSize = FixedPcdGet32(PcdWinNtFirmwareFdSize);
- SecCoreData->TemporaryRamBase = (VOID*)(UINTN)TopOfMemory;
+ SecCoreData->TemporaryRamBase = (VOID*)(UINTN)LargestRegion;
SecCoreData->TemporaryRamSize = STACK_SIZE;
- SecCoreData->PeiTemporaryRamBase = SecCoreData->TemporaryRamBase;
- SecCoreData->PeiTemporaryRamSize = (UINTN)RShiftU64((UINT64)STACK_SIZE,1);
- SecCoreData->StackBase = (VOID*)((UINTN)SecCoreData->TemporaryRamBase + (UINTN)SecCoreData->TemporaryRamSize);
- SecCoreData->StackSize = (UINTN)RShiftU64((UINT64)STACK_SIZE,1);
+ SecCoreData->StackBase = (VOID*) ((UINTN) SecCoreData->TemporaryRamBase + PeiStackSize);
+ SecCoreData->StackSize = PeiStackSize;
+ SecCoreData->PeiTemporaryRamBase = SecCoreData->StackBase;
+ SecCoreData->PeiTemporaryRamSize = STACK_SIZE - PeiStackSize;
//
// Load the PEI Core from a Firmware Volume
@@ -1209,3 +1233,44 @@ _ModuleEntryPoint ( {
}
+EFI_STATUS
+EFIAPI
+SecTemporaryRamSupport (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
+ IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
+ IN UINTN CopySize
+ )
+{
+ //
+ // Migrate the whole temporary memory to permenent memory.
+ //
+ CopyMem (
+ (VOID*)(UINTN)PermanentMemoryBase,
+ (VOID*)(UINTN)TemporaryMemoryBase,
+ CopySize
+ );
+
+ //
+ // SecSwitchStack function must be invoked after the memory migration
+ // immediatly, also we need fixup the stack change caused by new call into
+ // permenent memory.
+ //
+ SecSwitchStack (
+ (UINT32) TemporaryMemoryBase,
+ (UINT32) PermanentMemoryBase
+ );
+
+ //
+ // We need *not* fix the return address because currently,
+ // The PeiCore is excuted in flash.
+ //
+
+ //
+ // Simulate to invalid CAR, terminate CAR
+ //
+ //ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize);
+
+ return EFI_SUCCESS;
+}
+
diff --git a/Nt32Pkg/Sec/SecMain.h b/Nt32Pkg/Sec/SecMain.h index 7102d5f5fa..1f54fd0dd2 100644 --- a/Nt32Pkg/Sec/SecMain.h +++ b/Nt32Pkg/Sec/SecMain.h @@ -31,6 +31,7 @@ Abstract: #include <Ppi/NtThunk.h>
#include <Ppi/StatusCode.h>
#include <Ppi/NtFwh.h>
+#include <Ppi/TemporaryRamSupport.h>
#include <Library/PcdLib.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
@@ -576,6 +577,14 @@ SecNt32PeCoffUnloadimage ( IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
+EFI_STATUS
+EFIAPI
+SecTemporaryRamSupport (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
+ IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
+ IN UINTN CopySize
+ );
typedef struct {
EFI_PEI_PE_COFF_LOADER_PROTOCOL PeCoff;
diff --git a/Nt32Pkg/Sec/SecMain.inf b/Nt32Pkg/Sec/SecMain.inf index 20e4726465..95cd30e2ea 100644 --- a/Nt32Pkg/Sec/SecMain.inf +++ b/Nt32Pkg/Sec/SecMain.inf @@ -33,6 +33,7 @@ WinNtThunk.c
FwVol.c
SecMain.c
+ Stack.asm
[Packages]
MdePkg/MdePkg.dec
@@ -58,6 +59,7 @@ gNtFwhPpiGuid # PPI ALWAYS_PRODUCED
gPeiNtAutoScanPpiGuid # PPI ALWAYS_PRODUCED
gPeiNtThunkPpiGuid # PPI ALWAYS_PRODUCED
+ gEfiTemporaryRamSupportPpiGuid
[FixedPcd.common]
@@ -69,4 +71,6 @@ [BuildOptions.common]
MSFT:*_*_IA32_DLINK_FLAGS = /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib" /LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:I386 /LTCG Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib
MSFT:*_*_IA32_CC_FLAGS = /nologo /W4 /WX /Gy /c /D UNICODE /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /EHs-c- /GF /Gs8192 /Zi /Gm /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE
-
+ MSFT:*_*_IA32_PP_FLAGS = /nologo /E /TC /FI$(DEST_DIR_DEBUG)/AutoGen.h
+ MSFT:*_*_IA32_ASM_FLAGS = /nologo /W3 /WX /c /coff /Cx /Zd /W0 /Zi
+ MSFT:*_*_IA32_ASMLINK_FLAGS = /link /nologo /tiny
diff --git a/Nt32Pkg/Sec/Stack.asm b/Nt32Pkg/Sec/Stack.asm new file mode 100644 index 0000000000..ca6b7faaaa --- /dev/null +++ b/Nt32Pkg/Sec/Stack.asm @@ -0,0 +1,94 @@ +;------------------------------------------------------------------------------
+;
+; Copyright (c) 2007, Intel Corporation
+; All rights reserved. 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
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Stack.asm
+;
+; Abstract:
+;
+; Switch the stack from temporary memory to permenent memory.
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; SecSwitchStack (
+; UINT32 TemporaryMemoryBase,
+; UINT32 PermenentMemoryBase
+; );
+;------------------------------------------------------------------------------
+SecSwitchStack PROC
+ ;
+ ; Save three register: eax, ebx, ecx
+ ;
+ push eax
+ push ebx
+ push ecx
+ push edx
+
+ ;
+ ; !!CAUTION!! this function address's is pushed into stack after
+ ; migration of whole temporary memory, so need save it to permenent
+ ; memory at first!
+ ;
+
+ mov ebx, [esp + 20] ; Save the first parameter
+ mov ecx, [esp + 24] ; Save the second parameter
+
+ ;
+ ; Save this function's return address into permenent memory at first.
+ ; Then, Fixup the esp point to permenent memory
+ ;
+ mov eax, esp
+ sub eax, ebx
+ add eax, ecx
+ mov edx, dword ptr [esp] ; copy pushed register's value to permenent memory
+ mov dword ptr [eax], edx
+ mov edx, dword ptr [esp + 4]
+ mov dword ptr [eax + 4], edx
+ mov edx, dword ptr [esp + 8]
+ mov dword ptr [eax + 8], edx
+ mov edx, dword ptr [esp + 12]
+ mov dword ptr [eax + 12], edx
+ mov edx, dword ptr [esp + 16] ; Update this function's return address into permenent memory
+ mov dword ptr [eax + 16], edx
+ mov esp, eax ; From now, esp is pointed to permenent memory
+
+ ;
+ ; Fixup the ebp point to permenent memory
+ ;
+ mov eax, ebp
+ sub eax, ebx
+ add eax, ecx
+ mov ebp, eax ; From now, ebp is pointed to permenent memory
+
+ ;
+ ; Fixup callee's ebp point for PeiDispatch
+ ;
+ mov eax, dword ptr [ebp]
+ sub eax, ebx
+ add eax, ecx
+ mov dword ptr [ebp], eax ; From now, Temporary's PPI caller's stack is in permenent memory
+
+ pop edx
+ pop ecx
+ pop ebx
+ pop eax
+ ret
+SecSwitchStack ENDP
+
+ END
|