]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/SwitchStack.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseLib / SwitchStack.c
CommitLineData
e1f414b6 1/** @file\r
2 Switch Stack functions.\r
3\r
9095d37b 4 Copyright (c) 2006 - 2018, 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
e1f414b6 10\r
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. This function\r
18 supports a variable number of arguments following the NewStack parameter.\r
19 These additional arguments are ignored on IA-32, x64, and EBC.\r
20 IPF CPUs expect one additional parameter of type VOID * that specifies\r
21 the new backing store pointer.\r
22\r
23 If EntryPoint is NULL, then ASSERT().\r
24 If NewStack is NULL, then ASSERT().\r
25\r
26 @param EntryPoint A pointer to function to call with the new stack.\r
27 @param Context1 A pointer to the context to pass into the EntryPoint\r
28 function.\r
29 @param Context2 A pointer to the context to pass into the EntryPoint\r
30 function.\r
31 @param NewStack A pointer to the new stack to use for the EntryPoint\r
32 function.\r
9095d37b
LG
33 @param ... This variable argument list is ignored for IA32, x64, and EBC.\r
34 For IPF, this variable argument list is expected to contain\r
35 a single parameter of type VOID * that specifies the new backing\r
285010e7 36 store pointer.\r
e1f414b6 37\r
2fc60b70 38\r
e1f414b6 39**/\r
40VOID\r
41EFIAPI\r
42SwitchStack (\r
43 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
44 IN VOID *Context1, OPTIONAL\r
45 IN VOID *Context2, OPTIONAL\r
46 IN VOID *NewStack,\r
47 ...\r
48 )\r
49{\r
50 VA_LIST Marker;\r
51\r
52 ASSERT (EntryPoint != NULL);\r
53 ASSERT (NewStack != NULL);\r
54\r
7f22d351 55 //\r
56 // New stack must be aligned with CPU_STACK_ALIGNMENT\r
57 //\r
58 ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);\r
59\r
e1f414b6 60 VA_START (Marker, NewStack);\r
61\r
62 InternalSwitchStack (EntryPoint, Context1, Context2, NewStack, Marker);\r
63\r
7f22d351 64 VA_END (Marker);\r
65\r
e1f414b6 66 //\r
67 // InternalSwitchStack () will never return\r
68 //\r
69 ASSERT (FALSE);\r
70}\r