OpenSBI: Added HSM(Hart State Management) extension
This commit is contained in:
parent
a8a7c5fdc9
commit
03fcf4dbb2
3 changed files with 92 additions and 1 deletions
58
kernel/drivers/opensbi/extensions/hsm.cpp
Normal file
58
kernel/drivers/opensbi/extensions/hsm.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
#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
|
||||
|
32
kernel/drivers/opensbi/include/opensbi/extensions/hsm.h
Normal file
32
kernel/drivers/opensbi/include/opensbi/extensions/hsm.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include "opensbi/opensbi.h"
|
||||
|
||||
namespace drivers {
|
||||
namespace opensbi::hsm {
|
||||
|
||||
enum class SuspendType : uint32_t {
|
||||
RETENTIVE = 0,
|
||||
// 0x00000001 - 0x0FFFFFFF: Reserved
|
||||
// 0x10000000 - 0x7FFFFFFF: Platform specific retentive
|
||||
NON_RETENTIVE = 0x80000000
|
||||
// 0x80000001 - 0x8FFFFFFF: Reserved
|
||||
// 0x90000000 - 0xFFFFFFFF: Platform specific non-retentive
|
||||
};
|
||||
|
||||
SbiRet hart_start(
|
||||
unsigned long hartid,
|
||||
unsigned long start_addr,
|
||||
unsigned long opaque);
|
||||
|
||||
SbiRet hart_stop();
|
||||
|
||||
SbiRet hart_get_status(unsigned long hartid);
|
||||
|
||||
SbiRet hart_suspend(
|
||||
SuspendType suspend_type,
|
||||
unsigned long resume_addr,
|
||||
unsigned long opaque);
|
||||
|
||||
} // End namespace opensbi::hsm
|
||||
} // End namespace drivers
|
|
@ -5,7 +5,8 @@ kernel_sources += [
|
|||
'extensions/base.cpp',
|
||||
'extensions/timer.cpp',
|
||||
'extensions/ipi.cpp',
|
||||
'extensions/rfence.cpp'
|
||||
'extensions/rfence.cpp',
|
||||
'extensions/hsm.cpp'
|
||||
),
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue