]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/Sec/Ia32/Stack.S
Use PCD for PMM size and EndOpromShadowAddress to remove hard code value in CSM module.
[mirror_edk2.git] / UnixPkg / Sec / Ia32 / Stack.S
CommitLineData
ccd55824 1#------------------------------------------------------------------------------\r
2#\r
f9b8ab56
HT
3# Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>\r
4# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
5# This program and the accompanying materials\r
ccd55824 6# are licensed and made available under the terms and conditions of the BSD License\r
7# which accompanies this distribution. The full text of the license may be found at\r
8# http://opensource.org/licenses/bsd-license.php\r
9#\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12#\r
13# Module Name:\r
14#\r
15# Stack.asm\r
16#\r
17# Abstract:\r
18#\r
19# Switch the stack from temporary memory to permenent memory.\r
20#\r
21#------------------------------------------------------------------------------\r
22\r
23#------------------------------------------------------------------------------\r
24# VOID\r
25# EFIAPI\r
26# SecSwitchStack (\r
27# UINT32 TemporaryMemoryBase,\r
28# UINT32 PermenentMemoryBase\r
29# );\r
30#------------------------------------------------------------------------------ \r
31\r
32#include <ProcessorBind.h>\r
33\r
34ASM_GLOBAL ASM_PFX(SecSwitchStack)\r
35ASM_PFX(SecSwitchStack):\r
36#\r
37# Save three register: eax, ebx, ecx\r
38# \r
39 push %eax\r
40 push %ebx\r
41 push %ecx\r
42 push %edx\r
43 \r
44#\r
45# !!CAUTION!! this function address's is pushed into stack after\r
46# migration of whole temporary memory, so need save it to permenent\r
47# memory at first!\r
48# \r
49 \r
50 movl 20(%esp), %ebx # Save the first parameter\r
51 movl 24(%esp), %ecx # Save the second parameter\r
52 \r
53#\r
54# Save this function's return address into permenent memory at first.\r
55# Then, Fixup the esp point to permenent memory\r
56#\r
57\r
58 movl %esp, %eax\r
59 subl %ebx, %eax\r
60 addl %ecx, %eax\r
61 movl (%esp), %edx # copy pushed register's value to permenent memory\r
62 movl %edx, (%eax)\r
63 movl 4(%esp), %edx\r
64 movl %edx, 4(%eax)\r
65 movl 8(%esp), %edx\r
66 movl %edx, 8(%eax)\r
67 movl 12(%esp), %edx\r
68 movl %edx, 12(%eax)\r
69 movl 16(%esp), %edx\r
70 movl %edx, 16(%eax)\r
71 movl %eax, %esp # From now, esp is pointed to permenent memory\r
72\r
73#\r
74# Fixup the ebp point to permenent memory\r
75#\r
76#ifndef __APPLE__\r
77 movl %ebp, %eax\r
78 subl %ebx, %eax\r
79 addl %ecx, %eax\r
80 movl %eax, %ebp # From now, ebp is pointed to permenent memory\r
81 \r
82#\r
83# Fixup callee's ebp point for PeiDispatch\r
84# \r
85 movl (%ebp), %eax\r
86 subl %ebx, %eax\r
87 addl %ecx, %eax\r
88 movl %eax, (%ebp) # From now, Temporary's PPI caller's stack is in permenent memory\r
89#endif \r
90 \r
91 pop %edx\r
92 pop %ecx\r
93 pop %ebx\r
94 pop %eax\r
95 ret\r