]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/Sec/X64/SwitchStack.S
Complete coding to support X64 EFI ABI in UnixPkg. Code is not currently hooked in...
[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
a4902ccc 40ASM_GLOBAL ASM_PFX(GasketPeiSwitchStacks)\r
41ASM_PFX(GasketPeiSwitchStacks):\r
42// movq %rdx, %rdx \r
43 movq %r8, %rsp\r
67f86803 44 \r
a4902ccc 45 movq %rdi, %rax\r
46 movq %rsi, %rcx\r
47 movq %rcx, %r8 \r
67f86803 48 \r
49 #\r
50 # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,\r
51 # in case the callee wishes to spill them.\r
52 #\r
a4902ccc 53 subq 40, %rsp // 32-byte shadow space plus alignment pad\r
67f86803 54 call *%rax\r
55\r
56\r
57#------------------------------------------------------------------------------\r
58# Routine Description:\r
59#\r
60# Routine for switching stacks with 3 parameters UNIX ABI\r
61#\r
62# Arguments:\r
63#\r
64# (rdi) EntryPoint - Entry point with new stack.\r
65# (rsi) Context1 - Parameter1 for entry point.\r
66# (rdx) Context2 - Parameter2 for entry point.\r
67# (rcx) Context3 - Parameter3 for entry point.\r
68# (r8) NewStack - The pointer to new stack.\r
69#\r
70# Returns:\r
71#\r
72# None\r
73#\r
74#------------------------------------------------------------------------------\r
75ASM_GLOBAL ASM_PFX(PeiSwitchStacks)\r
76ASM_PFX(PeiSwitchStacks):\r
77 mov %rdi, %rax\r
78 mov %rsi, %rdi\r
79 mov %rdx, %rsi\r
80 mov %rcx, %rdx\r
81 mov %r8, %rsp\r
82 \r
83 \r
84 #\r
85 # Reserve space for redzone on the stack,\r
86 # in case the callee wishes to spill them.\r
87 #\r
88 lea -0x80(%rsp), %rsp\r
89 call *%rax\r
90\r
91\r
92\r
93#------------------------------------------------------------------------------\r
94# VOID\r
95# EFIAPI\r
96# SecSwitchStack (\r
97# UINT32 TemporaryMemoryBase, // Rcx, Rdi\r
98# UINT32 PermenentMemoryBase // Rdx, Rsi\r
99# );\r
100#------------------------------------------------------------------------------ \r
101ASM_GLOBAL ASM_PFX(SecSwitchStack)\r
102ASM_PFX(SecSwitchStack):\r
103\r
104 mov %rsp, %rax\r
105 sub %rdi, %rax\r
106 add %rsi, %rax\r
107 mov (%rip), %r10\r
108 mov %r10, (%rax) \r
109 ret\r
110 \r
111