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.
This commit is contained in:
parent
4d85da9674
commit
b08ac4817c
2 changed files with 99 additions and 0 deletions
67
kernel/drivers/opensbi/extensions/base.cpp
Normal file
67
kernel/drivers/opensbi/extensions/base.cpp
Normal file
|
@ -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<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
|
||||
|
32
kernel/drivers/opensbi/include/opensbi/extensions/base.h
Normal file
32
kernel/drivers/opensbi/include/opensbi/extensions/base.h
Normal file
|
@ -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
|
Loading…
Reference in a new issue