From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=jordan.l.justen@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C4CAA2194EB7F for ; Sun, 17 Feb 2019 20:12:01 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Feb 2019 20:12:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,383,1544515200"; d="scan'208";a="321197994" Received: from mmdandap-mobl1.amr.corp.intel.com (HELO jljusten-skl.amr.corp.intel.com) ([10.254.8.66]) by fmsmga005.fm.intel.com with ESMTP; 17 Feb 2019 20:12:01 -0800 From: Jordan Justen To: edk2-devel@lists.01.org Cc: Jordan Justen , Jian J Wang , Hao Wu , Ray Ni , Star Zeng Date: Sun, 17 Feb 2019 20:11:40 -0800 Message-Id: <20190218041141.21363-10-jordan.l.justen@intel.com> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20190218041141.21363-1-jordan.l.justen@intel.com> References: <20190218041141.21363-1-jordan.l.justen@intel.com> MIME-Version: 1.0 Subject: [PATCH 09/10] MdeModulePkg/Core/Pei: Use assembly for IA32 TemporaryRamMigration X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Feb 2019 04:12:02 -0000 Content-Transfer-Encoding: 8bit Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen Cc: Jian J Wang Cc: Hao Wu Cc: Ray Ni Cc: Star Zeng --- .../Dispatcher/Ia32/TemporaryRamMigration.S | 72 +++++++++++++++++ .../Ia32/TemporaryRamMigration.nasm | 78 +++++++++++++++++++ MdeModulePkg/Core/Pei/PeiMain.inf | 3 +- 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.S create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.nasm diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.S b/MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.S new file mode 100644 index 0000000000..363cadca2a --- /dev/null +++ b/MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.S @@ -0,0 +1,72 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2018 - 2019, 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. +# +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# VOID +# EFIAPI +# PeiTemporaryRamMigration ( +# IN PEI_CORE_TEMPORARY_RAM_TRANSITION *TempRamTransitionData +# ); +# +# @param[in] Stack Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION +# +# @return None This routine does not return +#------------------------------------------------------------------------------ +ASM_GLOBAL ASM_PFX(PeiTemporaryRamMigration) +ASM_PFX(PeiTemporaryRamMigration): + + # + # We never return from this call + # + add $4, %esp + + # + # (eax) Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION + # + mov (%esp), %eax + + # + # We'll store the new location of TempRamTransitionData after + # migration in ebx. By the IA32 calling convention we should + # normally save ebx, but we won't be returning to the caller, so + # we don't need to save it. By the same rule, the + # TemporaryRamMigration PPI call should preserve ebx for us. + # + mov (%esp), %ebx + add 0x10(%eax), %ebx + sub 0x08(%eax), %ebx + + # + # Setup parameters and call TemporaryRamSupport->TemporaryRamMigration + # 32-bit PeiServices + # 64-bit TemporaryMemoryBase + # 64-bit PermanentMemoryBase + # 32-bit CopySize + # + pushl 0x18(%eax) # CopySize + pushl 0x14(%eax) # PermanentMemoryBase Upper 32-bit + pushl 0x10(%eax) # PermanentMemoryBase Lower 32-bit + pushl 0x0c(%eax) # TemporaryMemoryBase Upper 32-bit + pushl 0x08(%eax) # TemporaryMemoryBase Lower 32-bit + pushl 0x04(%eax) # PeiServices + calll *(%eax) + sub 0x18, %esp + + # + # Setup parameters and call PeiTemporaryRamMigrated + # 32-bit Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION + # + push %ebx + call ASM_PFX(PeiTemporaryRamMigrated) diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.nasm b/MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.nasm new file mode 100644 index 0000000000..e200a3631f --- /dev/null +++ b/MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.nasm @@ -0,0 +1,78 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2018 - 2019, 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. +; +;------------------------------------------------------------------------------ + +#include + + SECTION .text + +extern ASM_PFX(PeiTemporaryRamMigrated) + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; PeiTemporaryRamMigration ( +; IN PEI_CORE_TEMPORARY_RAM_TRANSITION *TempRamTransitionData +; ); +; +; @param[in] Stack Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION +; +; @return None This routine does not return +;------------------------------------------------------------------------------ +global ASM_PFX(PeiTemporaryRamMigration) +ASM_PFX(PeiTemporaryRamMigration): + + ; + ; We never return from this call + ; + add esp, 4 + + ; + ; (eax) Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION + ; + mov eax, [esp] + + ; + ; We'll store the new location of TempRamTransitionData after + ; migration in ebx. By the IA32 calling convention we should + ; normally save ebx, but we won't be returning to the caller, so + ; we don't need to save it. By the same rule, the + ; TemporaryRamMigration PPI call should preserve ebx for us. + ; + mov ebx, [esp] + add ebx, [eax + 0x10] + sub ebx, [eax + 0x08] + + ; + ; Setup parameters and call TemporaryRamSupport->TemporaryRamMigration + ; 32-bit PeiServices + ; 64-bit TemporaryMemoryBase + ; 64-bit PermanentMemoryBase + ; 32-bit CopySize + ; + push DWORD [eax + 0x18] ; CopySize + push DWORD [eax + 0x14] ; PermanentMemoryBase Upper 32-bit + push DWORD [eax + 0x10] ; PermanentMemoryBase Lower 32-bit + push DWORD [eax + 0x0c] ; TemporaryMemoryBase Upper 32-bit + push DWORD [eax + 0x08] ; TemporaryMemoryBase Lower 32-bit + push DWORD [eax + 0x04] ; PeiServices + call DWORD [eax + 0x00] + sub esp, 0x18 + + ; + ; Setup parameters and call PeiTemporaryRamMigrated + ; 32-bit Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION + ; + push ebx + call ASM_PFX(PeiTemporaryRamMigrated) diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf index 1646f73385..505544d4e8 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.inf +++ b/MdeModulePkg/Core/Pei/PeiMain.inf @@ -53,7 +53,8 @@ PeiMain.h [Sources.Ia32] - Dispatcher/TemporaryRamMigration.c + Dispatcher/Ia32/TemporaryRamMigration.nasm + Dispatcher/Ia32/TemporaryRamMigration.S [Sources.X64] Dispatcher/X64/TemporaryRamMigration.nasm -- 2.20.0.rc1