summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--include/sbi/sbi_platform.h40
-rw-r--r--include/sbi/sbi_version.h8
-rw-r--r--platform/ariane-fpga/platform.c2
-rw-r--r--platform/kendryte/k210/platform.c2
-rw-r--r--platform/qemu/sifive_u/platform.c2
-rw-r--r--platform/qemu/virt/platform.c2
-rw-r--r--platform/sifive/fu540/platform.c2
-rw-r--r--platform/template/platform.c2
-rwxr-xr-xscripts/create-binary-archive.sh4
10 files changed, 55 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 3c3b046..78c28c0 100644
--- a/Makefile
+++ b/Makefile
@@ -63,8 +63,8 @@ export libsbiutils_dir=$(CURDIR)/lib/utils
export firmware_dir=$(CURDIR)/firmware
# Find library version
-OPENSBI_VERSION_MAJOR=`grep MAJOR $(include_dir)/sbi/sbi_version.h | sed 's/.*MAJOR.*\([0-9][0-9]*\)/\1/'`
-OPENSBI_VERSION_MINOR=`grep MINOR $(include_dir)/sbi/sbi_version.h | sed 's/.*MINOR.*\([0-9][0-9]*\)/\1/'`
+OPENSBI_VERSION_MAJOR=`grep "define OPENSBI_VERSION_MAJOR" $(include_dir)/sbi/sbi_version.h | sed 's/.*MAJOR.*\([0-9][0-9]*\)/\1/'`
+OPENSBI_VERSION_MINOR=`grep "define OPENSBI_VERSION_MINOR" $(include_dir)/sbi/sbi_version.h | sed 's/.*MINOR.*\([0-9][0-9]*\)/\1/'`
# Setup compilation commands
ifdef CROSS_COMPILE
diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
index 824522e..4399378 100644
--- a/include/sbi/sbi_platform.h
+++ b/include/sbi/sbi_platform.h
@@ -10,21 +10,32 @@
#ifndef __SBI_PLATFORM_H__
#define __SBI_PLATFORM_H__
+/** OpenSBI 32-bit platform version with:
+ * 1. upper 16-bits as major number
+ * 2. lower 16-bits as minor number
+ */
+#define SBI_PLATFORM_VERSION(Major, Minor) ((Major << 16) | Minor)
+
+/** Offset of opensbi_version in struct sbi_platform */
+#define SBI_PLATFORM_OPENSBI_VERSION_OFFSET (0x00)
+/** Offset of platform_version in struct sbi_platform */
+#define SBI_PLATFORM_VERSION_OFFSET (0x04)
/** Offset of name in struct sbi_platform */
-#define SBI_PLATFORM_NAME_OFFSET (0x0)
+#define SBI_PLATFORM_NAME_OFFSET (0x08)
/** Offset of features in struct sbi_platform */
-#define SBI_PLATFORM_FEATURES_OFFSET (0x40)
+#define SBI_PLATFORM_FEATURES_OFFSET (0x48)
/** Offset of hart_count in struct sbi_platform */
-#define SBI_PLATFORM_HART_COUNT_OFFSET (0x48)
+#define SBI_PLATFORM_HART_COUNT_OFFSET (0x50)
/** Offset of hart_stack_size in struct sbi_platform */
-#define SBI_PLATFORM_HART_STACK_SIZE_OFFSET (0x4c)
+#define SBI_PLATFORM_HART_STACK_SIZE_OFFSET (0x54)
/** Offset of disabled_hart_mask in struct sbi_platform */
-#define SBI_PLATFORM_DISABLED_HART_OFFSET (0x50)
+#define SBI_PLATFORM_DISABLED_HART_OFFSET (0x58)
/** Offset of platform_ops_addr in struct sbi_platform */
-#define SBI_PLATFORM_OPS_OFFSET (0x58)
+#define SBI_PLATFORM_OPS_OFFSET (0x60)
#ifndef __ASSEMBLY__
+#include <sbi/sbi_version.h>
#include <sbi/sbi_scratch.h>
/** Possible feature flags of a platform */
@@ -101,6 +112,18 @@ struct sbi_platform_operations {
/** Representation of a platform */
struct sbi_platform {
+ /**
+ * OpenSBI version this sbi_platform is based on.
+ * It's a 32-bit value where upper 16-bits are major number
+ * and lower 16-bits are minor number
+ */
+ u32 opensbi_version;
+ /**
+ * OpenSBI platform version released by vendor.
+ * It's a 32-bit value where upper 16-bits are major number
+ * and lower 16-bits are minor number
+ */
+ u32 platform_version;
/** Name of the platform */
char name[64];
/** Supported features */
@@ -119,9 +142,8 @@ struct sbi_platform {
#define sbi_platform_ptr(__s) \
((const struct sbi_platform *)((__s)->platform_addr))
/** Get pointer to sbi_platform for current HART */
-#define sbi_platform_thishart_ptr() \
- ((const struct sbi_platform *)(sbi_scratch_thishart_ptr() \
- >platform_addr))
+#define sbi_platform_thishart_ptr() ((const struct sbi_platform *) \
+ (sbi_scratch_thishart_ptr()->platform_addr))
/** Get pointer to platform_ops_addr from platform pointer **/
#define sbi_platform_ops(__p) \
((const struct sbi_platform_operations *)(__p)->platform_ops_addr)
diff --git a/include/sbi/sbi_version.h b/include/sbi/sbi_version.h
index 90020ac..d1c39b0 100644
--- a/include/sbi/sbi_version.h
+++ b/include/sbi/sbi_version.h
@@ -13,4 +13,12 @@
#define OPENSBI_VERSION_MAJOR 0
#define OPENSBI_VERSION_MINOR 3
+/**
+ * OpenSBI 32-bit version with:
+ * 1. upper 16-bits as major number
+ * 2. lower 16-bits as minor number
+ */
+#define OPENSBI_VERSION ((OPENSBI_VERSION_MAJOR << 16) | \
+ (OPENSBI_VERSION_MINOR))
+
#endif
diff --git a/platform/ariane-fpga/platform.c b/platform/ariane-fpga/platform.c
index 9dbf333..62cee90 100644
--- a/platform/ariane-fpga/platform.c
+++ b/platform/ariane-fpga/platform.c
@@ -196,6 +196,8 @@ const struct sbi_platform_operations platform_ops = {
};
const struct sbi_platform platform = {
+ .opensbi_version = OPENSBI_VERSION,
+ .platform_version = SBI_PLATFORM_VERSION(0x0, 0x01),
.name = "ARIANE RISC-V",
.features = SBI_ARIANE_FEATURES,
.hart_count = ARIANE_HART_COUNT,
diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c
index f332dab..4c31ee9 100644
--- a/platform/kendryte/k210/platform.c
+++ b/platform/kendryte/k210/platform.c
@@ -115,6 +115,8 @@ const struct sbi_platform_operations platform_ops = {
};
const struct sbi_platform platform = {
+ .opensbi_version = OPENSBI_VERSION,
+ .platform_version = SBI_PLATFORM_VERSION(0x0, 0x01),
.name = "Kendryte K210",
.features = SBI_PLATFORM_HAS_TIMER_VALUE,
.hart_count = K210_HART_COUNT,
diff --git a/platform/qemu/sifive_u/platform.c b/platform/qemu/sifive_u/platform.c
index aaacb3f..d8b586f 100644
--- a/platform/qemu/sifive_u/platform.c
+++ b/platform/qemu/sifive_u/platform.c
@@ -148,6 +148,8 @@ const struct sbi_platform_operations platform_ops = {
};
const struct sbi_platform platform = {
+ .opensbi_version = OPENSBI_VERSION,
+ .platform_version = SBI_PLATFORM_VERSION(0x0, 0x01),
.name = "QEMU SiFive Unleashed",
.features = SBI_PLATFORM_DEFAULT_FEATURES,
.hart_count = SIFIVE_U_HART_COUNT,
diff --git a/platform/qemu/virt/platform.c b/platform/qemu/virt/platform.c
index dbe593b..1cf0b7d 100644
--- a/platform/qemu/virt/platform.c
+++ b/platform/qemu/virt/platform.c
@@ -153,6 +153,8 @@ const struct sbi_platform_operations platform_ops = {
};
const struct sbi_platform platform = {
+ .opensbi_version = OPENSBI_VERSION,
+ .platform_version = SBI_PLATFORM_VERSION(0x0, 0x01),
.name = "QEMU Virt Machine",
.features = SBI_PLATFORM_DEFAULT_FEATURES,
.hart_count = VIRT_HART_COUNT,
diff --git a/platform/sifive/fu540/platform.c b/platform/sifive/fu540/platform.c
index e67f20a..46b48b8 100644
--- a/platform/sifive/fu540/platform.c
+++ b/platform/sifive/fu540/platform.c
@@ -209,6 +209,8 @@ const struct sbi_platform_operations platform_ops = {
};
const struct sbi_platform platform = {
+ .opensbi_version = OPENSBI_VERSION,
+ .platform_version = SBI_PLATFORM_VERSION(0x0, 0x01),
.name = "SiFive Freedom U540",
.features = SBI_PLATFORM_DEFAULT_FEATURES,
.hart_count = FU540_HART_COUNT,
diff --git a/platform/template/platform.c b/platform/template/platform.c
index 2ba549f..148bfa9 100644
--- a/platform/template/platform.c
+++ b/platform/template/platform.c
@@ -227,6 +227,8 @@ const struct sbi_platform_operations platform_ops = {
.system_shutdown = platform_system_down
};
const struct sbi_platform platform = {
+ .opensbi_version = OPENSBI_VERSION,
+ .platform_version = SBI_PLATFORM_VERSION(0x0, 0x00),
.name = "platform-name",
.features = SBI_PLATFORM_DEFAULT_FEATURES,
.hart_count = 1,
diff --git a/scripts/create-binary-archive.sh b/scripts/create-binary-archive.sh
index d5890fc..fcfb5cb 100755
--- a/scripts/create-binary-archive.sh
+++ b/scripts/create-binary-archive.sh
@@ -74,8 +74,8 @@ if [ -z "${BUILD_ARCHIVE_SUFFIX}" ]; then
fi
# Get version of OpenSBI
-BUILD_VERSION_MAJOR=$(grep MAJOR "${BUILD_OPENSBI_SOURCE_PATH}/include/sbi/sbi_version.h" | sed 's/.*MAJOR.*\([0-9][0-9]*\)/\1/')
-BUILD_VERSION_MINOR=$(grep MINOR "${BUILD_OPENSBI_SOURCE_PATH}/include/sbi/sbi_version.h" | sed 's/.*MINOR.*\([0-9][0-9]*\)/\1/')
+BUILD_VERSION_MAJOR=$(grep "define OPENSBI_VERSION_MAJOR" "${BUILD_OPENSBI_SOURCE_PATH}/include/sbi/sbi_version.h" | sed 's/.*MAJOR.*\([0-9][0-9]*\)/\1/')
+BUILD_VERSION_MINOR=$(grep "define OPENSBI_VERSION_MINOR" "${BUILD_OPENSBI_SOURCE_PATH}/include/sbi/sbi_version.h" | sed 's/.*MINOR.*\([0-9][0-9]*\)/\1/')
# Setup archive name
BUILD_ARCHIVE_NAME="opensbi-${BUILD_VERSION_MAJOR}.${BUILD_VERSION_MINOR}-rv${BUILD_RISCV_XLEN}-${BUILD_ARCHIVE_SUFFIX}"