MdePkg: BaseRiscVSbiLib: make more useful to consumers

Add a few more definitions and make SbiCall and TranslateError
usable (not static) by library users.

Cc: Daniel Schaefer <git@danielschaefer.me>
Signed-off-by: Andrei Warkentin <andrei.warkentin@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Andrei Warkentin 2023-02-28 17:30:19 -06:00 committed by mergify[bot]
parent cafb4f3f36
commit 2900e75511
2 changed files with 38 additions and 5 deletions

View File

@ -2,6 +2,7 @@
Library to call the RISC-V SBI ecalls
Copyright (c) 2021-2022, Hewlett Packard Development LP. All rights reserved.<BR>
Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@ -18,10 +19,28 @@
#include <Uefi.h>
/* SBI Extension IDs */
#define SBI_EXT_TIME 0x54494D45
#define SBI_EXT_SRST 0x53525354
#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
/* SBI function IDs for TIME extension*/
/* SBI function IDs for base extension */
#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
/* SBI function IDs for DBCN extension */
#define SBI_EXT_DBCN_WRITE 0x0
#define SBI_EXT_DBCN_READ 0x1
#define SBI_EXT_DBCN_WRITE_BYTE 0x2
/* SBI function IDs for TIME extension */
#define SBI_EXT_TIME_SET_TIMER 0x0
/* SBI function IDs for SRST extension */
@ -62,6 +81,21 @@ typedef struct {
UINTN Value; ///< Value returned
} SBI_RET;
SBI_RET
EFIAPI
SbiCall (
IN UINTN ExtId,
IN UINTN FuncId,
IN UINTN NumArgs,
...
);
EFI_STATUS
EFIAPI
TranslateError (
IN UINTN SbiError
);
VOID
EFIAPI
SbiSetTimer (

View File

@ -4,6 +4,7 @@
It allows calling an SBI function via an ecall from S-Mode.
Copyright (c) 2021-2022, Hewlett Packard Development LP. All rights reserved.<BR>
Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@ -31,7 +32,6 @@
@retval Returns SBI_RET structure with value and error code.
**/
STATIC
SBI_RET
EFIAPI
SbiCall (
@ -88,7 +88,6 @@ SbiCall (
@param[in] SbiError SBI error code
@retval EFI_STATUS
**/
STATIC
EFI_STATUS
EFIAPI
TranslateError (