VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Include/Library/BaseRiscVSbiLib.h

最後變更 在這個檔案是 101291,由 vboxsync 提交於 16 月 前

EFI/FirmwareNew: Make edk2-stable202308 build on all supported platforms (using gcc at least, msvc not tested yet), bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 4.1 KB
 
1/** @file
2 Library to call the RISC-V SBI ecalls
3
4 Copyright (c) 2021-2022, Hewlett Packard Development LP. All rights reserved.<BR>
5 Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 @par Glossary:
10 - Hart - Hardware Thread, similar to a CPU core
11
12 Currently, EDK2 needs to call SBI only to set the time and to do system reset.
13
14**/
15
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
74} EFI_RISCV_FIRMWARE_CONTEXT;
75
76//
77// EDK2 OpenSBI firmware extension return status.
78//
79typedef struct {
80 UINTN Error; ///< SBI status code
81 UINTN Value; ///< Value returned
82} SBI_RET;
83
84SBI_RET
85EFIAPI
86SbiCall (
87 IN UINTN ExtId,
88 IN UINTN FuncId,
89 IN UINTN NumArgs,
90 ...
91 );
92
93EFI_STATUS
94EFIAPI
95TranslateError (
96 IN UINTN SbiError
97 );
98
99VOID
100EFIAPI
101SbiSetTimer (
102 IN UINT64 Time
103 );
104
105EFI_STATUS
106EFIAPI
107SbiSystemReset (
108 IN UINTN ResetType,
109 IN UINTN ResetReason
110 );
111
112/**
113 Get firmware context of the calling hart.
114
115 @param[out] FirmwareContext The firmware context pointer.
116**/
117VOID
118EFIAPI
119GetFirmwareContext (
120 OUT EFI_RISCV_FIRMWARE_CONTEXT **FirmwareContext
121 );
122
123/**
124 Set firmware context of the calling hart.
125
126 @param[in] FirmwareContext The firmware context pointer.
127**/
128VOID
129EFIAPI
130SetFirmwareContext (
131 IN EFI_RISCV_FIRMWARE_CONTEXT *FirmwareContext
132 );
133
134/**
135 Get pointer to OpenSBI Firmware Context
136
137 Get the pointer of firmware context.
138
139 @param FirmwareContextPtr Pointer to retrieve pointer to the
140 Firmware Context.
141**/
142VOID
143EFIAPI
144GetFirmwareContextPointer (
145 IN OUT EFI_RISCV_FIRMWARE_CONTEXT **FirmwareContextPtr
146 );
147
148/**
149 Set pointer to OpenSBI Firmware Context
150
151 Set the pointer of firmware context.
152
153 @param FirmwareContextPtr Pointer to Firmware Context.
154**/
155VOID
156EFIAPI
157SetFirmwareContextPointer (
158 IN EFI_RISCV_FIRMWARE_CONTEXT *FirmwareContextPtr
159 );
160
161/**
162 Make ECALL in assembly
163
164 Switch to M-mode
165
166 @param[in,out] Arg0
167 @param[in,out] Arg1
168 @param[in] Arg2
169 @param[in] Arg3
170 @param[in] Arg4
171 @param[in] Arg5
172 @param[in] FID
173 @param[in] EXT
174**/
175VOID
176EFIAPI
177RiscVSbiEcall (
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
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette