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