diff --git a/kernel/drivers/opensbi/extensions/base.cpp b/kernel/drivers/opensbi/extensions/base.cpp new file mode 100644 index 0000000..273984a --- /dev/null +++ b/kernel/drivers/opensbi/extensions/base.cpp @@ -0,0 +1,67 @@ +#include "opensbi/extensions/base.h" + +namespace drivers { +namespace opensbi::base { + + namespace { + enum class ExtensionId { + BASE = 0x10 + }; + + enum class FunctionId { + GET_SPEC_VERSION, + GET_IMPL_ID, + GET_IMPL_VERSION, + PROBE_EXTENSION, + GET_MVENDORID, + GET_MARCHID, + GET_MIMPID + }; + } + + SbiRet get_spec_version() { + return ecall( + static_cast(ExtensionId::BASE), + static_cast(FunctionId::GET_SPEC_VERSION)); + } + + SbiRet get_impl_id() { + return ecall( + static_cast(ExtensionId::BASE), + static_cast(FunctionId::GET_IMPL_ID)); + } + + SbiRet get_impl_version() { + return ecall( + static_cast(ExtensionId::BASE), + static_cast(FunctionId::GET_IMPL_VERSION)); + } + + SbiRet probe_extension(long extension_id) { + return ecall( + static_cast(ExtensionId::BASE), + static_cast(FunctionId::PROBE_EXTENSION), + extension_id); + } + + SbiRet get_mvendor_id() { + return ecall( + static_cast(ExtensionId::BASE), + static_cast(FunctionId::GET_MVENDORID)); + } + + SbiRet get_march_id() { + return ecall( + static_cast(ExtensionId::BASE), + static_cast(FunctionId::GET_MARCHID)); + } + + SbiRet get_mimp_id() { + return ecall( + static_cast(ExtensionId::BASE), + static_cast(FunctionId::GET_MIMPID)); + } + +} // End namespace opensbi::base +} // End namespace drivers + diff --git a/kernel/drivers/opensbi/include/opensbi/extensions/base.h b/kernel/drivers/opensbi/include/opensbi/extensions/base.h new file mode 100644 index 0000000..2e4fd2b --- /dev/null +++ b/kernel/drivers/opensbi/include/opensbi/extensions/base.h @@ -0,0 +1,32 @@ +#pragma once + +#include "opensbi/opensbi.h" + +namespace drivers { +namespace opensbi::base { + + enum class ImplId { + BBL, + OPENSBI, + XVISOR, + KVM, + RUSTSBI, + DIOSIX + }; + + SbiRet get_spec_version(); + + SbiRet get_impl_id(); + + SbiRet get_impl_version(); + + SbiRet probe_extension(long extension_id); + + SbiRet get_mvendor_id(); + + SbiRet get_march_id(); + + SbiRet get_mimp_id(); + +} // End namespace opensbi::base +} // End namespace drivers