110 lines
3.1 KiB
C++
110 lines
3.1 KiB
C++
#include "opensbi/extensions/legacy.h"
|
|
|
|
namespace drivers {
|
|
namespace opensbi::legacy {
|
|
|
|
namespace {
|
|
enum class ExtensionId {
|
|
SET_TIMER,
|
|
CONSOLE_PUTCHAR,
|
|
CONSOLE_GETCHAR,
|
|
CLEAR_IPI,
|
|
SEND_IPI,
|
|
REMOTE_FENCE_I,
|
|
REMOTE_SFENCE_VMA,
|
|
REMOTE_SFENCE_VMA_ASID,
|
|
SHUTDOWN
|
|
};
|
|
|
|
enum class Functionid {
|
|
UNUSED
|
|
};
|
|
}
|
|
|
|
SbiRet set_timer(std::uint64_t stime_value) {
|
|
#if __riscv_xlen == 64
|
|
return ecall(
|
|
static_cast<sbiword_t>(ExtensionId::SET_TIMER),
|
|
static_cast<sbiword_t>(Functionid::UNUSED),
|
|
stime_value);
|
|
#else
|
|
return ecall(
|
|
static_cast<sbiword_t>(ExtensionId::SET_TIMER),
|
|
static_cast<sbiword_t>(Functionid::UNUSED),
|
|
static_cast<uint32_t>(stime_value),
|
|
static_cast<uint32_t>(stime_value >> 32));
|
|
#endif
|
|
}
|
|
|
|
SbiRet console_putchar(int ch) {
|
|
return ecall(
|
|
static_cast<sbiword_t>(ExtensionId::CONSOLE_PUTCHAR),
|
|
static_cast<sbiword_t>(Functionid::UNUSED),
|
|
ch);
|
|
}
|
|
|
|
SbiRet console_getchar() {
|
|
return ecall(
|
|
static_cast<sbiword_t>(ExtensionId::CONSOLE_GETCHAR),
|
|
static_cast<sbiword_t>(Functionid::UNUSED));
|
|
}
|
|
|
|
SbiRet clear_ipmi() {
|
|
return ecall(
|
|
static_cast<sbiword_t>(ExtensionId::CLEAR_IPI),
|
|
static_cast<sbiword_t>(Functionid::UNUSED));
|
|
}
|
|
|
|
SbiRet send_ipmi(hart_mask_t hart_mask) {
|
|
return ecall(
|
|
static_cast<sbiword_t>(ExtensionId::SEND_IPI),
|
|
static_cast<sbiword_t>(Functionid::UNUSED),
|
|
reinterpret_cast<sbiword_t>(hart_mask));
|
|
}
|
|
|
|
SbiRet remote_fence_i(hart_mask_t hart_mask) {
|
|
return ecall(
|
|
static_cast<sbiword_t>(ExtensionId::REMOTE_FENCE_I),
|
|
static_cast<sbiword_t>(Functionid::UNUSED),
|
|
reinterpret_cast<sbiword_t>(hart_mask));
|
|
}
|
|
|
|
SbiRet remote_sfence_vma(
|
|
hart_mask_t hart_mask,
|
|
sbiword_t start,
|
|
sbiword_t size) {
|
|
return ecall(
|
|
static_cast<sbiword_t>(ExtensionId::REMOTE_SFENCE_VMA),
|
|
static_cast<sbiword_t>(Functionid::UNUSED),
|
|
reinterpret_cast<sbiword_t>(hart_mask),
|
|
start,
|
|
size);
|
|
}
|
|
|
|
SbiRet remote_sfence_vma_asid(
|
|
hart_mask_t hart_mask,
|
|
sbiword_t start,
|
|
sbiword_t size,
|
|
sbiword_t asid) {
|
|
return ecall(
|
|
static_cast<sbiword_t>(ExtensionId::REMOTE_SFENCE_VMA_ASID),
|
|
static_cast<sbiword_t>(Functionid::UNUSED),
|
|
reinterpret_cast<sbiword_t>(hart_mask),
|
|
start,
|
|
size,
|
|
asid);
|
|
}
|
|
|
|
void shutdown() {
|
|
ecall(
|
|
static_cast<sbiword_t>(ExtensionId::SHUTDOWN),
|
|
static_cast<sbiword_t>(Functionid::UNUSED));
|
|
|
|
// This should never be reached, explode if it is
|
|
__builtin_trap();
|
|
while(1);
|
|
}
|
|
|
|
} // End namespace opensbi::legacy
|
|
} // End namespace drivers
|
|
|