TianoCore EDK2 master
Loading...
Searching...
No Matches
BaseRiscVSbiLib.h File Reference
#include <Uefi.h>

Go to the source code of this file.

Data Structures

struct  EFI_RISCV_FIRMWARE_CONTEXT
 
struct  SBI_RET
 

Macros

#define SBI_EXT_0_1_CONSOLE_PUTCHAR   0x1
 
#define SBI_EXT_0_1_CONSOLE_GETCHAR   0x2
 
#define SBI_EXT_BASE   0x10
 
#define SBI_EXT_DBCN   0x4442434E
 
#define SBI_EXT_TIME   0x54494D45
 
#define SBI_EXT_SRST   0x53525354
 
#define SBI_EXT_BASE_SPEC_VERSION   0x0
 
#define SBI_EXT_BASE_IMPL_ID   0x1
 
#define SBI_EXT_BASE_IMPL_VERSION   0x2
 
#define SBI_EXT_BASE_PROBE_EXT   0x3
 
#define SBI_EXT_BASE_GET_MVENDORID   0x4
 
#define SBI_EXT_BASE_GET_MARCHID   0x5
 
#define SBI_EXT_BASE_GET_MIMPID   0x6
 
#define SBI_EXT_DBCN_WRITE   0x0
 
#define SBI_EXT_DBCN_READ   0x1
 
#define SBI_EXT_DBCN_WRITE_BYTE   0x2
 
#define SBI_EXT_TIME_SET_TIMER   0x0
 
#define SBI_EXT_SRST_RESET   0x0
 
#define SBI_SRST_RESET_TYPE_SHUTDOWN   0x0
 
#define SBI_SRST_RESET_TYPE_COLD_REBOOT   0x1
 
#define SBI_SRST_RESET_TYPE_WARM_REBOOT   0x2
 
#define SBI_SRST_RESET_REASON_NONE   0x0
 
#define SBI_SRST_RESET_REASON_SYSFAIL   0x1
 
#define SBI_SUCCESS   0
 
#define SBI_ERR_FAILED   -1
 
#define SBI_ERR_NOT_SUPPORTED   -2
 
#define SBI_ERR_INVALID_PARAM   -3
 
#define SBI_ERR_DENIED   -4
 
#define SBI_ERR_INVALID_ADDRESS   -5
 
#define SBI_ERR_ALREADY_AVAILABLE   -6
 
#define SBI_ERR_ALREADY_STARTED   -7
 
#define SBI_ERR_ALREADY_STOPPED   -8
 
#define SBI_LAST_ERR   SBI_ERR_ALREADY_STOPPED
 

Functions

SBI_RET EFIAPI SbiCall (IN UINTN ExtId, IN UINTN FuncId, IN UINTN NumArgs,...)
 
EFI_STATUS EFIAPI TranslateError (IN UINTN SbiError)
 
VOID EFIAPI SbiSetTimer (IN UINT64 Time)
 
EFI_STATUS EFIAPI SbiSystemReset (IN UINTN ResetType, IN UINTN ResetReason)
 
VOID EFIAPI GetFirmwareContext (OUT EFI_RISCV_FIRMWARE_CONTEXT **FirmwareContext)
 
VOID EFIAPI SetFirmwareContext (IN EFI_RISCV_FIRMWARE_CONTEXT *FirmwareContext)
 
VOID EFIAPI GetFirmwareContextPointer (IN OUT EFI_RISCV_FIRMWARE_CONTEXT **FirmwareContextPtr)
 
VOID EFIAPI SetFirmwareContextPointer (IN EFI_RISCV_FIRMWARE_CONTEXT *FirmwareContextPtr)
 
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)
 

Detailed Description

Library to call the RISC-V SBI ecalls

Copyright (c) 2021-2022, Hewlett Packard Development LP. All rights reserved.
Copyright (c) 2023, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Glossary:
  • Hart - Hardware Thread, similar to a CPU core

Currently, EDK2 needs to call SBI only to set the time and to do system reset.

Definition in file BaseRiscVSbiLib.h.

Macro Definition Documentation

◆ SBI_ERR_ALREADY_AVAILABLE

#define SBI_ERR_ALREADY_AVAILABLE   -6

Definition at line 63 of file BaseRiscVSbiLib.h.

◆ SBI_ERR_ALREADY_STARTED

