]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFspPkg/FspSecCore/Ia32/Stacks.s
6c36c25d2b4b8f9ab3b9da7d230892ea5d961028
[mirror_edk2.git] / IntelFspPkg / FspSecCore / Ia32 / Stacks.s
1 #------------------------------------------------------------------------------
2 #
3 # Copyright (c) 2014, 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 permenent memory.
15 #
16 #------------------------------------------------------------------------------
17
18 ASM_GLOBAL ASM_PFX(SecSwitchStack)
19
20 #------------------------------------------------------------------------------
21 # VOID
22 # EFIAPI
23 # SecSwitchStack (
24 # UINT32 TemporaryMemoryBase,
25 # UINT32 PermenentMemoryBase
26 # )
27 #------------------------------------------------------------------------------
28 ASM_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 permenent
41 # memory at first!
42 #
43
44 movl 20(%esp), %ebx # Save the first parameter
45 movl 24(%esp), %ecx # Save the second parameter
46
47 #
48 # Save this function's return address into permenent memory at first.
49 # Then, Fixup the esp point to permenent memory
50 #
51
52 movl %esp, %eax
53 subl %ebx, %eax
54 addl %ecx, %eax
55 movl (%esp), %edx # copy pushed register's value to permenent memory
56 movl %edx, (%eax)
57 movl 4(%esp), %edx
58 movl %edx, 4(%eax)
59 movl 8(%esp), %edx
60 movl %edx, 8(%eax)
61 movl 12(%esp), %edx
62 movl %edx, 12(%eax)
63 movl 16(%esp), %edx # Update this function's return address into permenent memory
64 movl %edx, 16(%eax)
65 movl %eax, %esp # From now, esp is pointed to permenent memory
66
67 #
68 # Fixup the ebp point to permenent memory
69 #
70
71 movl %ebp, %eax
72 subl %ebx, %eax
73 addl %ecx, %eax
74 movl %eax, %ebp # From now, ebp is pointed to permenent memory
75
76 #
77 # Fixup callee's ebp point for PeiDispatch
78 #
79 movl %ebp, %eax
80 subl %ebx, %eax
81 addl %ecx, %eax
82 movl %eax, %ebp # From now, ebp is pointed to permenent memory
83
84 pop %edx
85 pop %ecx
86 pop %ebx
87 pop %eax
88 ret