Hi Rebecca,

if you want to update to opensbi master, please apply this patch.
Since opensbi 0.6 hasn't been released yet, we haven't pushed the fixes yet.
Atish said it will be out soon.

diff --git a/RiscVPkg/Include/OpensbiTypes.h b/RiscVPkg/Include/OpensbiTypes.h
index 800f97759a..c77dbdec11 100644
--- a/RiscVPkg/Include/OpensbiTypes.h
+++ b/RiscVPkg/Include/OpensbiTypes.h
@@ -46,6 +46,17 @@ typedef UINT64   physical_size_t;
 #define likely(x) __builtin_expect((x), 1)
 #define unlikely(x) __builtin_expect((x), 0)
 
+#undef offsetof
+#ifdef __compiler_offsetof
+#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE,MEMBER)
+#else
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+#define container_of(ptr, type, member) ({            \
+  const typeof(((type *)0)->member) * __mptr = (ptr); \
+  (type *)((char *)__mptr - offsetof(type, member)); })
+
 #define CLAMP(a, lo, hi) MIN(MAX(a, lo), hi)
 #define ROUNDUP(a, b) ((((a)-1) / (b) + 1) * (b))
 #define ROUNDDOWN(a, b) ((a) / (b) * (b))
diff --git a/RiscVPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.inf b/RiscVPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.inf
index a5e59463f1..d966330818 100644
--- a/RiscVPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.inf
+++ b/RiscVPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.inf
@@ -22,6 +22,10 @@
   opensbi/lib/sbi/riscv_locks.c
   opensbi/lib/sbi/sbi_console.c
   opensbi/lib/sbi/sbi_ecall.c
+  opensbi/lib/sbi/sbi_ecall_vendor.c
+  opensbi/lib/sbi/sbi_ecall_replace.c
+  opensbi/lib/sbi/sbi_ecall_legacy.c
+  opensbi/lib/sbi/sbi_ecall_base.c
   opensbi/lib/sbi/sbi_emulate_csr.c
   opensbi/lib/sbi/sbi_fifo.c
   opensbi/lib/sbi/sbi_hart.c
diff --git a/RiscVPkg/Library/RiscVOpensbiLib/opensbi b/RiscVPkg/Library/RiscVOpensbiLib/opensbi
index be92da280d..ec29e1cf73 160000
--- a/RiscVPkg/Library/RiscVOpensbiLib/opensbi
+++ b/RiscVPkg/Library/RiscVOpensbiLib/opensbi
@@ -1 +1 @@
-Subproject commit be92da280d87c38a2e0adc5d3f43bab7b5468f09
+Subproject commit ec29e1cf73ffe96a646daa7c2b288aa280e4be37

Cheers,
Daniel

From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Abner Chang <abner.chang@hpe.com>
Sent: Monday, February 10, 2020 02:53
To: Rebecca Cran <rebecca@bsdio.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Chen, Gilbert <gilbert.chen@hpe.com>
Subject: Re: [edk2-devel] [staging/RISC-V-V2]: Need to bump opensbi submodule to get sbi_hfence.S etc.
 
Hi Rebecca,
The RISC-V code on edk2-staging has the corresponding changes in order to incorporate with opensbi tag v0.6, however opensbi tag v0.6 is not released yet (supposed to release in weeks ago). Our changes were made based on opensbi tag v0.6 though.
Please stay in tune with my email send to edk2 mail list for the RISC-V edk2 port readiness.
Opensbi changes often, that is expected we get build error with the master. So I will make sure everything is good once 0.6 is released.

Thanks
Abner
 

> -----Original Message-----
> From: Rebecca Cran [mailto:rebecca@bsdio.com]
> Sent: Monday, February 10, 2020 8:11 AM
> To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist)
> <abner.chang@hpe.com>; Chen, Gilbert <gilbert.chen@hpe.com>
> Subject: Re: [staging/RISC-V-V2]: Need to bump opensbi submodule to get
> sbi_hfence.S etc.
>
> On 2020-02-09 12:07, Rebecca Cran wrote:
> > I recently got a HiFive Unleashed board, and am interested in trying
> > out RISCV EDK2 firmware either on it or in Qemu.
> >
> > It looks like the opensbi submodule in
> > edk2-staging/RiscVPkg/Library/RiscVOpensbiLib/opensbi needs updated
> > though: the commit currently used -
> > be92da280d87c38a2e0adc5d3f43bab7b5468f09 - is missing files such as
> > sbi_hfence.S mentioned in
> > RiscVPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.inf .
>
>
> After updating the opensbi submodule to master, I now get a compile error:
>
>
> /home/bcran/workspace/edk2-
> staging/RiscVPkg/Library/RiscVOpensbiLib/opensbi/lib/sbi/sbi_ecall.c:
> In function 'sbi_ecall_find_extension':
> /home/bcran/workspace/edk2-
> staging/RiscVPkg/Library/RiscVOpensbiLib/opensbi/lib/sbi/sbi_ecall.c:32:11:
> error: implicit declaration of function 'container_of'
> [-Werror=implicit-function-declaration]
>   sbi_list_for_each_entry(t, &ecall_exts_list, head) {
>            ^~~~~~~~~~~~
> /home/bcran/workspace/edk2-
> staging/RiscVPkg/Library/RiscVOpensbiLib/opensbi/lib/sbi/sbi_ecall.c:32:50:
> error: expected expression before 'typeof'
>   sbi_list_for_each_entry(t, &ecall_exts_list, head) {
>                                                   ^~~~
> /home/bcran/workspace/edk2-
> staging/RiscVPkg/Library/RiscVOpensbiLib/opensbi/lib/sbi/sbi_ecall.c:32:132:
> error: expected expression before 'typeof'
>   sbi_list_for_each_entry(t, &ecall_exts_list, head) {
>
> ^
> /home/bcran/workspace/edk2-
> staging/RiscVPkg/Library/RiscVOpensbiLib/opensbi/lib/sbi/sbi_ecall.c:
> In function 'sbi_ecall_unregister_extension':
> /home/bcran/workspace/edk2-
> staging/RiscVPkg/Library/RiscVOpensbiLib/opensbi/lib/sbi/sbi_ecall.c:64:50:
> error: expected expression before 'typeof'
>   sbi_list_for_each_entry(t, &ecall_exts_list, head) {
>                                                   ^~~~
> /home/bcran/workspace/edk2-
> staging/RiscVPkg/Library/RiscVOpensbiLib/opensbi/lib/sbi/sbi_ecall.c:64:132:
> error: expected expression before 'typeof'
>   sbi_list_for_each_entry(t, &ecall_exts_list, head) {
>
> ^
> cc1: all warnings being treated as errors
>
> --
> Rebecca Cran
>