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