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