2012-08-15 02:03:25 +02:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:03:44 +02:00
|
|
|
; SPDX-License-Identifier: BSD-2-Clause-Patent
|
2012-08-15 02:03:25 +02:00
|
|
|
;
|
|
|
|
; Module Name:
|
|
|
|
;
|
|
|
|
; Stack.asm
|
|
|
|
;
|
|
|
|
; Abstract:
|
|
|
|
;
|
2020-02-07 02:07:17 +01:00
|
|
|
; Switch the stack from temporary memory to permanent memory.
|
2012-08-15 02:03:25 +02:00
|
|
|
;
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
.586p
|
|
|
|
.model flat,C
|
|
|
|
.code
|
2018-08-29 05:39:06 +02:00
|
|
|
|
2012-08-15 02:03:25 +02:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; VOID
|
|
|
|
; EFIAPI
|
|
|
|
; SecSwitchStack (
|
|
|
|
; UINT32 TemporaryMemoryBase,
|
|
|
|
; UINT32 PermenentMemoryBase
|
|
|
|
; );
|
2018-08-29 05:39:06 +02:00
|
|
|
;------------------------------------------------------------------------------
|
2012-08-15 02:03:25 +02:00
|
|
|
SecSwitchStack PROC
|
|
|
|
;
|
|
|
|
; Save three register: eax, ebx, ecx
|
|
|
|
;
|
|
|
|
push eax
|
|
|
|
push ebx
|
|
|
|
push ecx
|
|
|
|
push edx
|
2018-08-29 05:39:06 +02:00
|
|
|
|
2012-08-15 02:03:25 +02:00
|
|
|
;
|
|
|
|
; !!CAUTION!! this function address's is pushed into stack after
|
2020-02-07 02:07:17 +01:00
|
|
|
; migration of whole temporary memory, so need save it to permanent
|
2012-08-15 02:03:25 +02:00
|
|
|
; memory at first!
|
|
|
|
;
|
2018-08-29 05:39:06 +02:00
|
|
|
|
2012-08-15 02:03:25 +02:00
|
|
|
mov ebx, [esp + 20] ; Save the first parameter
|
|
|
|
mov ecx, [esp + 24] ; Save the second parameter
|
2018-08-29 05:39:06 +02:00
|
|
|
|
2012-08-15 02:03:25 +02:00
|
|
|
;
|
2020-02-07 02:07:17 +01:00
|
|
|
; Save this function's return address into permanent memory at first.
|
|
|
|
; Then, Fixup the esp point to permanent memory
|
2012-08-15 02:03:25 +02:00
|
|
|
;
|
|
|
|
mov eax, esp
|
|
|
|
sub eax, ebx
|
|
|
|
add eax, ecx
|
2020-02-07 02:07:17 +01:00
|
|
|
mov edx, dword ptr [esp] ; copy pushed register's value to permanent memory
|
2018-08-29 05:39:06 +02:00
|
|
|
mov dword ptr [eax], edx
|
2012-08-15 02:03:25 +02:00
|
|
|
mov edx, dword ptr [esp + 4]
|
2018-08-29 05:39:06 +02:00
|
|
|
mov dword ptr [eax + 4], edx
|
2012-08-15 02:03:25 +02:00
|
|
|
mov edx, dword ptr [esp + 8]
|
2018-08-29 05:39:06 +02:00
|
|
|
mov dword ptr [eax + 8], edx
|
2012-08-15 02:03:25 +02:00
|
|
|
mov edx, dword ptr [esp + 12]
|
2018-08-29 05:39:06 +02:00
|
|
|
mov dword ptr [eax + 12], edx
|
2020-02-07 02:07:17 +01:00
|
|
|
mov edx, dword ptr [esp + 16] ; Update this function's return address into permanent memory
|
2018-08-29 05:39:06 +02:00
|
|
|
mov dword ptr [eax + 16], edx
|
2020-02-07 02:07:17 +01:00
|
|
|
mov esp, eax ; From now, esp is pointed to permanent memory
|
2018-08-29 05:39:06 +02:00
|
|
|
|
2012-08-15 02:03:25 +02:00
|
|
|
;
|
2020-02-07 02:07:17 +01:00
|
|
|
; Fixup the ebp point to permanent memory
|
2012-08-15 02:03:25 +02:00
|
|
|
;
|
|
|
|
mov eax, ebp
|
|
|
|
sub eax, ebx
|
|
|
|
add eax, ecx
|
2020-02-07 02:07:17 +01:00
|
|
|
mov ebp, eax ; From now, ebp is pointed to permanent memory
|
2018-08-29 05:39:06 +02:00
|
|
|
|
2012-08-15 02:03:25 +02:00
|
|
|
;
|
|
|
|
; Fixup callee's ebp point for PeiDispatch
|
|
|
|
;
|
|
|
|
mov eax, dword ptr [ebp]
|
|
|
|
sub eax, ebx
|
|
|
|
add eax, ecx
|
2020-02-07 02:07:17 +01:00
|
|
|
mov dword ptr [ebp], eax ; From now, Temporary's PPI caller's stack is in permanent memory
|
2018-08-29 05:39:06 +02:00
|
|
|
|
2012-08-15 02:03:25 +02:00
|
|
|
pop edx
|
|
|
|
pop ecx
|
|
|
|
pop ebx
|
|
|
|
pop eax
|
|
|
|
ret
|
|
|
|
SecSwitchStack ENDP
|
|
|
|
|
|
|
|
END
|