]>
Commit | Line | Data |
---|---|---|
a33a2f62 JY |
1 | ;------------------------------------------------------------------------------\r |
2 | ;\r | |
3 | ; Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r | |
19486360 | 4 | ; SPDX-License-Identifier: BSD-2-Clause-Patent\r |
a33a2f62 JY |
5 | ;\r |
6 | ; Abstract:\r | |
7 | ;\r | |
8 | ; Switch the stack from temporary memory to permenent memory.\r | |
9 | ;\r | |
10 | ;------------------------------------------------------------------------------\r | |
11 | \r | |
12 | .586p\r | |
13 | .model flat,C\r | |
14 | .code\r | |
15 | \r | |
16 | ;------------------------------------------------------------------------------\r | |
17 | ; VOID\r | |
18 | ; EFIAPI\r | |
19 | ; SecSwitchStack (\r | |
20 | ; UINT32 TemporaryMemoryBase,\r | |
21 | ; UINT32 PermenentMemoryBase\r | |
22 | ; );\r | |
23 | ;------------------------------------------------------------------------------\r | |
24 | SecSwitchStack PROC\r | |
25 | ;\r | |
26 | ; Save three register: eax, ebx, ecx\r | |
27 | ;\r | |
28 | push eax\r | |
29 | push ebx\r | |
30 | push ecx\r | |
31 | push edx\r | |
32 | \r | |
33 | ;\r | |
34 | ; !!CAUTION!! this function address's is pushed into stack after\r | |
35 | ; migration of whole temporary memory, so need save it to permenent\r | |
36 | ; memory at first!\r | |
37 | ;\r | |
38 | \r | |
39 | mov ebx, [esp + 20] ; Save the first parameter\r | |
40 | mov ecx, [esp + 24] ; Save the second parameter\r | |
41 | \r | |
42 | ;\r | |
43 | ; Save this function's return address into permenent memory at first.\r | |
44 | ; Then, Fixup the esp point to permenent memory\r | |
45 | ;\r | |
46 | mov eax, esp\r | |
47 | sub eax, ebx\r | |
48 | add eax, ecx\r | |
49 | mov edx, dword ptr [esp] ; copy pushed register's value to permenent memory\r | |
50 | mov dword ptr [eax], edx\r | |
51 | mov edx, dword ptr [esp + 4]\r | |
52 | mov dword ptr [eax + 4], edx\r | |
53 | mov edx, dword ptr [esp + 8]\r | |
54 | mov dword ptr [eax + 8], edx\r | |
55 | mov edx, dword ptr [esp + 12]\r | |
56 | mov dword ptr [eax + 12], edx\r | |
57 | mov edx, dword ptr [esp + 16] ; Update this function's return address into permenent memory\r | |
58 | mov dword ptr [eax + 16], edx\r | |
59 | mov esp, eax ; From now, esp is pointed to permenent memory\r | |
60 | \r | |
61 | ;\r | |
62 | ; Fixup the ebp point to permenent memory\r | |
63 | ;\r | |
64 | mov eax, ebp\r | |
65 | sub eax, ebx\r | |
66 | add eax, ecx\r | |
67 | mov ebp, eax ; From now, ebp is pointed to permenent memory\r | |
68 | \r | |
69 | pop edx\r | |
70 | pop ecx\r | |
71 | pop ebx\r | |
72 | pop eax\r | |
73 | ret\r | |
74 | SecSwitchStack ENDP\r | |
75 | \r | |
76 | END\r |