]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Sec/X64/SwitchStack.S
Started trying to get the UnixPkg to compile for X64 with UnixABI. So far only have...
[mirror_edk2.git] / UnixPkg / Sec / X64 / SwitchStack.S
1 #------------------------------------------------------------------------------
2 #
3 # Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4 # This program and the accompanying materials
5 # are licensed and made available under the terms and conditions of the BSD License
6 # which accompanies this distribution. The full text of the license may be found at
7 # http://opensource.org/licenses/bsd-license.php.
8 #
9 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 #
12 # Module Name:
13 #
14 # SwitchStack.S
15 #
16 # Abstract:
17 #
18 #------------------------------------------------------------------------------
19
20
21 #------------------------------------------------------------------------------
22 # Routine Description:
23 #
24 # Routine for switching stacks with 3 parameters EFI ABI
25 #
26 # Arguments:
27 #
28 # (rcx) EntryPoint - Entry point with new stack.
29 # (rdx) Context1 - Parameter1 for entry point.
30 # (r8) Context2 - Parameter2 for entry point.
31 # (r9) Context3 - Parameter3 for entry point.
32 # (rsp)0x20 NewStack - The pointer to new stack.
33 #
34 # Returns:
35 #
36 # None
37 #
38 #------------------------------------------------------------------------------
39 ASM_GLOBAL ASM_PFX(MsftPeiSwitchStacks)
40 ASM_PFX(MsftPeiSwitchStacks):
41 mov %rcx, %rax
42 mov %rdx, %rcx
43 mov %r8, %rdx
44 mov %r9, %r8
45
46 # get new stack from the stack
47 mov 0x20(%rsp), %rsp # is this off by 8?
48
49 #
50 # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,
51 # in case the callee wishes to spill them.
52 #
53 lea -0x20(%rsp), %rsp
54 call *%rax
55
56
57 #------------------------------------------------------------------------------
58 # Routine Description:
59 #
60 # Routine for switching stacks with 3 parameters UNIX ABI
61 #
62 # Arguments:
63 #
64 # (rdi) EntryPoint - Entry point with new stack.
65 # (rsi) Context1 - Parameter1 for entry point.
66 # (rdx) Context2 - Parameter2 for entry point.
67 # (rcx) Context3 - Parameter3 for entry point.
68 # (r8) NewStack - The pointer to new stack.
69 #
70 # Returns:
71 #
72 # None
73 #
74 #------------------------------------------------------------------------------
75 ASM_GLOBAL ASM_PFX(PeiSwitchStacks)
76 ASM_PFX(PeiSwitchStacks):
77 mov %rdi, %rax
78 mov %rsi, %rdi
79 mov %rdx, %rsi
80 mov %rcx, %rdx
81 mov %r8, %rsp
82
83
84 #
85 # Reserve space for redzone on the stack,
86 # in case the callee wishes to spill them.
87 #
88 lea -0x80(%rsp), %rsp
89 call *%rax
90
91
92
93 #------------------------------------------------------------------------------
94 # VOID
95 # EFIAPI
96 # SecSwitchStack (
97 # UINT32 TemporaryMemoryBase, // Rcx, Rdi
98 # UINT32 PermenentMemoryBase // Rdx, Rsi
99 # );
100 #------------------------------------------------------------------------------
101 ASM_GLOBAL ASM_PFX(SecSwitchStack)
102 ASM_PFX(SecSwitchStack):
103
104 mov %rsp, %rax
105 sub %rdi, %rax
106 add %rsi, %rax
107 mov (%rip), %r10
108 mov %r10, (%rax)
109 ret
110
111