public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Andrei Warkentin" <andrei.warkentin@intel.com>
To: devel@edk2.groups.io
Cc: Andrei Warkentin <andrei.warkentin@intel.com>,
	Daniel Schaefer <git@danielschaefer.me>,
	Sunil V L <sunilvl@ventanamicro.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [edk2 1/3] MdePkg: BaseRiscVSbiLib: make more useful to consumers
Date: Fri,  3 Mar 2023 12:04:08 -0600	[thread overview]
Message-ID: <20230303180410.6344-2-andrei.warkentin@intel.com> (raw)
In-Reply-To: <20230303180410.6344-1-andrei.warkentin@intel.com>

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

Cc: Daniel Schaefer <git@danielschaefer.me>
Cc: Sunil V L <sunilvl@ventanamicro.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Andrei Warkentin <andrei.warkentin@intel.com>
---
 MdePkg/Include/Library/BaseRiscVSbiLib.h         | 40 ++++++++++++++++++--
 MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.c |  3 +-
 2 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/MdePkg/Include/Library/BaseRiscVSbiLib.h b/MdePkg/Include/Library/BaseRiscVSbiLib.h
index e75520b4b888..2244165a6b6a 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
+#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 (
diff --git a/MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.c b/MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.c
index 2ba8f5ed366a..1141abfab9d0 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 (
-- 
2.25.1


  reply	other threads:[~2023-03-03 18:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 18:04 [edk2 0/3] v3 RISC-V SBI-backed SerialLib Andrei Warkentin
2023-03-03 18:04 ` Andrei Warkentin [this message]
2023-03-10  6:23   ` [edk2 1/3] MdePkg: BaseRiscVSbiLib: make more useful to consumers Sunil V L
2023-03-03 18:04 ` [edk2 2/3] [PATCH v3] MdePkg: add SBI-based SeriaPortLib for RISC-V Andrei Warkentin
2023-03-10  7:19   ` Sunil V L
2023-03-03 18:04 ` [edk2 3/3] OvmfPkg: RiscVVirt: Add missing SerialPortInitialize to Sec Andrei Warkentin
2023-03-10  6:26   ` [edk2-devel] " Sunil V L
  -- strict thread matches above, loose matches on Subject: below --
2023-03-02 21:49 [edk2 0/3] v2 RISC-V SBI-backed SerialLib Andrei Warkentin
2023-03-02 21:49 ` [edk2 1/3] MdePkg: BaseRiscVSbiLib: make more useful to consumers Andrei Warkentin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230303180410.6344-2-andrei.warkentin@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox