]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseRiscVSbiLib/RiscVSbiEcall.S
MdePkg: Add BaseRiscVSbiLib Library for RISC-V
[mirror_edk2.git] / MdePkg / Library / BaseRiscVSbiLib / RiscVSbiEcall.S
1 //------------------------------------------------------------------------------
2 //
3 // Make ECALL to SBI
4 //
5 // Copyright (c) 2023, Ventana Micro Systems Inc. All rights reserved.<BR>
6 //
7 // SPDX-License-Identifier: BSD-2-Clause-Patent
8 //
9 //------------------------------------------------------------------------------
10
11 #include <Register/RiscV64/RiscVImpl.h>
12
13 .data
14 .align 3
15 .section .text
16
17 //
18 // Make ECALL to SBI
19 // ecall updates the same a0 and a1 registers with
20 // return values. Hence, the C function which calls
21 // this should pass the address of Arg0 and Arg1.
22 // This routine saves the address and updates it
23 // with a0 and a1 once ecall returns.
24 //
25 // @param a0 : Pointer to Arg0
26 // @param a1 : Pointer to Arg1
27 // @param a2 : Arg2
28 // @param a3 : Arg3
29 // @param a4 : Arg4
30 // @param a5 : Arg5
31 // @param a6 : FunctionID
32 // @param a7 : ExtensionId
33 //
34 ASM_FUNC (RiscVSbiEcall)
35 mv t0, a0
36 mv t1, a1
37 ld a0, 0(a0)
38 ld a1, 0(a1)
39 ecall
40 sd a0, 0(t0)
41 sd a1, 0(t1)
42 ret