]>
Commit | Line | Data |
---|---|---|
112a857f | 1 | #------------------------------------------------------------------------------\r |
2 | #\r | |
3 | # Copyright (c) 2007, 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 | # Module Name:\r | |
13 | #\r | |
14 | # Stack.asm\r | |
15 | #\r | |
16 | # Abstract:\r | |
17 | #\r | |
18 | # Switch the stack from temporary memory to permenent memory.\r | |
19 | #\r | |
20 | #------------------------------------------------------------------------------\r | |
21 | \r | |
22 | .text\r | |
23 | \r | |
24 | \r | |
25 | // EFI_STATUS\r | |
26 | // EFIAPI\r | |
27 | // SecTemporaryRamSupport (\r | |
28 | // IN CONST EFI_PEI_SERVICES **PeiServices, // %rcx\r | |
29 | // IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, // %rdx\r | |
30 | // IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, // %r8 \r | |
31 | // IN UINTN CopySize // %r9\r | |
32 | // )\r | |
33 | //\r | |
34 | ASM_GLOBAL ASM_PFX(SecTemporaryRamSupport)\r | |
35 | ASM_PFX(SecTemporaryRamSupport):\r | |
36 | //------------------------------------------------------------------------------\r | |
37 | // VOID\r | |
38 | // EFIAPI\r | |
39 | // SecSwitchStack (\r | |
40 | // UINT32 TemporaryMemoryBase,\r | |
41 | // UINT32 PermenentMemoryBase\r | |
42 | // )//\r | |
43 | //------------------------------------------------------------------------------ \r | |
44 | \r | |
45 | //\r | |
46 | // Save three register: eax, ebx, ecx\r | |
47 | //\r | |
48 | push %eax\r | |
49 | push %ebx\r | |
50 | push %ecx\r | |
51 | push %edx\r | |
52 | \r | |
53 | #if 0 \r | |
54 | // Port me to GAS syntax\r | |
55 | //\r | |
56 | // !!CAUTION!! this function addresss is pushed into stack after\r | |
57 | // migration of whole temporary memory, so need save it to permenent\r | |
58 | // memory at first!\r | |
59 | //\r | |
60 | \r | |
61 | mov ebx, [esp + 20] // Save the first parameter\r | |
62 | mov ecx, [esp + 24] // Save the second parameter\r | |
63 | \r | |
64 | //\r | |
65 | // Save this functions return address into permenent memory at first.\r | |
66 | // Then, Fixup the esp point to permenent memory\r | |
67 | //\r | |
68 | mov eax, esp\r | |
69 | sub eax, ebx\r | |
70 | add eax, ecx\r | |
71 | mov edx, dword ptr [esp] // copy pushed registers value to permenent memory\r | |
72 | mov dword ptr [eax], edx \r | |
73 | mov edx, dword ptr [esp + 4]\r | |
74 | mov dword ptr [eax + 4], edx \r | |
75 | mov edx, dword ptr [esp + 8]\r | |
76 | mov dword ptr [eax + 8], edx \r | |
77 | mov edx, dword ptr [esp + 12]\r | |
78 | mov dword ptr [eax + 12], edx \r | |
79 | mov edx, dword ptr [esp + 16] // Update this functions return address into permenent memory\r | |
80 | mov dword ptr [eax + 16], edx \r | |
81 | mov esp, eax // From now, esp is pointed to permenent memory\r | |
82 | \r | |
83 | //\r | |
84 | // Fixup the ebp point to permenent memory\r | |
85 | //\r | |
86 | mov eax, ebp\r | |
87 | sub eax, ebx\r | |
88 | add eax, ecx\r | |
89 | mov ebp, eax // From now, ebp is pointed to permenent memory\r | |
90 | \r | |
91 | //\r | |
92 | // Fixup callees ebp point for PeiDispatch\r | |
93 | //\r | |
94 | mov eax, dword ptr [ebp]\r | |
95 | sub eax, ebx\r | |
96 | add eax, ecx\r | |
97 | mov dword ptr [ebp], eax // From now, Temporarys PPI callers stack is in permenent memory\r | |
98 | #endif\r | |
99 | pop %edx\r | |
100 | pop %ecx\r | |
101 | pop %ebx\r | |
102 | pop %eax\r | |
103 | ret\r |