]>
Commit | Line | Data |
---|---|---|
2d24f4e7 LG |
1 | ;------------------------------------------------------------------------------\r |
2 | ;\r | |
3 | ; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r | |
4 | ; This program and the accompanying materials\r | |
5 | ; are licensed and made available under the terms and conditions of the BSD License\r | |
6 | ; which accompanies this distribution. The full text of the license may be found at\r | |
7 | ; http://opensource.org/licenses/bsd-license.php.\r | |
8 | ;\r | |
9 | ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | ;\r | |
12 | ; Abstract:\r | |
13 | ;\r | |
14 | ; Switch the stack from temporary memory to permenent memory.\r | |
15 | ;\r | |
16 | ;------------------------------------------------------------------------------\r | |
17 | \r | |
18 | SECTION .text\r | |
19 | \r | |
20 | ;------------------------------------------------------------------------------\r | |
21 | ; VOID\r | |
22 | ; EFIAPI\r | |
23 | ; SecSwitchStack (\r | |
24 | ; UINT32 TemporaryMemoryBase,\r | |
25 | ; UINT32 PermanentMemoryBase\r | |
26 | ; );\r | |
27 | ;------------------------------------------------------------------------------\r | |
28 | global ASM_PFX(SecSwitchStack)\r | |
29 | ASM_PFX(SecSwitchStack):\r | |
30 | ;\r | |
31 | ; Save three register: eax, ebx, ecx\r | |
32 | ;\r | |
33 | push eax\r | |
34 | push ebx\r | |
35 | push ecx\r | |
36 | push edx\r | |
37 | \r | |
38 | ;\r | |
39 | ; !!CAUTION!! this function address's is pushed into stack after\r | |
40 | ; migration of whole temporary memory, so need save it to permanent\r | |
41 | ; memory at first!\r | |
42 | ;\r | |
43 | \r | |
44 | mov ebx, [esp + 20] ; Save the first parameter\r | |
45 | mov ecx, [esp + 24] ; Save the second parameter\r | |
46 | \r | |
47 | ;\r | |
48 | ; Save this function's return address into permanent memory at first.\r | |
49 | ; Then, Fixup the esp point to permanent memory\r | |
50 | ;\r | |
51 | mov eax, esp\r | |
52 | sub eax, ebx\r | |
53 | add eax, ecx\r | |
54 | mov edx, dword [esp] ; copy pushed register's value to permanent memory\r | |
55 | mov dword [eax], edx\r | |
56 | mov edx, dword [esp + 4]\r | |
57 | mov dword [eax + 4], edx\r | |
58 | mov edx, dword [esp + 8]\r | |
59 | mov dword [eax + 8], edx\r | |
60 | mov edx, dword [esp + 12]\r | |
61 | mov dword [eax + 12], edx\r | |
62 | mov edx, dword [esp + 16] ; Update this function's return address into permanent memory\r | |
63 | mov dword [eax + 16], edx\r | |
64 | mov esp, eax ; From now, esp is pointed to permanent memory\r | |
65 | \r | |
66 | ;\r | |
67 | ; Fixup the ebp point to permanent memory\r | |
68 | ;\r | |
69 | mov eax, ebp\r | |
70 | sub eax, ebx\r | |
71 | add eax, ecx\r | |
72 | mov ebp, eax ; From now, ebp is pointed to permanent memory\r | |
73 | \r | |
74 | pop edx\r | |
75 | pop ecx\r | |
76 | pop ebx\r | |
77 | pop eax\r | |
78 | ret\r | |
79 | \r |