]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/TianoTools/Common/PeiLib/ia32/ProcessorAsms.Asm
Add <FrameworkModules> in EdkModulePkg-All-Archs.fpd and MdePkg-All-Archs.fpd file...
[mirror_edk2.git] / Tools / Source / TianoTools / Common / PeiLib / ia32 / ProcessorAsms.Asm
CommitLineData
878ddf1f 1;\r
2; Copyright (c) 2004, Intel Corporation \r
3; All rights reserved. This program and the accompanying materials \r
4; are licensed and made available under the terms and conditions of the BSD License \r
5; which accompanies this distribution. The full text of the license may be found at \r
6; http://opensource.org/licenses/bsd-license.php \r
7; \r
8; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
9; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
10; \r
11; Module Name:\r
12; \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; Notes:\r
19; - Masm uses "This", "ebx", etc as a directive.\r
20; - H2INC is still not embedded in our build process so I translated the struc manually.\r
21; - Unreferenced variables/arguments (This, NewBsp, NewStack) were causing compile errors and \r
22; did not know of "pragma" mechanism in MASM and I did not want to reduce the warning level. \r
23; Instead, I did a dummy referenced.\r
24;\r
25\r
26 .686P\r
27 .MMX\r
28 .MODEL SMALL\r
29 .CODE\r
30\r
31EFI_SUCCESS equ 0\r
32EFI_WARN_RETURN_FROM_LONG_JUMP equ 5\r
33\r
34;\r
35; Generated by h2inc run manually\r
36;\r
37_EFI_JUMP_BUFFER STRUCT 2t\r
38_ebx DWORD ?\r
39_esi DWORD ?\r
40_edi DWORD ?\r
41_ebp DWORD ?\r
42_esp DWORD ?\r
43_eip DWORD ?\r
44_EFI_JUMP_BUFFER ENDS\r
45\r
46EFI_JUMP_BUFFER TYPEDEF _EFI_JUMP_BUFFER\r
47\r
48TransferControlSetJump PROTO C \\r
49 _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \\r
50 Jump:PTR EFI_JUMP_BUFFER\r
51\r
52TransferControlLongJump PROTO C \\r
53 _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \\r
54 Jump:PTR EFI_JUMP_BUFFER\r
55\r
56SwitchStacks PROTO C \\r
57 EntryPoint:PTR DWORD, \\r
58 Parameter:DWORD, \\r
59 NewStack:PTR DWORD, \\r
60 NewBsp:PTR DWORD\r
61 \r
62SwitchIplStacks PROTO C \\r
63 EntryPoint:PTR DWORD, \\r
64 Parameter1:DWORD, \\r
65 Parameter2:DWORD, \\r
66 NewStack:PTR DWORD, \\r
67 NewBsp:PTR DWORD\r
68\r
69;\r
70;Routine Description:\r
71;\r
72; This routine implements the IA32 variant of the SetJump call. Its\r
73; responsibility is to store system state information for a possible\r
74; subsequent LongJump.\r
75;\r
76;Arguments:\r
77;\r
78; Pointer to CPU context save buffer.\r
79;\r
80;Returns:\r
81;\r
82; EFI_SUCCESS\r
83;\r
84TransferControlSetJump PROC C \\r
85 _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \\r
86 Jump:PTR EFI_JUMP_BUFFER\r
87 \r
88 mov eax, _This \r
89 mov ecx, Jump\r
90 mov (EFI_JUMP_BUFFER PTR [ecx])._ebx, ebx\r
91 mov (EFI_JUMP_BUFFER PTR [ecx])._esi, esi\r
92 mov (EFI_JUMP_BUFFER PTR [ecx])._edi, edi\r
93 mov eax, [ebp]\r
94 mov (EFI_JUMP_BUFFER PTR [ecx])._ebp, eax\r
95 lea eax, [ebp+4]\r
96 mov (EFI_JUMP_BUFFER PTR [ecx])._esp, eax\r
97 mov eax, [ebp+4]\r
98 mov (EFI_JUMP_BUFFER PTR [ecx])._eip, eax\r
99 mov eax, EFI_SUCCESS\r
100 \r
101 ret\r
102 \r
103TransferControlSetJump ENDP\r
104\r
105;\r
106; Routine Description:\r
107; \r
108; This routine implements the IA32 variant of the LongJump call. Its\r
109; responsibility is restore the system state to the Context Buffer and\r
110; pass control back.\r
111;\r
112; Arguments:\r
113; \r
114; Pointer to CPU context save buffer.\r
115;\r
116; Returns:\r
117;\r
118; EFI_WARN_RETURN_FROM_LONG_JUMP\r
119;\r
120\r
121TransferControlLongJump PROC C \\r
122 _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \\r
123 Jump:PTR EFI_JUMP_BUFFER\r
124\r
125 push ebx\r
126 push esi\r
127 push edi\r
128\r
129 mov eax, _This\r
130 ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP\r
131 mov eax, EFI_WARN_RETURN_FROM_LONG_JUMP \r
132 mov ecx, Jump\r
133 mov ebx, (EFI_JUMP_BUFFER PTR [ecx])._ebx\r
134 mov esi, (EFI_JUMP_BUFFER PTR [ecx])._esi\r
135 mov edi, (EFI_JUMP_BUFFER PTR [ecx])._edi\r
136 mov ebp, (EFI_JUMP_BUFFER PTR [ecx])._ebp\r
137 mov esp, (EFI_JUMP_BUFFER PTR [ecx])._esp\r
138 add esp, 4 ;pop the eip\r
139 jmp DWORD PTR (EFI_JUMP_BUFFER PTR [ecx])._eip\r
140 mov eax, EFI_WARN_RETURN_FROM_LONG_JUMP\r
141 \r
142 pop edi\r
143 pop esi\r
144 pop ebx\r
145 ret\r
146 \r
147TransferControlLongJump ENDP\r
148\r
149;\r
150; Routine Description:\r
151; This allows the caller to switch the stack and goes to the new entry point\r
152;\r
153; Arguments:\r
154; EntryPoint - Pointer to the location to enter\r
155; Parameter - Parameter to pass in\r
156; NewStack - New Location of the stack\r
157; NewBsp - New BSP\r
158;\r
159; Returns:\r
160;\r
161; Nothing. Goes to the Entry Point passing in the new parameters\r
162;\r
163SwitchStacks PROC C \\r
164 EntryPoint:PTR DWORD, \\r
165 Parameter:DWORD, \\r
166 NewStack:PTR DWORD, \\r
167 NewBsp:PTR DWORD\r
168 \r
169 push ebx\r
170 mov eax, NewBsp\r
171 mov ebx, Parameter\r
172 mov ecx, EntryPoint\r
173 mov eax, NewStack\r
174 mov esp, eax\r
175 push ebx\r
176 push 0\r
177 jmp ecx\r
178 \r
179 pop ebx\r
180 ret\r
181 \r
182SwitchStacks ENDP\r
183\r
184;\r
185; Routine Description:\r
186; This allows the caller to switch the stack and goes to the new entry point\r
187;\r
188; Arguments:\r
189; EntryPoint - Pointer to the location to enter\r
190; Parameter1/Parameter2 - Parameter to pass in\r
191; NewStack - New Location of the stack\r
192; NewBsp - New BSP\r
193;\r
194; Returns:\r
195;\r
196; Nothing. Goes to the Entry Point passing in the new parameters\r
197;\r
198SwitchIplStacks PROC C \\r
199 EntryPoint:PTR DWORD, \\r
200 Parameter1:DWORD, \\r
201 Parameter2:DWORD, \\r
202 NewStack:PTR DWORD, \\r
203 NewBsp:PTR DWORD\r
204 \r
205 push ebx\r
206 mov eax, NewBsp \r
207 mov ebx, Parameter1\r
208 mov edx, Parameter2\r
209 mov ecx, EntryPoint\r
210 mov eax, NewStack\r
211 mov esp, eax\r
212\r
213 push edx\r
214 push ebx\r
215 call ecx\r
216 \r
217 pop ebx\r
218 ret\r
219 \r
220SwitchIplStacks ENDP\r
221\r
222 END\r
223\r