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
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.
16 ; This is separated from processor.c to allow this functions to be built with /O1
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.
32 EFI_WARN_RETURN_FROM_LONG_JUMP equ 5
35 ; Generated by h2inc run manually
37 _EFI_JUMP_BUFFER STRUCT 2t
46 EFI_JUMP_BUFFER TYPEDEF _EFI_JUMP_BUFFER
48 TransferControlSetJump PROTO C \
49 _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \
50 Jump:PTR EFI_JUMP_BUFFER
52 TransferControlLongJump PROTO C \
53 _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \
54 Jump:PTR EFI_JUMP_BUFFER
56 SwitchStacks PROTO C \
57 EntryPoint:PTR DWORD, \
62 SwitchIplStacks PROTO C \
63 EntryPoint:PTR DWORD, \
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.
78 ; Pointer to CPU context save buffer.
84 TransferControlSetJump PROC C \
85 _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \
86 Jump:PTR EFI_JUMP_BUFFER
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
94 mov (EFI_JUMP_BUFFER PTR [ecx])._ebp, eax
96 mov (EFI_JUMP_BUFFER PTR [ecx])._esp, eax
98 mov (EFI_JUMP_BUFFER PTR [ecx])._eip, eax
103 TransferControlSetJump ENDP
106 ; Routine Description:
108 ; This routine implements the IA32 variant of the LongJump call. Its
109 ; responsibility is restore the system state to the Context Buffer and
114 ; Pointer to CPU context save buffer.
118 ; EFI_WARN_RETURN_FROM_LONG_JUMP
121 TransferControlLongJump PROC C \
122 _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \
123 Jump:PTR EFI_JUMP_BUFFER
130 ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
131 mov eax, EFI_WARN_RETURN_FROM_LONG_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
147 TransferControlLongJump ENDP
150 ; Routine Description:
151 ; This allows the caller to switch the stack and goes to the new entry point
154 ; EntryPoint - Pointer to the location to enter
155 ; Parameter - Parameter to pass in
156 ; NewStack - New Location of the stack
161 ; Nothing. Goes to the Entry Point passing in the new parameters
163 SwitchStacks PROC C \
164 EntryPoint:PTR DWORD, \
166 NewStack:PTR DWORD, \
185 ; Routine Description:
186 ; This allows the caller to switch the stack and goes to the new entry point
189 ; EntryPoint - Pointer to the location to enter
190 ; Parameter1/Parameter2 - Parameter to pass in
191 ; NewStack - New Location of the stack
196 ; Nothing. Goes to the Entry Point passing in the new parameters
198 SwitchIplStacks PROC C \
199 EntryPoint:PTR DWORD, \
202 NewStack:PTR DWORD, \