]> git.proxmox.com Git - mirror_edk2.git/blame - CorebootModulePkg/SecCore/Ia32/Stack.asm
CorebootModulePkg: Replace BSD License with BSD+Patent License
[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
f3342b7a 4; SPDX-License-Identifier: BSD-2-Clause-Patent\r
fce4ecd9
MM
5;\r
6; Abstract:\r
7;\r
06516768 8; Switch the stack from temporary memory to permanent memory.\r
fce4ecd9
MM
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
24SecSwitchStack 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
06516768 35 ; migration of whole temporary memory, so need save it to permanent\r
fce4ecd9
MM
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
06516768
AC
43 ; Save this function's return address into permanent memory at first.\r
44 ; Then, Fixup the esp point to permanent memory\r
fce4ecd9
MM
45 ;\r
46 mov eax, esp\r
47 sub eax, ebx\r
48 add eax, ecx\r
06516768 49 mov edx, dword ptr [esp] ; copy pushed register's value to permanent memory\r
fce4ecd9
MM
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
06516768 57 mov edx, dword ptr [esp + 16] ; Update this function's return address into permanent memory\r
fce4ecd9 58 mov dword ptr [eax + 16], edx \r
06516768 59 mov esp, eax ; From now, esp is pointed to permanent memory\r
fce4ecd9
MM
60 \r
61 ;\r
06516768 62 ; Fixup the ebp point to permanent memory\r
fce4ecd9
MM
63 ;\r
64 mov eax, ebp\r
65 sub eax, ebx\r
66 add eax, ecx\r
06516768 67 mov ebp, eax ; From now, ebp is pointed to permanent memory\r
fce4ecd9
MM
68 \r
69 pop edx\r
70 pop ecx\r
71 pop ebx\r
72 pop eax\r
73 ret\r
74SecSwitchStack ENDP\r
75\r
76 END\r