]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Pei / PeiLib / X64 / ProcessorAsms.S
CommitLineData
e8de4680
A
1#------------------------------------------------------------------------------
2#
4ea9375a
HT
3# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
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
62.equ EFI_SUCCESS, 0
63.equ EFI_WARN_RETURN_FROM_LONG_JUMP, 5
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)
102 mov (%rsp),%rax
103 mov %rax,0x58(%rdx)
104 mov $0x0,%rax
105 retq
106
107
108#
109# EFI_STATUS
110# EFIAPI
111# TransferControlLongJump (
112# IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, // rcx
113# IN EFI_JUMP_BUFFER *Jump // rdx
114# );
115#
116#
117ASM_PFX(TransferControlLongJump):
118 # set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
119 mov $0x5,%rax
120 mov (%rdx),%rbx
121 mov 0x8(%rdx),%rsp
122 mov 0x10(%rdx),%rbp
123 mov 0x18(%rdx),%rdi
124 mov 0x20(%rdx),%rsi
125 mov 0x28(%rdx),%r10
126 mov 0x30(%rdx),%r11
127 mov 0x38(%rdx),%r12
128 mov 0x40(%rdx),%r13
129 mov 0x48(%rdx),%r14
130 mov 0x50(%rdx),%r15
131 add $0x8,%rsp
132 jmpq *0x58(%rdx)
133 mov $0x5,%rax
134 retq
135