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