]>
Commit | Line | Data |
---|---|---|
1 | #------------------------------------------------------------------------------\r | |
2 | #\r | |
3 | # Copyright (c) 2014, 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 | # Abstract:\r | |
13 | #\r | |
14 | # Switch the stack from temporary memory to permenent memory.\r | |
15 | #\r | |
16 | #------------------------------------------------------------------------------\r | |
17 | \r | |
18 | ASM_GLOBAL ASM_PFX(SecSwitchStack)\r | |
19 | \r | |
20 | #------------------------------------------------------------------------------\r | |
21 | # VOID\r | |
22 | # EFIAPI\r | |
23 | # SecSwitchStack (\r | |
24 | # UINT32 TemporaryMemoryBase,\r | |
25 | # UINT32 PermenentMemoryBase\r | |
26 | # )\r | |
27 | #------------------------------------------------------------------------------\r | |
28 | ASM_GLOBAL ASM_PFX(SecSwitchStack)\r | |
29 | ASM_PFX(SecSwitchStack):\r | |
30 | #\r | |
31 | # Save three register: eax, ebx, ecx\r | |
32 | #\r | |
33 | push %eax\r | |
34 | push %ebx\r | |
35 | push %ecx\r | |
36 | push %edx\r | |
37 | \r | |
38 | #\r | |
39 | # !!CAUTION!! this function address's is pushed into stack after\r | |
40 | # migration of whole temporary memory, so need save it to permenent\r | |
41 | # memory at first!\r | |
42 | #\r | |
43 | \r | |
44 | movl 20(%esp), %ebx # Save the first parameter\r | |
45 | movl 24(%esp), %ecx # Save the second parameter\r | |
46 | \r | |
47 | #\r | |
48 | # Save this function's return address into permenent memory at first.\r | |
49 | # Then, Fixup the esp point to permenent memory\r | |
50 | #\r | |
51 | \r | |
52 | movl %esp, %eax\r | |
53 | subl %ebx, %eax\r | |
54 | addl %ecx, %eax\r | |
55 | movl (%esp), %edx # copy pushed register's value to permenent memory\r | |
56 | movl %edx, (%eax)\r | |
57 | movl 4(%esp), %edx\r | |
58 | movl %edx, 4(%eax)\r | |
59 | movl 8(%esp), %edx\r | |
60 | movl %edx, 8(%eax)\r | |
61 | movl 12(%esp), %edx\r | |
62 | movl %edx, 12(%eax)\r | |
63 | movl 16(%esp), %edx # Update this function's return address into permenent memory\r | |
64 | movl %edx, 16(%eax)\r | |
65 | movl %eax, %esp # From now, esp is pointed to permenent memory\r | |
66 | \r | |
67 | #\r | |
68 | # Fixup the ebp point to permenent memory\r | |
69 | #\r | |
70 | \r | |
71 | movl %ebp, %eax\r | |
72 | subl %ebx, %eax\r | |
73 | addl %ecx, %eax\r | |
74 | movl %eax, %ebp # From now, ebp is pointed to permenent memory\r | |
75 | \r | |
76 | #\r | |
77 | # Fixup callee's ebp point for PeiDispatch\r | |
78 | #\r | |
79 | movl %ebp, %eax\r | |
80 | subl %ebx, %eax\r | |
81 | addl %ecx, %eax\r | |
82 | movl %eax, %ebp # From now, ebp is pointed to permenent memory\r | |
83 | \r | |
84 | pop %edx\r | |
85 | pop %ecx\r | |
86 | pop %ebx\r | |
87 | pop %eax\r | |
88 | ret |