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