summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Warkentin <andrei.warkentin@intel.com>2023-02-28 17:30:19 -0600
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-05-17 23:47:20 +0000
commit2900e755113c8f923e16a8b5f16258afd25221a0 (patch)
tree0ede74319d2546a1d747d2984564cb34adca7db1
parentcafb4f3f36e2101cab2ed6db3ea246a5a3e4708e (diff)
downloadedk2-2900e755113c8f923e16a8b5f16258afd25221a0.tar.gz
edk2-2900e755113c8f923e16a8b5f16258afd25221a0.tar.bz2
edk2-2900e755113c8f923e16a8b5f16258afd25221a0.zip
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>
-rw-r--r--MdePkg/Include/Library/BaseRiscVSbiLib.h42
-rw-r--r--MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.c3
2 files changed, 39 insertions, 6 deletions
diff --git a/MdePkg/Include/Library/BaseRiscVSbiLib.h b/MdePkg/Include/Library/BaseRiscVSbiLib.h
index e75520b4b8..2244165a6b 100644
--- a/MdePkg/Include/Library/BaseRiscVSbiLib.h
+++ b/MdePkg/Include/Library/BaseRiscVSbiLib.h
@@ -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
-
-/* SBI function IDs for TIME extension*/
+#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 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 (
diff --git a/MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.c b/MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.c
index 2ba8f5ed36..1141abfab9 100644
--- a/MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.c
+++ b/MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.c
@@ -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 (