]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/Sec/Ia32/SwitchRam.S
EmulatorPkg: Remove all trailing whitespace
[mirror_edk2.git] / EmulatorPkg / Sec / Ia32 / SwitchRam.S
CommitLineData
112a857f 1#------------------------------------------------------------------------------\r
2#\r
3# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
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# Module Name:\r
13#\r
14# Stack.asm\r
15#\r
16# Abstract:\r
17#\r
18# Switch the stack from temporary memory to permenent memory.\r
19#\r
20#------------------------------------------------------------------------------\r
21\r
22 .text\r
d18d8a1d 23\r
112a857f 24\r
112a857f 25//------------------------------------------------------------------------------\r
26// VOID\r
27// EFIAPI\r
28// SecSwitchStack (\r
29// UINT32 TemporaryMemoryBase,\r
30// UINT32 PermenentMemoryBase\r
31// )//\r
d18d8a1d 32//------------------------------------------------------------------------------\r
aac0fea7 33ASM_GLOBAL ASM_PFX(SecSwitchStack)\r
34ASM_PFX(SecSwitchStack):\r
35#\r
36# Save three register: eax, ebx, ecx\r
d18d8a1d 37#\r
112a857f 38 push %eax\r
39 push %ebx\r
40 push %ecx\r
41 push %edx\r
d18d8a1d 42\r
aac0fea7 43#\r
44# !!CAUTION!! this function address's is pushed into stack after\r
45# migration of whole temporary memory, so need save it to permenent\r
46# memory at first!\r
d18d8a1d 47#\r
48\r
aac0fea7 49 movl 20(%esp), %ebx # Save the first parameter\r
50 movl 24(%esp), %ecx # Save the second parameter\r
d18d8a1d 51\r
aac0fea7 52#\r
53# Save this function's return address into permenent memory at first.\r
54# Then, Fixup the esp point to permenent memory\r
55#\r
56\r
57 movl %esp, %eax\r
58 subl %ebx, %eax\r
59 addl %ecx, %eax\r
60 movl (%esp), %edx # copy pushed register's value to permenent memory\r
61 movl %edx, (%eax)\r
62 movl 4(%esp), %edx\r
63 movl %edx, 4(%eax)\r
64 movl 8(%esp), %edx\r
65 movl %edx, 8(%eax)\r
66 movl 12(%esp), %edx\r
67 movl %edx, 12(%eax)\r
68 movl 16(%esp), %edx\r
69 movl %edx, 16(%eax)\r
70 movl %eax, %esp # From now, esp is pointed to permenent memory\r
71\r
72#\r
73# Fixup the ebp point to permenent memory\r
74#\r
75#ifndef __APPLE__\r
76 movl %ebp, %eax\r
77 subl %ebx, %eax\r
78 addl %ecx, %eax\r
79 movl %eax, %ebp # From now, ebp is pointed to permenent memory\r
d18d8a1d 80\r
aac0fea7 81#\r
82# Fixup callee's ebp point for PeiDispatch\r
d18d8a1d 83#\r
aac0fea7 84 movl (%ebp), %eax\r
85 subl %ebx, %eax\r
86 addl %ecx, %eax\r
87 movl %eax, (%ebp) # From now, Temporary's PPI caller's stack is in permenent memory\r
d18d8a1d 88#endif\r
89\r
112a857f 90 pop %edx\r
91 pop %ecx\r
92 pop %ebx\r
93 pop %eax\r
94 ret\r
aac0fea7 95\r