Stack.asm 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. .586p
  12. .model flat,C
  13. .code
  14. ;------------------------------------------------------------------------------
  15. ; UINT32
  16. ; EFIAPI
  17. ; Pei2LoaderSwitchStack (
  18. ; VOID
  19. ; )
  20. ;------------------------------------------------------------------------------
  21. EXTERNDEF C MeasurePoint:PROC
  22. Pei2LoaderSwitchStack PROC C PUBLIC
  23. xor eax, eax
  24. jmp FspSwitchStack
  25. Pei2LoaderSwitchStack ENDP
  26. ;------------------------------------------------------------------------------
  27. ; UINT32
  28. ; EFIAPI
  29. ; Loader2PeiSwitchStack (
  30. ; VOID
  31. ; )
  32. ;------------------------------------------------------------------------------
  33. Loader2PeiSwitchStack PROC C PUBLIC
  34. jmp FspSwitchStack
  35. Loader2PeiSwitchStack ENDP
  36. ;------------------------------------------------------------------------------
  37. ; UINT32
  38. ; EFIAPI
  39. ; FspSwitchStack (
  40. ; VOID
  41. ; )
  42. ;------------------------------------------------------------------------------
  43. EXTERNDEF C SwapStack:PROC
  44. FspSwitchStack PROC C PUBLIC
  45. ; Save current contexts
  46. push eax
  47. pushfd
  48. cli
  49. pushad
  50. sub esp, 8
  51. sidt fword ptr [esp]
  52. ; Load new stack
  53. push esp
  54. call SwapStack
  55. mov esp, eax
  56. ; Restore previous contexts
  57. lidt fword ptr [esp]
  58. add esp, 8
  59. popad
  60. popfd
  61. add esp, 4
  62. ret
  63. FspSwitchStack ENDP
  64. END