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