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