]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/FspSupport/Library/SecFspPlatformSecLibVlv2/Ia32/Stack.asm
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2TbltDevicePkg / FspSupport / Library / SecFspPlatformSecLibVlv2 / Ia32 / Stack.asm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
4 ; This program and the accompanying materials
5 ; are licensed and made available under the terms and conditions of the BSD License
6 ; which accompanies this distribution. The full text of the license may be found at
7 ; http://opensource.org/licenses/bsd-license.php.
8 ;
9 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 ;
12 ; Abstract:
13 ;
14 ; Switch the stack from temporary memory to permenent memory.
15 ;
16 ;------------------------------------------------------------------------------
17
18 .586p
19 .model flat,C
20 .code
21
22 ;------------------------------------------------------------------------------
23 ; VOID
24 ; EFIAPI
25 ; SecSwitchStack (
26 ; UINT32 TemporaryMemoryBase,
27 ; UINT32 PermenentMemoryBase
28 ; );
29 ;------------------------------------------------------------------------------
30 SecSwitchStack PROC
31 ;
32 ; Save three register: eax, ebx, ecx
33 ;
34 push eax
35 push ebx
36 push ecx
37 push edx
38
39 ;
40 ; !!CAUTION!! this function address's is pushed into stack after
41 ; migration of whole temporary memory, so need save it to permenent
42 ; memory at first!
43 ;
44
45 mov ebx, [esp + 20] ; Save the first parameter
46 mov ecx, [esp + 24] ; Save the second parameter
47
48 ;
49 ; Save this function's return address into permenent memory at first.
50 ; Then, Fixup the esp point to permenent memory
51 ;
52 mov eax, esp
53 sub eax, ebx
54 add eax, ecx
55 mov edx, dword ptr [esp] ; copy pushed register's value to permenent memory
56 mov dword ptr [eax], edx
57 mov edx, dword ptr [esp + 4]
58 mov dword ptr [eax + 4], edx
59 mov edx, dword ptr [esp + 8]
60 mov dword ptr [eax + 8], edx
61 mov edx, dword ptr [esp + 12]
62 mov dword ptr [eax + 12], edx
63 mov edx, dword ptr [esp + 16] ; Update this function's return address into permenent memory
64 mov dword ptr [eax + 16], edx
65 mov esp, eax ; From now, esp is pointed to permenent memory
66
67 ;
68 ; Fixup the ebp point to permenent memory
69 ;
70 mov eax, ebp
71 sub eax, ebx
72 add eax, ecx
73 mov ebp, eax ; From now, ebp is pointed to permenent memory
74
75 pop edx
76 pop ecx
77 pop ebx
78 pop eax
79 ret
80 SecSwitchStack ENDP
81
82 END