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