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