]>
Commit | Line | Data |
---|---|---|
7d7c2b46 | 1 | /** @file\r |
2 | SwitchStack() function for IA-32.\r | |
3 | \r | |
4 | Copyright (c) 2006, 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 | |
13 | Module Name: InternalSwitchStack.c\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | /**\r | |
18 | Transfers control to a function starting with a new stack.\r | |
19 | \r | |
20 | Transfers control to the function specified by EntryPoint using the new stack\r | |
21 | specified by NewStack and passing in the parameters specified by Context1 and\r | |
22 | Context2. Context1 and Context2 are optional and may be NULL. The function\r | |
23 | EntryPoint must never return.\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 | \r | |
33 | **/\r | |
34 | VOID\r | |
35 | EFIAPI\r | |
36 | InternalSwitchStack (\r | |
37 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
38 | IN VOID *Context1,\r | |
39 | IN VOID *Context2,\r | |
40 | IN VOID *NewStack\r | |
41 | )\r | |
42 | {\r | |
43 | BASE_LIBRARY_JUMP_BUFFER JumpBuffer;\r | |
44 | \r | |
45 | JumpBuffer.Eip = (UINTN)EntryPoint;\r | |
46 | JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);\r | |
47 | JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);\r | |
48 | ((VOID**)JumpBuffer.Esp)[1] = Context1;\r | |
49 | ((VOID**)JumpBuffer.Esp)[2] = Context2;\r | |
50 | \r | |
51 | LongJump (&JumpBuffer, (UINTN)-1);\r | |
52 | }\r |