]> git.proxmox.com Git - mirror_edk2.git/blame - CorebootModulePkg/SecCore/Ia32/Stack.asm
CorebootModulePkg: Fix various typos
[mirror_edk2.git] / CorebootModulePkg / SecCore / Ia32 / Stack.asm
CommitLineData
fce4ecd9
MM
1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2013, 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
06516768 14; Switch the stack from temporary memory to permanent memory.\r
fce4ecd9
MM
15;\r
16;------------------------------------------------------------------------------\r
17\r
18 .586p\r
19 .model flat,C\r
20 .code\r
21 \r
22;------------------------------------------------------------------------------\r
23; VOID\r
24; EFIAPI\r
25; SecSwitchStack (\r
26; UINT32 TemporaryMemoryBase,\r
27; UINT32 PermenentMemoryBase\r
28; );\r
29;------------------------------------------------------------------------------ \r
30SecSwitchStack PROC\r
31 ;\r
32 ; Save three register: eax, ebx, ecx\r
33 ;\r
34 push eax\r
35 push ebx\r
36 push ecx\r
37 push edx\r
38 \r
39 ;\r
40 ; !!CAUTION!! this function address's is pushed into stack after\r
06516768 41 ; migration of whole temporary memory, so need save it to permanent\r
fce4ecd9
MM
42 ; memory at first!\r
43 ;\r
44 \r
45 mov ebx, [esp + 20] ; Save the first parameter\r
46 mov ecx, [esp + 24] ; Save the second parameter\r
47 \r
48 ;\r
06516768
AC
49 ; Save this function's return address into permanent memory at first.\r
50 ; Then, Fixup the esp point to permanent memory\r
fce4ecd9
MM
51 ;\r
52 mov eax, esp\r
53 sub eax, ebx\r
54 add eax, ecx\r
06516768 55 mov edx, dword ptr [esp] ; copy pushed register's value to permanent memory\r
fce4ecd9
MM
56 mov dword ptr [eax], edx \r
57 mov edx, dword ptr [esp + 4]\r
58 mov dword ptr [eax + 4], edx \r
59 mov edx, dword ptr [esp + 8]\r
60 mov dword ptr [eax + 8], edx \r
61 mov edx, dword ptr [esp + 12]\r
62 mov dword ptr [eax + 12], edx \r
06516768 63 mov edx, dword ptr [esp + 16] ; Update this function's return address into permanent memory\r
fce4ecd9 64 mov dword ptr [eax + 16], edx \r
06516768 65 mov esp, eax ; From now, esp is pointed to permanent memory\r
fce4ecd9
MM
66 \r
67 ;\r
06516768 68 ; Fixup the ebp point to permanent memory\r
fce4ecd9
MM
69 ;\r
70 mov eax, ebp\r
71 sub eax, ebx\r
72 add eax, ecx\r
06516768 73 mov ebp, eax ; From now, ebp is pointed to permanent memory\r
fce4ecd9
MM
74 \r
75 pop edx\r
76 pop ecx\r
77 pop ebx\r
78 pop eax\r
79 ret\r
80SecSwitchStack ENDP\r
81\r
82 END\r