3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. 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
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.
19 SwitchStack() function for IA-32.
23 #include "..\BaseLibInternal.h"
26 Transfers control to a function starting with a new stack.
28 Transfers control to the function specified by EntryPoint using the new stack
29 specified by NewStack and passing in the parameters specified by Context1 and
30 Context2. Context1 and Context2 are optional and may be NULL. The function
31 EntryPoint must never return.
33 @param EntryPoint A pointer to function to call with the new stack.
34 @param Context1 A pointer to the context to pass into the EntryPoint
36 @param Context2 A pointer to the context to pass into the EntryPoint
38 @param NewStack A pointer to the new stack to use for the EntryPoint
45 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
51 BASE_LIBRARY_JUMP_BUFFER JumpBuffer
;
53 JumpBuffer
.Eip
= (UINTN
)EntryPoint
;
54 JumpBuffer
.Esp
= (UINTN
)NewStack
- sizeof (VOID
*);
55 JumpBuffer
.Esp
-= sizeof (Context1
) + sizeof (Context2
);
56 ((VOID
**)JumpBuffer
.Esp
)[1] = Context1
;
57 ((VOID
**)JumpBuffer
.Esp
)[2] = Context2
;
59 LongJump (&JumpBuffer
, (UINTN
)-1);