]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFsp2Pkg/Library/BaseFspSwitchStackLib/Ia32/Stack.nasm
IntelFsp2Pkg BaseFspSwitchStackLib: Convert Ia32/Stack.asm to NASM
[mirror_edk2.git] / IntelFsp2Pkg / Library / BaseFspSwitchStackLib / Ia32 / Stack.nasm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2016, 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 SECTION .text
19
20 extern ASM_PFX(SwapStack)
21
22 ;------------------------------------------------------------------------------
23 ; UINT32
24 ; EFIAPI
25 ; Pei2LoaderSwitchStack (
26 ; VOID
27 ; )
28 ;------------------------------------------------------------------------------
29 global ASM_PFX(Pei2LoaderSwitchStack)
30 ASM_PFX(Pei2LoaderSwitchStack):
31 xor eax, eax
32 jmp ASM_PFX(FspSwitchStack)
33
34 ;------------------------------------------------------------------------------
35 ; UINT32
36 ; EFIAPI
37 ; Loader2PeiSwitchStack (
38 ; VOID
39 ; )
40 ;------------------------------------------------------------------------------
41 global ASM_PFX(Loader2PeiSwitchStack)
42 ASM_PFX(Loader2PeiSwitchStack):
43 jmp ASM_PFX(FspSwitchStack)
44
45 ;------------------------------------------------------------------------------
46 ; UINT32
47 ; EFIAPI
48 ; FspSwitchStack (
49 ; VOID
50 ; )
51 ;------------------------------------------------------------------------------
52 global ASM_PFX(FspSwitchStack)
53 ASM_PFX(FspSwitchStack):
54 ; Save current contexts
55 push eax
56 pushfd
57 cli
58 pushad
59 sub esp, 8
60 sidt [esp]
61
62 ; Load new stack
63 push esp
64 call ASM_PFX(SwapStack)
65 mov esp, eax
66
67 ; Restore previous contexts
68 lidt [esp]
69 add esp, 8
70 popad
71 popfd
72 add esp, 4
73 ret
74