]> git.proxmox.com Git - mirror_edk2.git/blame - CorebootModulePkg/SecCore/Ia32/Stack.S
CorebootModulePkg: Fix various typos
[mirror_edk2.git] / CorebootModulePkg / SecCore / Ia32 / Stack.S
CommitLineData
fce4ecd9
MM
1#------------------------------------------------------------------------------
2#
3# Copyright (c) 2013, 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#
06516768 14# Switch the stack from temporary memory to permanent memory.\r
fce4ecd9
MM
15#
16#------------------------------------------------------------------------------
17
18
19#------------------------------------------------------------------------------
20# VOID
21# EFIAPI
22# SecSwitchStack (
23# UINT32 TemporaryMemoryBase,
24# UINT32 PermenentMemoryBase
25# )#
26#------------------------------------------------------------------------------
27ASM_GLOBAL ASM_PFX (SecSwitchStack)
28ASM_PFX(SecSwitchStack):
29 #
30 # Save standard registers so they can be used to change stack
31 #
32 pushl %eax
33 pushl %ebx
34 pushl %ecx
35 pushl %edx
36
37 #
38 # !!CAUTION!! this function address's is pushed into stack after
06516768 39 # migration of whole temporary memory, so need save it to permanent\r
fce4ecd9
MM
40 # memory at first!
41 #
42 movl 20(%esp), %ebx # Save the first parameter
43 movl 24(%esp), %ecx # Save the second parameter
44
45 #
06516768
AC
46 # Save this function's return address into permanent memory at first.\r
47 # Then, Fixup the esp point to permanent memory\r
fce4ecd9
MM
48 #
49 movl %esp, %eax
50 subl %ebx, %eax
51 addl %ecx, %eax
06516768 52 movl 0(%esp), %edx # copy pushed register's value to permanent memory\r
fce4ecd9
MM
53 movl %edx, 0(%eax)
54 movl 4(%esp), %edx
55 movl %edx, 4(%eax)
56 movl 8(%esp), %edx
57 movl %edx, 8(%eax)
58 movl 12(%esp), %edx
59 movl %edx, 12(%eax)
06516768 60 movl 16(%esp), %edx # Update this function's return address into permanent memory\r
fce4ecd9 61 movl %edx, 16(%eax)
06516768 62 movl %eax, %esp # From now, esp is pointed to permanent memory\r
fce4ecd9
MM
63
64 #
06516768 65 # Fixup the ebp point to permanent memory\r
fce4ecd9
MM
66 #
67 movl %ebp, %eax
68 subl %ebx, %eax
69 addl %ecx, %eax
06516768 70 movl %eax, %ebp # From now, ebp is pointed to permanent memory\r
fce4ecd9
MM
71
72 popl %edx
73 popl %ecx
74 popl %ebx
75 popl %eax
76 ret
77
78