]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/RiscV64/InternalSwitchStack.c
MdePkg/BaseLib: BaseLib for RISCV64 architecture
[mirror_edk2.git] / MdePkg / Library / BaseLib / RiscV64 / InternalSwitchStack.c
CommitLineData
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
35VOID\r
36EFIAPI\r
37InternalSwitchStack (\r
38 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
39 IN VOID *Context1, OPTIONAL\r
40 IN VOID *Context2, OPTIONAL\r
41 IN VOID *NewStack,\r
42 IN VA_LIST Marker\r
43 )\r
44{\r
45 BASE_LIBRARY_JUMP_BUFFER JumpBuffer;\r
46\r
47 DEBUG ((DEBUG_INFO, "RISC-V InternalSwitchStack Entry:%x Context1:%x Context2:%x NewStack%x\n", \\r
48 EntryPoint, Context1, Context2, NewStack));\r
49 JumpBuffer.RA = (UINTN)EntryPoint;\r
50 JumpBuffer.SP = (UINTN)NewStack - sizeof (VOID *);\r
51 JumpBuffer.S0 = (UINT64)(UINTN)Context1;\r
52 JumpBuffer.S1 = (UINT64)(UINTN)Context2;\r
53 LongJump (&JumpBuffer, (UINTN)-1);\r
54 ASSERT(FALSE);\r
55}\r