]>
Commit | Line | Data |
---|---|---|
3cbfba02 DW |
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 | \r | |
19 | #------------------------------------------------------------------------------\r | |
20 | # VOID\r | |
21 | # EFIAPI\r | |
22 | # SecSwitchStack (\r | |
23 | # UINT32 TemporaryMemoryBase,\r | |
24 | # UINT32 PermenentMemoryBase\r | |
25 | # )#\r | |
26 | #------------------------------------------------------------------------------\r | |
27 | ASM_GLOBAL ASM_PFX (SecSwitchStack)\r | |
28 | ASM_PFX(SecSwitchStack):\r | |
29 | #\r | |
30 | # Save standard registers so they can be used to change stack\r | |
31 | #\r | |
32 | pushl %eax\r | |
33 | pushl %ebx\r | |
34 | pushl %ecx\r | |
35 | pushl %edx\r | |
36 | \r | |
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 | |
41 | #\r | |
42 | movl 20(%esp), %ebx # Save the first parameter\r | |
43 | movl 24(%esp), %ecx # Save the second parameter\r | |
44 | \r | |
45 | #\r | |
46 | # Save this function's return address into permenent memory at first.\r | |
47 | # Then, Fixup the esp point to permenent memory\r | |
48 | #\r | |
49 | movl %esp, %eax\r | |
50 | subl %ebx, %eax\r | |
51 | addl %ecx, %eax\r | |
52 | movl 0(%esp), %edx # copy pushed register's value to permenent memory\r | |
53 | movl %edx, 0(%eax)\r | |
54 | movl 4(%esp), %edx\r | |
55 | movl %edx, 4(%eax)\r | |
56 | movl 8(%esp), %edx\r | |
57 | movl %edx, 8(%eax)\r | |
58 | movl 12(%esp), %edx\r | |
59 | movl %edx, 12(%eax)\r | |
60 | movl 16(%esp), %edx # Update this function's return address into permenent memory\r | |
61 | movl %edx, 16(%eax)\r | |
62 | movl %eax, %esp # From now, esp is pointed to permenent memory\r | |
63 | \r | |
64 | #\r | |
65 | # Fixup the ebp point to permenent memory\r | |
66 | #\r | |
67 | movl %ebp, %eax\r | |
68 | subl %ebx, %eax\r | |
69 | addl %ecx, %eax\r | |
70 | movl %eax, %ebp # From now, ebp is pointed to permenent memory\r | |
71 | \r | |
72 | popl %edx\r | |
73 | popl %ecx\r | |
74 | popl %ebx\r | |
75 | popl %eax\r | |
76 | ret\r | |
77 | \r |