]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/Unix/Host/X64/SwitchStack.S
EmulatorPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmulatorPkg / Unix / Host / X64 / SwitchStack.S
1 #------------------------------------------------------------------------------
2 #
3 # Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4 # Portitions copyright (c) 2011, Apple Inc. All rights reserved.
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
6 #
7 #------------------------------------------------------------------------------
8
9
10 #------------------------------------------------------------------------------
11 # Routine Description:
12 #
13 # Routine for switching stacks with 2 parameters EFI ABI
14 # Convert UNIX to EFI ABI
15 #
16 # Arguments:
17 #
18 # (rdi) EntryPoint - Entry point with new stack.
19 # (rsi) Context1 - Parameter1 for entry point. (rcx)
20 # (rdx) Context2 - Parameter2 for entry point. (rdx)
21 # (rcx) NewStack - The pointer to new stack.
22 #
23 # Returns:
24 #
25 # None
26 #
27 #------------------------------------------------------------------------------
28 ASM_GLOBAL ASM_PFX(PeiSwitchStacks)
29 ASM_PFX(PeiSwitchStacks):
30 pushq $0 // tells gdb to stop unwinding frame
31 movq %rsp, %rbp
32
33 movq %rcx, %rsp // update stack pointer
34
35 movq %rdi, %rax // entry point to %rax
36 movq %rsi, %rcx // Adjust Context1
37 // Context2 already in the rigth spot
38
39 #
40 # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,
41 # in case the callee wishes to spill them.
42 #
43 subq $32, %rsp // 32-byte shadow space plus alignment pad
44 call *%rax
45
46
47