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