Page MenuHomeFreeBSD

D22327.id64223.diff
No OneTemporary

D22327.id64223.diff

Index: sys/riscv/include/sbi.h
===================================================================
--- sys/riscv/include/sbi.h
+++ sys/riscv/include/sbi.h
@@ -41,8 +41,7 @@
/* SBI Specification Version */
#define SBI_SPEC_VERS_MAJOR_OFFSET 24
#define SBI_SPEC_VERS_MAJOR_MASK (0x7F << SBI_SPEC_VERS_MAJOR_OFFSET)
-#define SBI_SPEC_VERS_MINOR_OFFSET 0
-#define SBI_SPEC_VERS_MINOR_MASK (0xFFFFFF << SBI_SPEC_VERS_MINOR_OFFSET)
+#define SBI_SPEC_VERS_MINOR_MASK (0xFFFFFF)
/* SBI Implementation IDs */
#define SBI_IMPL_ID_BBL 0
@@ -197,6 +196,7 @@
start, size, asid);
}
+void sbi_print_version(void);
void sbi_init(void);
#endif /* !_MACHINE_SBI_H_ */
Index: sys/riscv/riscv/machdep.c
===================================================================
--- sys/riscv/riscv/machdep.c
+++ sys/riscv/riscv/machdep.c
@@ -128,6 +128,7 @@
cpu_startup(void *dummy)
{
+ sbi_print_version();
identify_cpu();
printf("real memory = %ju (%ju MB)\n", ptoa((uintmax_t)realmem),
Index: sys/riscv/riscv/sbi.c
===================================================================
--- sys/riscv/riscv/sbi.c
+++ sys/riscv/riscv/sbi.c
@@ -32,6 +32,9 @@
#include <machine/md_var.h>
#include <machine/sbi.h>
+#define OPENSBI_VERSION_MAJOR_OFFSET 16
+#define OPENSBI_VERSION_MINOR_MASK 0xFFFF
+
u_int sbi_spec_version;
u_int sbi_impl_id;
u_int sbi_impl_version;
@@ -73,6 +76,39 @@
return (SBI_CALL0(SBI_EXT_ID_BASE, SBI_BASE_GET_MIMPID));
}
+void
+sbi_print_version(void)
+{
+ u_int major;
+ u_int minor;
+
+ /* For legacy SBI implementations. */
+ if (sbi_spec_version == 0) {
+ printf("SBI: Unknown (Legacy) Implementation\n");
+ printf("SBI Specification Version: 0.1\n");
+ return;
+ }
+
+ switch (sbi_impl_id) {
+ case (SBI_IMPL_ID_BBL):
+ printf("SBI: Berkely Boot Loader %u\n", sbi_impl_version);
+ break;
+ case (SBI_IMPL_ID_OPENSBI):
+ major = sbi_impl_version >> OPENSBI_VERSION_MAJOR_OFFSET;
+ minor = sbi_impl_version & OPENSBI_VERSION_MINOR_MASK;
+ printf("SBI: OpenSBI v%u.%u\n", major, minor);
+ break;
+ default:
+ printf("SBI: Unrecognized Implementation: %u\n", sbi_impl_id);
+ break;
+ }
+
+ major = (sbi_spec_version & SBI_SPEC_VERS_MAJOR_MASK) >>
+ SBI_SPEC_VERS_MAJOR_OFFSET;
+ minor = (sbi_spec_version & SBI_SPEC_VERS_MINOR_MASK);
+ printf("SBI Specification Version: %u.%u\n", major, minor);
+}
+
void
sbi_init(void)
{

File Metadata

Mime Type
text/plain
Expires
Wed, Mar 4, 10:45 PM (14 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29259186
Default Alt Text
D22327.id64223.diff (2 KB)

Event Timeline