]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFspPkg/FspSecCore/Ia32/Stack.asm
DynamicTablesPkg: GTDT updates for ACPI 6.3
[mirror_edk2.git] / IntelFspPkg / FspSecCore / Ia32 / Stack.asm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
5 ;
6 ; Abstract:
7 ;
8 ; Switch the stack from temporary memory to permenent memory.
9 ;
10 ;------------------------------------------------------------------------------
11
12 .586p
13 .model flat,C
14 .code
15
16 ;------------------------------------------------------------------------------
17 ; VOID
18 ; EFIAPI
19 ; SecSwitchStack (
20 ; UINT32 TemporaryMemoryBase,
21 ; UINT32 PermenentMemoryBase
22 ; );
23 ;------------------------------------------------------------------------------
24 SecSwitchStack PROC
25 ;
26 ; Save three register: eax, ebx, ecx
27 ;
28 push eax
29 push ebx
30 push ecx
31 push edx
32
33 ;
34 ; !!CAUTION!! this function address's is pushed into stack after
35 ; migration of whole temporary memory, so need save it to permenent
36 ; memory at first!
37 ;
38
39 mov ebx, [esp + 20] ; Save the first parameter
40 mov ecx, [esp + 24] ; Save the second parameter
41
42 ;
43 ; Save this function's return address into permenent memory at first.
44 ; Then, Fixup the esp point to permenent memory
45 ;
46 mov eax, esp
47 sub eax, ebx
48 add eax, ecx
49 mov edx, dword ptr [esp] ; copy pushed register's value to permenent memory
50 mov dword ptr [eax], edx
51 mov edx, dword ptr [esp + 4]
52 mov dword ptr [eax + 4], edx
53 mov edx, dword ptr [esp + 8]
54 mov dword ptr [eax + 8], edx
55 mov edx, dword ptr [esp + 12]
56 mov dword ptr [eax + 12], edx
57 mov edx, dword ptr [esp + 16] ; Update this function's return address into permenent memory
58 mov dword ptr [eax + 16], edx
59 mov esp, eax ; From now, esp is pointed to permenent memory
60
61 ;
62 ; Fixup the ebp point to permenent memory
63 ;
64 mov eax, ebp
65 sub eax, ebx
66 add eax, ecx
67 mov ebp, eax ; From now, ebp is pointed to permenent memory
68
69 pop edx
70 pop ecx
71 pop ebx
72 pop eax
73 ret
74 SecSwitchStack ENDP
75
76 END