59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
|
#include "opensbi/extensions/hsm.h"
|
||
|
|
||
|
namespace drivers {
|
||
|
namespace opensbi::hsm {
|
||
|
|
||
|
namespace {
|
||
|
enum class ExtensionId {
|
||
|
HSM = 0x48534D
|
||
|
};
|
||
|
|
||
|
enum class FunctionId {
|
||
|
HART_START,
|
||
|
HART_STOP,
|
||
|
HART_GET_STATUS,
|
||
|
HART_SUSPEND
|
||
|
};
|
||
|
}
|
||
|
|
||
|
SbiRet set_hsm(
|
||
|
unsigned long hartid,
|
||
|
unsigned long start_addr,
|
||
|
unsigned long opaque) {
|
||
|
return ecall(
|
||
|
static_cast<sbiword_t>(ExtensionId::HSM),
|
||
|
static_cast<sbiword_t>(FunctionId::HART_START),
|
||
|
hartid,
|
||
|
start_addr,
|
||
|
opaque);
|
||
|
}
|
||
|
|
||
|
SbiRet hart_stop() {
|
||
|
return ecall(
|
||
|
static_cast<sbiword_t>(ExtensionId::HSM),
|
||
|
static_cast<sbiword_t>(FunctionId::HART_STOP));
|
||
|
}
|
||
|
|
||
|
SbiRet hart_get_status(unsigned long hartid) {
|
||
|
return ecall(
|
||
|
static_cast<sbiword_t>(ExtensionId::HSM),
|
||
|
static_cast<sbiword_t>(FunctionId::HART_GET_STATUS),
|
||
|
hartid);
|
||
|
}
|
||
|
|
||
|
SbiRet hart_suspend(
|
||
|
SuspendType suspend_type,
|
||
|
unsigned long resume_addr,
|
||
|
unsigned long opaque) {
|
||
|
return ecall(
|
||
|
static_cast<sbiword_t>(ExtensionId::HSM),
|
||
|
static_cast<sbiword_t>(FunctionId::HART_SUSPEND),
|
||
|
static_cast<uint32_t>(suspend_type),
|
||
|
resume_addr,
|
||
|
opaque);
|
||
|
}
|
||
|
|
||
|
} // End namespace opensbi::hsm
|
||
|
} // End namespace drivers
|
||
|
|