#define SBI_ERR_ALREADY_STARTED   -7

Definition at line 64 of file BaseRiscVSbiLib.h.

◆ SBI_ERR_ALREADY_STOPPED

#define SBI_ERR_ALREADY_STOPPED   -8

Definition at line 65 of file BaseRiscVSbiLib.h.

◆ SBI_ERR_DENIED

#define SBI_ERR_DENIED   -4

Definition at line 61 of file BaseRiscVSbiLib.h.

◆ SBI_ERR_FAILED

#define SBI_ERR_FAILED   -1

Definition at line 58 of file BaseRiscVSbiLib.h.

◆ SBI_ERR_INVALID_ADDRESS

#define SBI_ERR_INVALID_ADDRESS   -5

Definition at line 62 of file BaseRiscVSbiLib.h.

◆ SBI_ERR_INVALID_PARAM

#define SBI_ERR_INVALID_PARAM   -3

Definition at line 60 of file BaseRiscVSbiLib.h.

◆ SBI_ERR_NOT_SUPPORTED

#define SBI_ERR_NOT_SUPPORTED   -2

Definition at line 59 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_0_1_CONSOLE_GETCHAR

#define SBI_EXT_0_1_CONSOLE_GETCHAR   0x2

Definition at line 23 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_0_1_CONSOLE_PUTCHAR

#define SBI_EXT_0_1_CONSOLE_PUTCHAR   0x1

Definition at line 22 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_BASE

#define SBI_EXT_BASE   0x10

Definition at line 24 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_BASE_GET_MARCHID

#define SBI_EXT_BASE_GET_MARCHID   0x5

Definition at line 35 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_BASE_GET_MIMPID

#define SBI_EXT_BASE_GET_MIMPID   0x6

Definition at line 36 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_BASE_GET_MVENDORID

#define SBI_EXT_BASE_GET_MVENDORID   0x4

Definition at line 34 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_BASE_IMPL_ID

#define SBI_EXT_BASE_IMPL_ID   0x1

Definition at line 31 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_BASE_IMPL_VERSION

#define SBI_EXT_BASE_IMPL_VERSION   0x2

Definition at line 32 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_BASE_PROBE_EXT

#define SBI_EXT_BASE_PROBE_EXT   0x3

Definition at line 33 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_BASE_SPEC_VERSION

#define SBI_EXT_BASE_SPEC_VERSION   0x0

Definition at line 30 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_DBCN

#define SBI_EXT_DBCN   0x4442434E

Definition at line 25 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_DBCN_READ

#define SBI_EXT_DBCN_READ   0x1

Definition at line 40 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_DBCN_WRITE

#define SBI_EXT_DBCN_WRITE   0x0

Definition at line 39 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_DBCN_WRITE_BYTE

#define SBI_EXT_DBCN_WRITE_BYTE   0x2

Definition at line 41 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_SRST

#define SBI_EXT_SRST   0x53525354

Definition at line 27 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_SRST_RESET

#define SBI_EXT_SRST_RESET   0x0

Definition at line 47 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_TIME

#define SBI_EXT_TIME   0x54494D45

Definition at line 26 of file BaseRiscVSbiLib.h.

◆ SBI_EXT_TIME_SET_TIMER

#define SBI_EXT_TIME_SET_TIMER   0x0

Definition at line 44 of file BaseRiscVSbiLib.h.

◆ SBI_LAST_ERR

#define SBI_LAST_ERR   SBI_ERR_ALREADY_STOPPED

Definition at line 67 of file BaseRiscVSbiLib.h.

◆ SBI_SRST_RESET_REASON_NONE

#define SBI_SRST_RESET_REASON_NONE   0x0

Definition at line 53 of file BaseRiscVSbiLib.h.

◆ SBI_SRST_RESET_REASON_SYSFAIL

#define SBI_SRST_RESET_REASON_SYSFAIL   0x1

Definition at line 54 of file BaseRiscVSbiLib.h.

◆ SBI_SRST_RESET_TYPE_COLD_REBOOT

#define SBI_SRST_RESET_TYPE_COLD_REBOOT   0x1

Definition at line 50 of file BaseRiscVSbiLib.h.

◆ SBI_SRST_RESET_TYPE_SHUTDOWN

#define SBI_SRST_RESET_TYPE_SHUTDOWN   0x0

Definition at line 49 of file BaseRiscVSbiLib.h.

