QTechOS/kernel/drivers/opensbi/extensions/base.cpp
Quantum b08ac4817c
OpenSBI: Added base extension
General notes:

For now im just going to leave all the responses as SbiRet but once I
decide how I want to handle returning errors I would like to return more
useful values.

In the cpp file I define a enum class "ExtensionId" with only one
member. For now the thought is that its descriptive and is consistent
with how the legacy extension is written. I'll also do the same thing
with FunctionId in the legacy extension after this commit for
consistency.
2022-01-23 22:40:21 -05:00

67 lines
1.7 KiB
C++

#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<sbiword_t>(ExtensionId::BASE),
static_cast<sbiword_t>(FunctionId::GET_SPEC_VERSION));
}
SbiRet get_impl_id() {
return ecall(
static_cast<sbiword_t>(ExtensionId::BASE),
static_cast<sbiword_t>(FunctionId::GET_IMPL_ID));
}
SbiRet get_impl_version() {
return ecall(
static_cast<sbiword_t>(ExtensionId::BASE),
static_cast<sbiword_t>(FunctionId::GET_IMPL_VERSION));
}
SbiRet probe_extension(long extension_id) {
return ecall(
static_cast<sbiword_t>(ExtensionId::BASE),
static_cast<sbiword_t>(FunctionId::PROBE_EXTENSION),
extension_id);
}
SbiRet get_mvendor_id() {
return ecall(
static_cast<sbiword_t>(ExtensionId::BASE),
static_cast<sbiword_t>(FunctionId::GET_MVENDORID));
}
SbiRet get_march_id() {
return ecall(
static_cast<sbiword_t>(ExtensionId::BASE),
static_cast<sbiword_t>(FunctionId::GET_MARCHID));
}
SbiRet get_mimp_id() {
return ecall(
static_cast<sbiword_t>(ExtensionId::BASE),
static_cast<sbiword_t>(FunctionId::GET_MIMPID));
}
} // End namespace opensbi::base
} // End namespace drivers