]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Pei / PeiLib / X64 / ProcessorAsms.Asm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2005 - 2007, 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 ; ProcessorAsms.Asm
14 ;
15 ; Abstract:
16 ; This is separated from processor.c to allow this functions to be built with /O1
17 ;
18 ;
19 ;------------------------------------------------------------------------------
20
21 text SEGMENT
22
23
24 ;
25 ; Routine Description:
26 ; This allows the caller to switch the stack and goes to the new entry point
27 ;
28 ; Arguments:
29 ; EntryPoint - Pointer to the location to enter // rcx
30 ; Parameter - Parameter to pass in // rdx
31 ; NewStack - New Location of the stack // r8
32 ; NewBsp - New BSP // r9 - not used
33 ;
34 ; Returns:
35 ; Nothing. Goes to the Entry Point passing in the new parameters
36 ;
37 SwitchStacks PROC PUBLIC
38
39 ; Adjust stack for
40 ; 1) leave 4 registers space
41 ; 2) let it 16 bytes aligned after call
42 sub r8, 20h
43 and r8w, 0fff0h ; do not assume 16 bytes aligned
44
45 mov rsp, r8 ; rsp = NewStack
46 mov r10, rcx ; save EntryPoint
47 mov rcx, rdx ; Arg1 = Parameter
48 call r10 ; r10 = copy of EntryPoint
49 ;
50 ; no ret as we have a new stack and we jumped to the new location
51 ;
52 ret
53
54 SwitchStacks ENDP
55
56
57 EFI_SUCCESS equ 0
58 EFI_WARN_RETURN_FROM_LONG_JUMP equ 5
59
60 ;
61 ; Generated by h2inc run manually
62 ;
63 _EFI_JUMP_BUFFER STRUCT 2t
64 _rbx QWORD ?
65 _rsp QWORD ?
66 _rbp QWORD ?
67 _rdi QWORD ?
68 _rsi QWORD ?
69 _r10 QWORD ?
70 _r11 QWORD ?
71 _r12 QWORD ?
72 _r13 QWORD ?
73 _r14 QWORD ?
74 _r15 QWORD ?
75 _rip QWORD ?
76 _EFI_JUMP_BUFFER ENDS
77
78 EFI_JUMP_BUFFER TYPEDEF _EFI_JUMP_BUFFER
79
80
81 ;
82 ;Routine Description:
83 ;
84 ; This routine implements the x64 variant of the SetJump call. Its
85 ; responsibility is to store system state information for a possible
86 ; subsequent LongJump.
87 ;
88 ;Arguments:
89 ;
90 ; Pointer to CPU context save buffer.
91 ;
92 ;Returns:
93 ;
94 ; EFI_SUCCESS
95 ;
96 ; EFI_STATUS
97 ; EFIAPI
98 ; TransferControlLongJump (
99 ; IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
100 ; IN EFI_JUMP_BUFFER *Jump
101 ; );
102 ;
103 ; rcx - *This
104 ; rdx - JumpBuffer
105 ;
106 PUBLIC TransferControlSetJump
107 TransferControlSetJump PROC
108 mov (EFI_JUMP_BUFFER PTR [rdx])._rbx, rbx
109 mov (EFI_JUMP_BUFFER PTR [rdx])._rsp, rsp
110 mov (EFI_JUMP_BUFFER PTR [rdx])._rbp, rbp
111 mov (EFI_JUMP_BUFFER PTR [rdx])._rdi, rdi
112 mov (EFI_JUMP_BUFFER PTR [rdx])._rsi, rsi
113 mov (EFI_JUMP_BUFFER PTR [rdx])._r10, r10
114 mov (EFI_JUMP_BUFFER PTR [rdx])._r11, r11
115 mov (EFI_JUMP_BUFFER PTR [rdx])._r12, r12
116 mov (EFI_JUMP_BUFFER PTR [rdx])._r13, r13
117 mov (EFI_JUMP_BUFFER PTR [rdx])._r14, r14
118 mov (EFI_JUMP_BUFFER PTR [rdx])._r15, r15
119 mov rax, QWORD PTR [rsp+0]
120 mov (EFI_JUMP_BUFFER PTR [rdx])._rip, rax
121 mov rax, EFI_SUCCESS
122 ret
123
124 TransferControlSetJump ENDP
125
126 ;
127 ; EFI_STATUS
128 ; EFIAPI
129 ; TransferControlLongJump (
130 ; IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, // rcx
131 ; IN EFI_JUMP_BUFFER *Jump // rdx
132 ; );
133 ;
134 ;
135 PUBLIC TransferControlLongJump
136 TransferControlLongJump PROC
137 ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
138 mov rax, EFI_WARN_RETURN_FROM_LONG_JUMP
139 mov rbx, (EFI_JUMP_BUFFER PTR [rdx])._rbx
140 mov rsp, (EFI_JUMP_BUFFER PTR [rdx])._rsp
141 mov rbp, (EFI_JUMP_BUFFER PTR [rdx])._rbp
142 mov rdi, (EFI_JUMP_BUFFER PTR [rdx])._rdi
143 mov rsi, (EFI_JUMP_BUFFER PTR [rdx])._rsi
144 mov r10, (EFI_JUMP_BUFFER PTR [rdx])._r10
145 mov r11, (EFI_JUMP_BUFFER PTR [rdx])._r11
146 mov r12, (EFI_JUMP_BUFFER PTR [rdx])._r12
147 mov r13, (EFI_JUMP_BUFFER PTR [rdx])._r13
148 mov r14, (EFI_JUMP_BUFFER PTR [rdx])._r14
149 mov r15, (EFI_JUMP_BUFFER PTR [rdx])._r15
150 add rsp, 8 ;pop the eip
151 jmp QWORD PTR (EFI_JUMP_BUFFER PTR [rdx])._rip
152 ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
153 mov rax, EFI_WARN_RETURN_FROM_LONG_JUMP
154 ret
155 TransferControlLongJump ENDP
156
157 text ENDS
158 END