Stack.s 1.7 KB

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