]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFsp2Pkg/Library/BaseFspSwitchStackLib/Ia32/Stack.nasm
IntelFsp2Pkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFsp2Pkg / Library / BaseFspSwitchStackLib / Ia32 / Stack.nasm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
5 ;
6 ; Abstract:
7 ;
8 ; Switch the stack from temporary memory to permenent memory.
9 ;
10 ;------------------------------------------------------------------------------
11
12 SECTION .text
13
14 extern ASM_PFX(SwapStack)
15
16 ;------------------------------------------------------------------------------
17 ; UINT32
18 ; EFIAPI
19 ; Pei2LoaderSwitchStack (
20 ; VOID
21 ; )
22 ;------------------------------------------------------------------------------
23 global ASM_PFX(Pei2LoaderSwitchStack)
24 ASM_PFX(Pei2LoaderSwitchStack):
25 xor eax, eax
26 jmp ASM_PFX(FspSwitchStack)
27
28 ;------------------------------------------------------------------------------
29 ; UINT32
30 ; EFIAPI
31 ; Loader2PeiSwitchStack (
32 ; VOID
33 ; )
34 ;------------------------------------------------------------------------------
35 global ASM_PFX(Loader2PeiSwitchStack)
36 ASM_PFX(Loader2PeiSwitchStack):
37 jmp ASM_PFX(FspSwitchStack)
38
39 ;------------------------------------------------------------------------------
40 ; UINT32
41 ; EFIAPI
42 ; FspSwitchStack (
43 ; VOID
44 ; )
45 ;------------------------------------------------------------------------------
46 global ASM_PFX(FspSwitchStack)
47 ASM_PFX(FspSwitchStack):
48 ; Save current contexts
49 push eax
50 pushfd
51 cli
52 pushad
53 sub esp, 8
54 sidt [esp]
55
56 ; Load new stack
57 push esp
58 call ASM_PFX(SwapStack)
59 mov esp, eax
60
61 ; Restore previous contexts
62 lidt [esp]
63 add esp, 8
64 popad
65 popfd
66 add esp, 4
67 ret
68