[if !mso]>

[edk2] the issue about Pei Switch Stack

Subject: [edk2] the issue about Pei Switch Stack

From: <PandaZhang@viatech.com.cn>

To: <edk2-devel@lists.sourceforge.net>

Date: 2011-12-22 00:42:11

Hi, all:

   After discovery physical memory, EFI must switch stack and heap from CAR to physical memory.

   In EDK2, this is implemented through EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI. TemporaryRamMigration in Dispatcher.c.

            TemporaryRamSupportPpi->TemporaryRamMigration (



                                          (EFI_PHYSICAL_ADDRESS)(UINTN)(TopOfNewStack - TemporaryStackSize),



 1)  if implement TemporaryRamMigration() function in C code, after use MSFT compiler,  the assemble code always like is:

   TemporaryRamMigration() {

       push  ebp

       mov   ebp, esp


        ;Change esp to physical memory


       mov  esp, ebp

       pop ebp


So, after pei dispatcher call this function, stack pointer does not change and can not switch stack?


  2)  if I still want to use C code, I have to add __declspec (naked), but this declare need TemporaryRamMigration() function return VOID not EFI STATUS.




              IN CONST EFI_PEI_SERVICES   **PeiServices,

              IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,

              IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,

               IN UINTN                    CopySize


So I need to modify EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI’s interface.


Then, is TemporaryRamMigration() function must be implemented in assemble code ? how about C code ?