]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S
EdkCompatabilityPkg: Fix build issues with X64 clang
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Pei / PeiLib / X64 / ProcessorAsms.S
CommitLineData
e8de4680
A
1#------------------------------------------------------------------------------
2#
3e99020d 3# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
4ea9375a 4# This program and the accompanying materials
e8de4680
A
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# ProcessorAsms.S
14#
15# Abstract:
16# This is separated from processor.c to allow this functions to be built with /O1
17#
18#
19#------------------------------------------------------------------------------
20#include <EfiBind.h>
21
22 .text
23
24.globl ASM_PFX(SwitchStacks)
25.globl ASM_PFX(TransferControlSetJump)
26.globl ASM_PFX(TransferControlLongJump)
27
28#
29# Routine Description:
30# This allows the caller to switch the stack and goes to the new entry point
31#
32# Arguments:
33# EntryPoint - Pointer to the location to enter // rcx
34# Parameter - Parameter to pass in // rdx
35# NewStack - New Location of the stack // r8
36# NewBsp - New BSP // r9 - not used
37#
38# Returns:
39# Nothing. Goes to the Entry Point passing in the new parameters
40#
41ASM_PFX(SwitchStacks):
42
43 # Adjust stack for
44 # 1) leave 4 registers space
45 # 2) let it 16 bytes aligned after call
46 sub $0x20,%r8
47 and -0x10,%r8w # do not assume 16 bytes aligned
48
49 mov %r8,%rsp
50 mov %rcx,%r10
51 mov %rdx,%rcx
52 callq *%r10
53
54 #
55 # no ret as we have a new stack and we jumped to the new location
56 #
57 ret
58
59#SwitchStacks ENDP
60
61
271d2c7f 62.set EFI_SUCCESS, 0
63.set EFI_WARN_RETURN_FROM_LONG_JUMP, 5
e8de4680
A
64
65#
66#Routine Description:
67#
68# This routine implements the x64 variant of the SetJump call. Its
69# responsibility is to store system state information for a possible
70# subsequent LongJump.
71#
72#Arguments:
73#
74# Pointer to CPU context save buffer.
75#
76#Returns:
77#
78# EFI_SUCCESS
79#
80# EFI_STATUS
81# EFIAPI
82# TransferControlLongJump (
83# IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
84# IN EFI_JUMP_BUFFER *Jump
85# );
86#
87# rcx - *This
88# rdx - JumpBuffer
89#
90ASM_PFX(TransferControlSetJump):
91 mov %rbx,(%rdx)
92 mov %rsp,0x8(%rdx)
93 mov %rbp,0x10(%rdx)
94 mov %rdi,0x18(%rdx)
95 mov %rsi,0x20(%rdx)
96 mov %r10,0x28(%rdx)
97 mov %r11,0x30(%rdx)
98 mov %r12,0x38(%rdx)
99 mov %r13,0x40(%rdx)
100 mov %r14,0x48(%rdx)
101 mov %r15,0x50(%rdx)
271d2c7f 102 #; save non-volatile fp registers
103 stmxcsr 0x60(%rdx)
104 lea 0x68(%rdx), %rax
105 movdqu %xmm6, (%rax)
106 movdqu %xmm7, 0x10(%rax)
107 movdqu %xmm8, 0x20(%rax)
108 movdqu %xmm9, 0x30(%rax)
109 movdqu %xmm10, 0x40(%rax)
110 movdqu %xmm11, 0x50(%rax)
111 movdqu %xmm12, 0x60(%rax)
112 movdqu %xmm13, 0x70(%rax)
113 movdqu %xmm14, 0x80(%rax)
114 movdqu %xmm15, 0x90(%rax)
e8de4680
A
115 mov (%rsp),%rax
116 mov %rax,0x58(%rdx)
117 mov $0x0,%rax
118 retq
119
120
121#
122# EFI_STATUS
123# EFIAPI
124# TransferControlLongJump (
125# IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, // rcx
126# IN EFI_JUMP_BUFFER *Jump // rdx
127# );
128#
129#
130ASM_PFX(TransferControlLongJump):
3e99020d 131 # set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
271d2c7f 132 #; load non-volatile fp registers
133 ldmxcsr 0x60(%rdx)
134 lea 0x68(%rdx), %rax
135 movdqu (%rax), %xmm6
136 movdqu 0x10(%rax), %xmm7
137 movdqu 0x20(%rax), %xmm8
138 movdqu 0x30(%rax), %xmm9
139 movdqu 0x40(%rax), %xmm10
140 movdqu 0x50(%rax), %xmm11
141 movdqu 0x60(%rax), %xmm12
142 movdqu 0x70(%rax), %xmm13
143 movdqu 0x80(%rax), %xmm14
144 movdqu 0x90(%rax), %xmm15
e8de4680
A
145 mov $0x5,%rax
146 mov (%rdx),%rbx
147 mov 0x8(%rdx),%rsp
148 mov 0x10(%rdx),%rbp
149 mov 0x18(%rdx),%rdi
150 mov 0x20(%rdx),%rsi
151 mov 0x28(%rdx),%r10
152 mov 0x30(%rdx),%r11
153 mov 0x38(%rdx),%r12
154 mov 0x40(%rdx),%r13
155 mov 0x48(%rdx),%r14
156 mov 0x50(%rdx),%r15
157 add $0x8,%rsp
158 jmpq *0x58(%rdx)
159 mov $0x5,%rax
160 retq
161