]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/Ia32/Stack.nasm
SecurityPkg/Tcg2Smm: Measure the table before patch.
[mirror_edk2.git] / IntelFsp2WrapperPkg / Library / SecFspWrapperPlatformSecLibSample / Ia32 / Stack.nasm
CommitLineData
2d24f4e7
LG
1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
512e23a3 4; SPDX-License-Identifier: BSD-2-Clause-Patent\r
2d24f4e7
LG
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 SECTION .text\r
13\r
14;------------------------------------------------------------------------------\r
15; VOID\r
16; EFIAPI\r
17; SecSwitchStack (\r
18; UINT32 TemporaryMemoryBase,\r
19; UINT32 PermanentMemoryBase\r
20; );\r
21;------------------------------------------------------------------------------\r
22global ASM_PFX(SecSwitchStack)\r
23ASM_PFX(SecSwitchStack):\r
24 ;\r
25 ; Save three register: eax, ebx, ecx\r
26 ;\r
27 push eax\r
28 push ebx\r
29 push ecx\r
30 push edx\r
31\r
32 ;\r
33 ; !!CAUTION!! this function address's is pushed into stack after\r
34 ; migration of whole temporary memory, so need save it to permanent\r
35 ; memory at first!\r
36 ;\r
37\r
38 mov ebx, [esp + 20] ; Save the first parameter\r
39 mov ecx, [esp + 24] ; Save the second parameter\r
40\r
41 ;\r
42 ; Save this function's return address into permanent memory at first.\r
43 ; Then, Fixup the esp point to permanent memory\r
44 ;\r
45 mov eax, esp\r
46 sub eax, ebx\r
47 add eax, ecx\r
48 mov edx, dword [esp] ; copy pushed register's value to permanent memory\r
49 mov dword [eax], edx\r
50 mov edx, dword [esp + 4]\r
51 mov dword [eax + 4], edx\r
52 mov edx, dword [esp + 8]\r
53 mov dword [eax + 8], edx\r
54 mov edx, dword [esp + 12]\r
55 mov dword [eax + 12], edx\r
56 mov edx, dword [esp + 16] ; Update this function's return address into permanent memory\r
57 mov dword [eax + 16], edx\r
58 mov esp, eax ; From now, esp is pointed to permanent memory\r
59\r
60 ;\r
61 ; Fixup the ebp point to permanent memory\r
62 ;\r
63 mov eax, ebp\r
64 sub eax, ebx\r
65 add eax, ecx\r
66 mov ebp, eax ; From now, ebp is pointed to permanent memory\r
67\r
68 pop edx\r
69 pop ecx\r
70 pop ebx\r
71 pop eax\r
72 ret\r
73\r