]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Sec/X64/SwitchStack.S
Fix issue with fixing tabs.
[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 # Convert UNIX to EFI ABI
26 #
27 # Arguments:
28 #
29 # (rdi) EntryPoint - Entry point with new stack.
30 # (rsi) Context1 - Parameter1 for entry point. (rcx)
31 # (rdx) Context2 - Parameter2 for entry point. (rdx)
32 # (rcx) Context3 - Parameter3 for entry point. (r8)
33 # (r8) NewStack - The pointer to new stack.
34 #
35 # Returns:
36 #
37 # None
38 #
39 #------------------------------------------------------------------------------
40 ASM_GLOBAL ASM_PFX(PeiSwitchStacks)
41 ASM_PFX(PeiSwitchStacks):
42 pushq %rbp // stack frame is for the debugger
43 movq %rsp, %rbp
44
45 movq %r8, %rsp
46
47 movq %rdi, %rax
48 movq %rsi, %rcx
49 movq %rcx, %r8
50
51 #
52 # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,
53 # in case the callee wishes to spill them.
54 #
55 subq $32, %rsp // 32-byte shadow space plus alignment pad
56 call *%rax
57
58
59 #------------------------------------------------------------------------------
60 # Routine Description:
61 #
62 # Routine for switching stacks with 3 parameters UNIX ABI
63 #
64 # Arguments:
65 #
66 # (rdi) EntryPoint - Entry point with new stack.
67 # (rsi) Context1 - Parameter1 for entry point.
68 # (rdx) Context2 - Parameter2 for entry point.
69 # (rcx) Context3 - Parameter3 for entry point.
70 # (r8) NewStack - The pointer to new stack.
71 #
72 # Returns:
73 #
74 # None
75 #
76 #------------------------------------------------------------------------------
77 ASM_GLOBAL ASM_PFX(UnixPeiSwitchStacks)
78 ASM_PFX(UnixPeiSwitchStacks):
79 pushq %rbp // stack frame is for the debugger
80 movq %rsp, %rbp
81
82 mov %rdi, %rax
83 mov %rsi, %rdi
84 mov %rdx, %rsi
85 mov %rcx, %rdx
86 mov %r8, %rsp
87
88
89 #
90 # Reserve space for redzone on the stack,
91 # in case the callee wishes to spill them.
92 #
93 lea -0x80(%rsp), %rsp
94 call *%rax
95
96
97
98 #------------------------------------------------------------------------------
99 # VOID
100 # EFIAPI
101 # SecSwitchStack (
102 # UINT32 TemporaryMemoryBase, // Rcx, Rdi
103 # UINT32 PermenentMemoryBase // Rdx, Rsi
104 # );
105 #------------------------------------------------------------------------------
106 ASM_GLOBAL ASM_PFX(SecSwitchStack)
107 ASM_PFX(SecSwitchStack):
108 pushq %rbp // stack frame is for the debugger
109 movq %rsp, %rbp
110
111 mov %rsp, %rax
112 sub %rdi, %rax
113 add %rsi, %rax
114 mov (%rip), %r10
115 mov %r10, (%rax)
116
117 popq %rbp
118 ret
119
120