1 | /** @file
|
---|
2 | Switch Stack functions.
|
---|
3 |
|
---|
4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #include "BaseLibInternals.h"
|
---|
10 |
|
---|
11 | /**
|
---|
12 | Transfers control to a function starting with a new stack.
|
---|
13 |
|
---|
14 | Transfers control to the function specified by EntryPoint using the
|
---|
15 | new stack specified by NewStack and passing in the parameters specified
|
---|
16 | by Context1 and Context2. Context1 and Context2 are optional and may
|
---|
17 | be NULL. The function EntryPoint must never return. This function
|
---|
18 | supports a variable number of arguments following the NewStack parameter.
|
---|
19 | These additional arguments are ignored on IA-32, x64, and EBC.
|
---|
20 | IPF CPUs expect one additional parameter of type VOID * that specifies
|
---|
21 | the new backing store pointer.
|
---|
22 |
|
---|
23 | If EntryPoint is NULL, then ASSERT().
|
---|
24 | If NewStack is NULL, then ASSERT().
|
---|
25 |
|
---|
26 | @param EntryPoint A pointer to function to call with the new stack.
|
---|
27 | @param Context1 A pointer to the context to pass into the EntryPoint
|
---|
28 | function.
|
---|
29 | @param Context2 A pointer to the context to pass into the EntryPoint
|
---|
30 | function.
|
---|
31 | @param NewStack A pointer to the new stack to use for the EntryPoint
|
---|
32 | function.
|
---|
33 | @param ... This variable argument list is ignored for IA32, x64, and EBC.
|
---|
34 | For IPF, this variable argument list is expected to contain
|
---|
35 | a single parameter of type VOID * that specifies the new backing
|
---|
36 | store pointer.
|
---|
37 |
|
---|
38 |
|
---|
39 | **/
|
---|
40 | VOID
|
---|
41 | EFIAPI
|
---|
42 | SwitchStack (
|
---|
43 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
---|
44 | IN VOID *Context1, OPTIONAL
|
---|
45 | IN VOID *Context2, OPTIONAL
|
---|
46 | IN VOID *NewStack,
|
---|
47 | ...
|
---|
48 | )
|
---|
49 | {
|
---|
50 | VA_LIST Marker;
|
---|
51 |
|
---|
52 | ASSERT (EntryPoint != NULL);
|
---|
53 | ASSERT (NewStack != NULL);
|
---|
54 |
|
---|
55 | //
|
---|
56 | // New stack must be aligned with CPU_STACK_ALIGNMENT
|
---|
57 | //
|
---|
58 | ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);
|
---|
59 |
|
---|
60 | VA_START (Marker, NewStack);
|
---|
61 |
|
---|
62 | InternalSwitchStack (EntryPoint, Context1, Context2, NewStack, Marker);
|
---|
63 |
|
---|
64 | VA_END (Marker);
|
---|
65 |
|
---|
66 | //
|
---|
67 | // InternalSwitchStack () will never return
|
---|
68 | //
|
---|
69 | ASSERT (FALSE);
|
---|
70 | }
|
---|