]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
2 | SwitchStack() function for IA-32.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2007, Intel Corporation<BR>\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
e1f414b6 | 13 | **/\r |
14 | \r | |
15 | //\r | |
16 | // Include common header file for this module.\r | |
17 | //\r | |
f734a10a A |
18 | #include <BaseLibInternals.h>\r |
19 | \r | |
e1f414b6 | 20 | \r |
21 | /**\r | |
22 | Transfers control to a function starting with a new stack.\r | |
23 | \r | |
24 | Transfers control to the function specified by EntryPoint using the\r | |
25 | new stack specified by NewStack and passing in the parameters specified\r | |
26 | by Context1 and Context2. Context1 and Context2 are optional and may\r | |
27 | be NULL. The function EntryPoint must never return.\r | |
28 | Marker will be ignored on IA-32, x64, and EBC.\r | |
29 | IPF CPUs expect one additional parameter of type VOID * that specifies\r | |
30 | the new backing store pointer.\r | |
31 | \r | |
32 | If EntryPoint is NULL, then ASSERT().\r | |
33 | If NewStack is NULL, then ASSERT().\r | |
34 | \r | |
35 | @param EntryPoint A pointer to function to call with the new stack.\r | |
36 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
37 | function.\r | |
38 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
39 | function.\r | |
40 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
41 | function.\r | |
42 | @param Marker VA_LIST marker for the variable argument list.\r | |
43 | \r | |
44 | **/\r | |
45 | VOID\r | |
46 | EFIAPI\r | |
47 | InternalSwitchStack (\r | |
48 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
49 | IN VOID *Context1, OPTIONAL\r | |
50 | IN VOID *Context2, OPTIONAL\r | |
51 | IN VOID *NewStack,\r | |
52 | IN VA_LIST Marker\r | |
53 | )\r | |
54 | {\r | |
55 | BASE_LIBRARY_JUMP_BUFFER JumpBuffer;\r | |
56 | \r | |
57 | //\r | |
58 | // Stack should be aligned with CPU_STACK_ALIGNMENT\r | |
59 | //\r | |
60 | ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);\r | |
61 | \r | |
62 | JumpBuffer.Eip = (UINTN)EntryPoint;\r | |
63 | JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);\r | |
64 | JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);\r | |
65 | ((VOID**)JumpBuffer.Esp)[1] = Context1;\r | |
66 | ((VOID**)JumpBuffer.Esp)[2] = Context2;\r | |
67 | \r | |
68 | LongJump (&JumpBuffer, (UINTN)-1);\r | |
69 | }\r |