1#------------------------------------------------------------------------------
2#
3# Copyright (c) 2014 - 2015, 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
19#------------------------------------------------------------------------------
20# UINT32
21# EFIAPI
22# Pei2LoaderSwitchStack (
23#   VOID
24#   )
25#------------------------------------------------------------------------------
26ASM_GLOBAL ASM_PFX(Pei2LoaderSwitchStack)
27ASM_PFX(Pei2LoaderSwitchStack):
28    xorl    %eax, %eax
29    jmp     ASM_PFX(FspSwitchStack)
30
31#------------------------------------------------------------------------------
32# UINT32
33# EFIAPI
34# Loader2PeiSwitchStack (
35#   VOID
36#   )
37#------------------------------------------------------------------------------
38ASM_GLOBAL ASM_PFX(Loader2PeiSwitchStack)
39ASM_PFX(Loader2PeiSwitchStack):
40    jmp     ASM_PFX(FspSwitchStack)
41
42#------------------------------------------------------------------------------
43# UINT32
44# EFIAPI
45# FspSwitchStack (
46#   VOID
47#   )
48#------------------------------------------------------------------------------
49ASM_GLOBAL ASM_PFX(FspSwitchStack)
50ASM_PFX(FspSwitchStack):
51    #
52    #Save current contexts
53    #
54    push    %eax
55    pushf
56    cli
57    pusha
58    sub     $0x08, %esp
59    sidt    (%esp)
60
61    #
62    # Load new stack
63    #
64    push   %esp
65    call   ASM_PFX(SwapStack)
66    movl   %eax, %esp
67
68    #
69    # Restore previous contexts
70    #
71    lidt    (%esp)
72    add     $0x08,%esp
73    popa
74    popf
75    add     $0x04,%esp
76    ret
77
78
79