◆ SBI_SRST_RESET_TYPE_WARM_REBOOT

#define SBI_SRST_RESET_TYPE_WARM_REBOOT   0x2

Definition at line 51 of file BaseRiscVSbiLib.h.

◆ SBI_SUCCESS

#define SBI_SUCCESS   0

Definition at line 57 of file BaseRiscVSbiLib.h.

Function Documentation

◆ GetFirmwareContext()

VOID EFIAPI GetFirmwareContext ( OUT EFI_RISCV_FIRMWARE_CONTEXT **  FirmwareContext)

Get firmware context of the calling hart.

Parameters
[out]FirmwareContextThe firmware context pointer.

Definition at line 178 of file BaseRiscVSbiLib.c.

◆ GetFirmwareContextPointer()

VOID EFIAPI GetFirmwareContextPointer ( IN OUT EFI_RISCV_FIRMWARE_CONTEXT **  FirmwareContextPtr)

Get pointer to OpenSBI Firmware Context

Get the pointer of firmware context.

Parameters
FirmwareContextPtrPointer to retrieve pointer to the Firmware Context.

Get pointer to OpenSBI Firmware Context

Get the pointer of firmware context through OpenSBI FW Extension SBI.

Parameters
FirmwareContextPtrPointer to retrieve pointer to the Firmware Context.

Definition at line 209 of file BaseRiscVSbiLib.c.

◆ RiscVSbiEcall()

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 
)

Make ECALL in assembly

Switch to M-mode

Parameters
[in,out]Arg0
[in,out]Arg1
[in]Arg2
[in]Arg3
[in]Arg4
[in]Arg5
[in]FID
[in]EXT

◆ SbiCall()

SBI_RET EFIAPI SbiCall ( IN UINTN  ExtId,
IN UINTN  FuncId,
IN UINTN  NumArgs,
  ... 
)

Call SBI call using ecall instruction.

Asserts when NumArgs exceeds SBI_CALL_MAX_ARGS.

Parameters
[in]ExtIdSBI extension ID.
[in]FuncIdSBI function ID.
[in]NumArgsNumber of arguments to pass to the ecall.
[in]...Argument list for the ecall.
Return values
ReturnsSBI_RET structure with value and error code.

Definition at line 37 of file BaseRiscVSbiLib.c.

◆ SbiSetTimer()

VOID EFIAPI SbiSetTimer ( IN UINT64  Time)

Clear pending timer interrupt bit and set timer for next event after Time.

To clear the timer without scheduling a timer event, set Time to a practically infinite value or mask the timer interrupt by clearing sie.STIE.

Parameters
[in]TimeThe time offset to the next scheduled timer interrupt.

Definition at line 138 of file BaseRiscVSbiLib.c.

◆ SbiSystemReset()

EFI_STATUS EFIAPI SbiSystemReset ( IN UINTN  ResetType,
IN UINTN  ResetReason 
)

Reset the system using SRST SBI extenion

Parameters
[in]ResetTypeThe SRST System Reset Type.
[in]ResetReasonThe SRST System Reset Reason.

Definition at line 153 of file BaseRiscVSbiLib.c.

◆ SetFirmwareContext()

VOID EFIAPI SetFirmwareContext ( IN EFI_RISCV_FIRMWARE_CONTEXT FirmwareContext)

Set firmware context of the calling hart.

Parameters
[in]FirmwareContextThe firmware context pointer.

Definition at line 192 of file BaseRiscVSbiLib.c.

◆ SetFirmwareContextPointer()

VOID EFIAPI SetFirmwareContextPointer ( IN EFI_RISCV_FIRMWARE_CONTEXT FirmwareContextPtr)

Set pointer to OpenSBI Firmware Context

Set the pointer of firmware context.

Parameters
FirmwareContextPtrPointer to Firmware Context.

Set the pointer to OpenSBI Firmware Context

Set the pointer of firmware context through OpenSBI FW Extension SBI.

Parameters
FirmwareContextPtrPointer to Firmware Context.

Definition at line 225 of file BaseRiscVSbiLib.c.

◆ TranslateError()

EFI_STATUS EFIAPI TranslateError ( IN UINTN  SbiError)

Translate SBI error code to EFI status.

Parameters
[in]SbiErrorSBI error code
Return values
EFI_STATUS

Definition at line 93 of file BaseRiscVSbiLib.c.