]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFspPkg/FspSecCore/Ia32/Stacks.s
rename XXXDflt to XXXDefault (expand for better readability)
[mirror_edk2.git] / IntelFspPkg / FspSecCore / Ia32 / Stacks.s
CommitLineData
c8ec22a2
JY
1#------------------------------------------------------------------------------\r
2#\r
d5fb1edf 3# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
c8ec22a2
JY
4# This program and the accompanying materials\r
5# are licensed and made available under the terms and conditions of the BSD License\r
6# which accompanies this distribution. The full text of the license may be found at\r
7# http://opensource.org/licenses/bsd-license.php.\r
8#\r
9# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11#\r
12# Abstract:\r
13#\r
14# Switch the stack from temporary memory to permenent memory.\r
15#\r
16#------------------------------------------------------------------------------\r
17\r
18ASM_GLOBAL ASM_PFX(SecSwitchStack)\r
19\r
20#------------------------------------------------------------------------------\r
21# VOID\r
22# EFIAPI\r
23# SecSwitchStack (\r
24# UINT32 TemporaryMemoryBase,\r
25# UINT32 PermenentMemoryBase\r
26# )\r
27#------------------------------------------------------------------------------\r
28ASM_GLOBAL ASM_PFX(SecSwitchStack)\r
29ASM_PFX(SecSwitchStack):\r
30#\r
d5fb1edf 31# Save four registers: eax, ebx, ecx, edx\r
c8ec22a2 32#\r
d5fb1edf
JY
33 pushl %eax\r
34 pushl %ebx\r
35 pushl %ecx\r
36 pushl %edx\r
c8ec22a2
JY
37\r
38#\r
39# !!CAUTION!! this function address's is pushed into stack after\r
40# migration of whole temporary memory, so need save it to permenent\r
41# memory at first!\r
42#\r
43\r
44 movl 20(%esp), %ebx # Save the first parameter\r
45 movl 24(%esp), %ecx # Save the second parameter\r
46\r
47#\r
48# Save this function's return address into permenent memory at first.\r
49# Then, Fixup the esp point to permenent memory\r
50#\r
51\r
52 movl %esp, %eax\r
53 subl %ebx, %eax\r
54 addl %ecx, %eax\r
55 movl (%esp), %edx # copy pushed register's value to permenent memory\r
56 movl %edx, (%eax)\r
57 movl 4(%esp), %edx\r
58 movl %edx, 4(%eax)\r
59 movl 8(%esp), %edx\r
60 movl %edx, 8(%eax)\r
61 movl 12(%esp), %edx\r
62 movl %edx, 12(%eax)\r
63 movl 16(%esp), %edx # Update this function's return address into permenent memory\r
64 movl %edx, 16(%eax)\r
65 movl %eax, %esp # From now, esp is pointed to permenent memory\r
66\r
67#\r
68# Fixup the ebp point to permenent memory\r
69#\r
c8ec22a2
JY
70 movl %ebp, %eax\r
71 subl %ebx, %eax\r
72 addl %ecx, %eax\r
73 movl %eax, %ebp # From now, ebp is pointed to permenent memory\r
74\r
75#\r
76# Fixup callee's ebp point for PeiDispatch\r
77#\r
d5fb1edf
JY
78# movl %ebp, %eax\r
79# subl %ebx, %eax\r
80# addl %ecx, %eax\r
81# movl %eax, %ebp # From now, ebp is pointed to permenent memory\r
82 popl %edx\r
83 popl %ecx\r
84 popl %ebx\r
85 popl %eax \r
c8ec22a2 86 ret