]>
Commit | Line | Data |
---|---|---|
7601b251 AC |
1 | /** @file\r |
2 | Switch stack function for RISC-V\r | |
3 | \r | |
4 | Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>\r | |
5 | \r | |
6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
7 | **/\r | |
8 | \r | |
9 | #include "BaseLibInternals.h"\r | |
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.\r | |
18 | Marker will be ignored on IA-32, x64, and EBC.\r | |
19 | IPF CPUs expect one additional parameter of type VOID * that specifies\r | |
20 | the new backing store pointer.\r | |
21 | \r | |
22 | If EntryPoint is NULL, then ASSERT().\r | |
23 | If NewStack is NULL, then ASSERT().\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 | @param Marker VA_LIST marker for the variable argument list.\r | |
33 | \r | |
34 | **/\r | |
35 | VOID\r | |
36 | EFIAPI\r | |
37 | InternalSwitchStack (\r | |
38 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
d0e2f823 MK |
39 | IN VOID *Context1 OPTIONAL,\r |
40 | IN VOID *Context2 OPTIONAL,\r | |
7601b251 AC |
41 | IN VOID *NewStack,\r |
42 | IN VA_LIST Marker\r | |
43 | )\r | |
44 | {\r | |
45 | BASE_LIBRARY_JUMP_BUFFER JumpBuffer;\r | |
46 | \r | |
2f88bd3a MK |
47 | DEBUG ((\r |
48 | DEBUG_INFO,\r | |
49 | "RISC-V InternalSwitchStack Entry:%x Context1:%x Context2:%x NewStack%x\n", \\r | |
50 | EntryPoint,\r | |
51 | Context1,\r | |
52 | Context2,\r | |
53 | NewStack\r | |
54 | ));\r | |
7601b251 AC |
55 | JumpBuffer.RA = (UINTN)EntryPoint;\r |
56 | JumpBuffer.SP = (UINTN)NewStack - sizeof (VOID *);\r | |
57 | JumpBuffer.S0 = (UINT64)(UINTN)Context1;\r | |
58 | JumpBuffer.S1 = (UINT64)(UINTN)Context2;\r | |
59 | LongJump (&JumpBuffer, (UINTN)-1);\r | |
2f88bd3a | 60 | ASSERT (FALSE);\r |
7601b251 | 61 | }\r |