]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFspPkg/FspSecCore/Ia32/Stacks.s
DynamicTablesPkg: GTDT updates for ACPI 6.3
[mirror_edk2.git] / IntelFspPkg / FspSecCore / Ia32 / Stacks.s
1 #------------------------------------------------------------------------------
2 #
3 # Copyright (c) 2014 - 2015, 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 ASM_GLOBAL ASM_PFX(SecSwitchStack)
13
14 #------------------------------------------------------------------------------
15 # VOID
16 # EFIAPI
17 # SecSwitchStack (
18 # UINT32 TemporaryMemoryBase,
19 # UINT32 PermenentMemoryBase
20 # )
21 #------------------------------------------------------------------------------
22 ASM_GLOBAL ASM_PFX(SecSwitchStack)
23 ASM_PFX(SecSwitchStack):
24 #
25 # Save four registers: eax, ebx, ecx, edx
26 #
27 pushl %eax
28 pushl %ebx
29 pushl %ecx
30 pushl %edx
31
32 #
33 # !!CAUTION!! this function address's is pushed into stack after
34 # migration of whole temporary memory, so need save it to permenent
35 # memory at first!
36 #
37
38 movl 20(%esp), %ebx # Save the first parameter
39 movl 24(%esp), %ecx # Save the second parameter
40
41 #
42 # Save this function's return address into permenent memory at first.
43 # Then, Fixup the esp point to permenent memory
44 #
45
46 movl %esp, %eax
47 subl %ebx, %eax
48 addl %ecx, %eax
49 movl (%esp), %edx # copy pushed register's value to permenent memory
50 movl %edx, (%eax)
51 movl 4(%esp), %edx
52 movl %edx, 4(%eax)
53 movl 8(%esp), %edx
54 movl %edx, 8(%eax)
55 movl 12(%esp), %edx
56 movl %edx, 12(%eax)
57 movl 16(%esp), %edx # Update this function's return address into permenent memory
58 movl %edx, 16(%eax)
59 movl %eax, %esp # From now, esp is pointed to permenent memory
60
61 #
62 # Fixup the ebp point to permenent memory
63 #
64 movl %ebp, %eax
65 subl %ebx, %eax
66 addl %ecx, %eax
67 movl %eax, %ebp # From now, ebp is pointed to permenent memory
68
69 #
70 # Fixup callee's ebp point for PeiDispatch
71 #
72 # movl %ebp, %eax
73 # subl %ebx, %eax
74 # addl %ecx, %eax
75 # movl %eax, %ebp # From now, ebp is pointed to permenent memory
76 popl %edx
77 popl %ecx
78 popl %ebx
79 popl %eax
80 ret