TianoCore EDK2 master
Loading...
Searching...
No Matches
BaseRiscVSbiLib.h
Go to the documentation of this file.
1
16#ifndef RISCV_SBI_LIB_H_
17#define RISCV_SBI_LIB_H_
18
19#include <Uefi.h>
20
21/* SBI Extension IDs */
22#define SBI_EXT_0_1_CONSOLE_PUTCHAR 0x1
23#define SBI_EXT_0_1_CONSOLE_GETCHAR 0x2
24#define SBI_EXT_BASE 0x10
25#define SBI_EXT_DBCN 0x4442434E
26#define SBI_EXT_TIME 0x54494D45
27#define SBI_EXT_SRST 0x53525354
28
29/* SBI function IDs for base extension */
30#define SBI_EXT_BASE_SPEC_VERSION 0x0
31#define SBI_EXT_BASE_IMPL_ID 0x1
32#define SBI_EXT_BASE_IMPL_VERSION 0x2
33#define SBI_EXT_BASE_PROBE_EXT 0x3
34#define SBI_EXT_BASE_GET_MVENDORID 0x4
35#define SBI_EXT_BASE_GET_MARCHID 0x5
36#define SBI_EXT_BASE_GET_MIMPID 0x6
37
38/* SBI function IDs for DBCN extension */
39#define SBI_EXT_DBCN_WRITE 0x0
40#define SBI_EXT_DBCN_READ 0x1
41#define SBI_EXT_DBCN_WRITE_BYTE 0x2
42
43/* SBI function IDs for TIME extension */
44#define SBI_EXT_TIME_SET_TIMER 0x0
45
46/* SBI function IDs for SRST extension */
47#define SBI_EXT_SRST_RESET 0x0
48
49#define SBI_SRST_RESET_TYPE_SHUTDOWN 0x0
50#define SBI_SRST_RESET_TYPE_COLD_REBOOT 0x1
51#define SBI_SRST_RESET_TYPE_WARM_REBOOT 0x2
52
53#define SBI_SRST_RESET_REASON_NONE 0x0
54#define SBI_SRST_RESET_REASON_SYSFAIL 0x1
55
56/* SBI return error codes */
57#define SBI_SUCCESS 0
58#define SBI_ERR_FAILED -1
59#define SBI_ERR_NOT_SUPPORTED -2
60#define SBI_ERR_INVALID_PARAM -3
61#define SBI_ERR_DENIED -4
62#define SBI_ERR_INVALID_ADDRESS -5
63#define SBI_ERR_ALREADY_AVAILABLE -6
64#define SBI_ERR_ALREADY_STARTED -7
65#define SBI_ERR_ALREADY_STOPPED -8
66
67#define SBI_LAST_ERR SBI_ERR_ALREADY_STOPPED
68
69typedef struct {
70 UINT64 BootHartId;
71 VOID *PeiServiceTable; // PEI Service table
72 VOID *PrePiHobList; // Pre PI Hob List
73 UINT64 FlattenedDeviceTree; // Pointer to Flattened Device tree
75
76//
77// EDK2 OpenSBI firmware extension return status.
78//
79typedef struct {
82} SBI_RET;
83
85EFIAPI
86SbiCall (
87 IN UINTN ExtId,
88 IN UINTN FuncId,
89 IN UINTN NumArgs,
90 ...
91 );
92
94EFIAPI
96 IN UINTN SbiError
97 );
98
99VOID
100EFIAPI
102 IN UINT64 Time
103 );
104
106EFIAPI
108 IN UINTN ResetType,
109 IN UINTN ResetReason
110 );
111
117VOID
118EFIAPI
120 OUT EFI_RISCV_FIRMWARE_CONTEXT **FirmwareContext
121 );
122
128VOID
129EFIAPI
131 IN EFI_RISCV_FIRMWARE_CONTEXT *FirmwareContext
132 );
133
142VOID
143EFIAPI
145 IN OUT EFI_RISCV_FIRMWARE_CONTEXT **FirmwareContextPtr
146 );
147
155VOID
156EFIAPI
158 IN EFI_RISCV_FIRMWARE_CONTEXT *FirmwareContextPtr
159 );
160
175VOID
176EFIAPI
178 IN OUT UINTN *Arg0,
179 IN OUT UINTN *Arg1,
180 IN UINTN Arg2,
181 IN UINTN Arg3,
182 IN UINTN Arg4,
183 IN UINTN Arg5,
184 IN UINTN Fid,
185 IN UINTN Ext
186 );
187
188#endif
UINT64 UINTN
EFI_STATUS EFIAPI SbiSystemReset(IN UINTN ResetType, IN UINTN ResetReason)
VOID EFIAPI SetFirmwareContextPointer(IN EFI_RISCV_FIRMWARE_CONTEXT *FirmwareContextPtr)
VOID EFIAPI SbiSetTimer(IN UINT64 Time)
VOID EFIAPI SetFirmwareContext(IN EFI_RISCV_FIRMWARE_CONTEXT *FirmwareContext)
VOID EFIAPI RiscVSbiEcall(IN OUT UINTN *Arg0, IN OUT UINTN *Arg1, IN UINTN Arg2, IN UINTN Arg3, IN UINTN Arg4, IN UINTN Arg5, IN UINTN Fid, IN UINTN Ext)
VOID EFIAPI GetFirmwareContext(OUT EFI_RISCV_FIRMWARE_CONTEXT **FirmwareContext)
VOID EFIAPI GetFirmwareContextPointer(IN OUT EFI_RISCV_FIRMWARE_CONTEXT **FirmwareContextPtr)
SBI_RET EFIAPI SbiCall(IN UINTN ExtId, IN UINTN FuncId, IN UINTN NumArgs,...)
EFI_STATUS EFIAPI TranslateError(IN UINTN SbiError)
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
UINTN Error
SBI status code.
UINTN Value
Value returned.