1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
#
# Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# ProcessorAsms.Asm
#
#
#
#include "EfiBind.h"
#------------------------------------------------------------------------------
.686P:
.MMX:
#.MODEL SMALL
.CODE:
#------------------------------------------------------------------------------
.globl ASM_PFX(TransferControlSetJump)
.globl ASM_PFX(TransferControlLongJump)
.globl ASM_PFX(SwitchStacks)
.globl ASM_PFX(SwitchIplStacks)
#define EFI_SUCCESS 0
#define EFI_WARN_RETURN_FROM_LONG_JUMP 5
#
# typedef struct {
# UINT32 ebx;
# UINT32 esi;
# UINT32 edi;
# UINT32 ebp;
# UINT32 esp;
# UINT32 eip;
#} EFI_JUMP_BUFFER;
#
#typedef
#EFI_STATUS
#(EFIAPI *EFI_PEI_TRANSFER_CONTROL_SET_JUMP) (
# IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
# OUT EFI_JUMP_BUFFER *Context
# );
#
#Routine Description:
#
# This routine implements the IA32 variant of the SetJump call. Its
# responsibility is to store system state information for a possible
# subsequent LongJump.
#
#Arguments:
#
# Pointer to CPU context save buffer.
#
#Returns:
#
# EFI_SUCCESS
#
ASM_PFX(TransferControlSetJump):
push %ebp
mov %esp,%ebp
mov 0x8(%ebp),%eax
mov 0xc(%ebp),%ecx
mov %ebx,(%ecx)
mov %esi,0x4(%ecx)
mov %edi,0x8(%ecx)
mov 0x0(%ebp),%eax
mov %eax,0xc(%ecx)
lea 0x4(%ebp),%eax
mov %eax,0x10(%ecx)
mov 0x4(%ebp),%eax
mov %eax,0x14(%ecx)
mov $0x0,%eax
leave
ret
#typedef
#EFI_STATUS
#(EFIAPI *EFI_PEI_TRANSFER_CONTROL_LONG_JUMP) (
# IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
# IN EFI_JUMP_BUFFER *Context
# );
#
# Routine Description:
#
# This routine implements the IA32 variant of the LongJump call. Its
# responsibility is restore the system state to the Context Buffer and
# pass control back.
#
# Arguments:
#
# Pointer to CPU context save buffer.
#
# Returns:
#
# EFI_WARN_RETURN_FROM_LONG_JUMP
#
ASM_PFX(TransferControlLongJump):
push %ebp
mov %esp,%ebp
push %ebx
push %esi
push %edi
mov 0x8(%ebp),%eax
mov $0x5,%eax
mov 0xc(%ebp),%ecx
mov (%ecx),%ebx
mov 0x4(%ecx),%esi
mov 0x8(%ecx),%edi
mov 0xc(%ecx),%ebp
mov 0x10(%ecx),%esp
add $0x4,%esp
jmp *0x14(%ecx)
mov $0x5,%eax
pop %edi
pop %esi
pop %ebx
leave
ret
#
# Routine Description:
# This allows the caller to switch the stack and goes to the new entry point
#
# Arguments:
# EntryPoint - Pointer to the location to enter
# Parameter - Parameter to pass in
# NewStack - New Location of the stack
# NewBsp - New BSP
#
# Returns:
#
# Nothing. Goes to the Entry Point passing in the new parameters
#
#SwitchStacks PROC C \
# EntryPoint:PTR DWORD, \
# Parameter:DWORD, \
# NewStack:PTR DWORD, \
# NewBsp:PTR DWORD
ASM_PFX(SwitchStacks):
push %ebp
mov %esp,%ebp
push %ebx
mov 0x14(%ebp),%eax
mov 0xc(%ebp),%ebx
mov 0x8(%ebp),%ecx
mov 0x10(%ebp),%eax
mov %eax,%esp
push %ebx
push $0x0
jmp *%ecx
pop %ebx
leave
ret
#
# Routine Description:
# This allows the caller to switch the stack and goes to the new entry point
#
# Arguments:
# EntryPoint - Pointer to the location to enter
# Parameter1/Parameter2 - Parameter to pass in
# NewStack - New Location of the stack
# NewBsp - New BSP
#
# Returns:
#
# Nothing. Goes to the Entry Point passing in the new parameters
#
#SwitchIplStacks PROC C \
# EntryPoint:PTR DWORD, \
# Parameter1:DWORD, \
# Parameter2:DWORD, \
# NewStack:PTR DWORD, \
# NewBsp:PTR DWORD
ASM_PFX(SwitchIplStacks):
push %ebp
mov %esp,%ebp
push %ebx
mov 0x18(%ebp),%eax
mov 0xc(%ebp),%ebx
mov 0x10(%ebp),%edx
mov 0x8(%ebp),%ecx
mov 0x14(%ebp),%eax
mov %eax,%esp
push %edx
push %ebx
call *%ecx
pop %ebx
leave
ret
#SwitchIplStacks ENDP
|