]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFspWrapperPkg/Library/SecPeiFspPlatformSecLibSample/Ia32/Stack.S
IntelFspWrapperPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFspWrapperPkg / Library / SecPeiFspPlatformSecLibSample / Ia32 / Stack.S
CommitLineData
a33a2f62
JY
1#------------------------------------------------------------------------------\r
2#\r
3# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
19486360 4# SPDX-License-Identifier: BSD-2-Clause-Patent\r
a33a2f62
JY
5#\r
6# Abstract:\r
7#\r
8# Switch the stack from temporary memory to permenent memory.\r
9#\r
10#------------------------------------------------------------------------------\r
11\r
12\r
13#------------------------------------------------------------------------------\r
14# VOID\r
15# EFIAPI\r
16# SecSwitchStack (\r
17# UINT32 TemporaryMemoryBase,\r
18# UINT32 PermenentMemoryBase\r
19# )#\r
20#------------------------------------------------------------------------------\r
21ASM_GLOBAL ASM_PFX (SecSwitchStack)\r
22ASM_PFX(SecSwitchStack):\r
23 #\r
24 # Save standard registers so they can be used to change stack\r
25 #\r
26 pushl %eax\r
27 pushl %ebx\r
28 pushl %ecx\r
29 pushl %edx\r
30\r
31 #\r
32 # !!CAUTION!! this function address's is pushed into stack after\r
33 # migration of whole temporary memory, so need save it to permenent\r
34 # memory at first!\r
35 #\r
36 movl 20(%esp), %ebx # Save the first parameter\r
37 movl 24(%esp), %ecx # Save the second parameter\r
38\r
39 #\r
40 # Save this function's return address into permenent memory at first.\r
41 # Then, Fixup the esp point to permenent memory\r
42 #\r
43 movl %esp, %eax\r
44 subl %ebx, %eax\r
45 addl %ecx, %eax\r
46 movl 0(%esp), %edx # copy pushed register's value to permenent memory\r
47 movl %edx, 0(%eax)\r
48 movl 4(%esp), %edx\r
49 movl %edx, 4(%eax)\r
50 movl 8(%esp), %edx\r
51 movl %edx, 8(%eax)\r
52 movl 12(%esp), %edx\r
53 movl %edx, 12(%eax)\r
54 movl 16(%esp), %edx # Update this function's return address into permenent memory\r
55 movl %edx, 16(%eax)\r
56 movl %eax, %esp # From now, esp is pointed to permenent memory\r
57\r
58 #\r
59 # Fixup the ebp point to permenent memory\r
60 #\r
61 movl %ebp, %eax\r
62 subl %ebx, %eax\r
63 addl %ecx, %eax\r
64 movl %eax, %ebp # From now, ebp is pointed to permenent memory\r
65\r
66 popl %edx\r
67 popl %ecx\r
68 popl %ebx\r
69 popl %eax\r
70 ret\r
71\r