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