]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
2 | SwitchStack() function for IA-32.\r | |
3 | \r | |
bb817c56 | 4 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r |
9344f092 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
e1f414b6 | 6 | \r |
e1f414b6 | 7 | **/\r |
8 | \r | |
47fc17d8 | 9 | #include "BaseLibInternals.h"\r |
f734a10a | 10 | \r |
e1f414b6 | 11 | /**\r |
12 | Transfers control to a function starting with a new stack.\r | |
13 | \r | |
14 | Transfers control to the function specified by EntryPoint using the\r | |
15 | new stack specified by NewStack and passing in the parameters specified\r | |
16 | by Context1 and Context2. Context1 and Context2 are optional and may\r | |
17 | be NULL. The function EntryPoint must never return.\r | |
18 | Marker will be ignored on IA-32, x64, and EBC.\r | |
19 | IPF CPUs expect one additional parameter of type VOID * that specifies\r | |
20 | the new backing store pointer.\r | |
21 | \r | |
22 | If EntryPoint is NULL, then ASSERT().\r | |
23 | If NewStack is NULL, then ASSERT().\r | |
24 | \r | |
25 | @param EntryPoint A pointer to function to call with the new stack.\r | |
26 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
27 | function.\r | |
28 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
29 | function.\r | |
30 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
31 | function.\r | |
32 | @param Marker VA_LIST marker for the variable argument list.\r | |
33 | \r | |
34 | **/\r | |
35 | VOID\r | |
36 | EFIAPI\r | |
37 | InternalSwitchStack (\r | |
38 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
d0e2f823 MK |
39 | IN VOID *Context1 OPTIONAL,\r |
40 | IN VOID *Context2 OPTIONAL,\r | |
e1f414b6 | 41 | IN VOID *NewStack,\r |
42 | IN VA_LIST Marker\r | |
43 | )\r | |
44 | {\r | |
45 | BASE_LIBRARY_JUMP_BUFFER JumpBuffer;\r | |
46 | \r | |
e1f414b6 | 47 | JumpBuffer.Eip = (UINTN)EntryPoint;\r |
48 | JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);\r | |
49 | JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);\r | |
50 | ((VOID**)JumpBuffer.Esp)[1] = Context1;\r | |
51 | ((VOID**)JumpBuffer.Esp)[2] = Context2;\r | |
52 | \r | |
53 | LongJump (&JumpBuffer, (UINTN)-1);\r | |
54 | }\r |