1#------------------------------------------------------------------------------ 2# 3# Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR> 4# Portitions copyright (c) 2011, Apple Inc. All rights reserved. 5# This program and the accompanying materials 6# are licensed and made available under the terms and conditions of the BSD License 7# which accompanies this distribution. The full text of the license may be found at 8# http://opensource.org/licenses/bsd-license.php. 9# 10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12# 13#------------------------------------------------------------------------------ 14 15 16#------------------------------------------------------------------------------ 17# Routine Description: 18# 19# Routine for switching stacks with 2 parameters EFI ABI 20# Convert UNIX to EFI ABI 21# 22# Arguments: 23# 24# (rdi) EntryPoint - Entry point with new stack. 25# (rsi) Context1 - Parameter1 for entry point. (rcx) 26# (rdx) Context2 - Parameter2 for entry point. (rdx) 27# (rcx) NewStack - The pointer to new stack. 28# 29# Returns: 30# 31# None 32# 33#------------------------------------------------------------------------------ 34ASM_GLOBAL ASM_PFX(PeiSwitchStacks) 35ASM_PFX(PeiSwitchStacks): 36 pushq $0 // tells gdb to stop unwinding frame 37 movq %rsp, %rbp 38 39 movq %rcx, %rsp // update stack pointer 40 41 movq %rdi, %rax // entry point to %rax 42 movq %rsi, %rcx // Adjust Context1 43 // Context2 already in the rigth spot 44 45 # 46 # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack, 47 # in case the callee wishes to spill them. 48 # 49 subq $32, %rsp // 32-byte shadow space plus alignment pad 50 call *%rax 51 52 53 54