OpenSBI: Added HSM(Hart State Management) extension

This commit is contained in:
Thomas Muller 2022-01-26 18:16:29 -05:00
parent a8a7c5fdc9
commit 03fcf4dbb2
Signed by: thomas
GPG key ID: AF006EB730564952
3 changed files with 92 additions and 1 deletions

View 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

View 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

View file

@ -5,7 +5,8 @@ kernel_sources += [
'extensions/base.cpp',
'extensions/timer.cpp',
'extensions/ipi.cpp',
'extensions/rfence.cpp'
'extensions/rfence.cpp',
'extensions/hsm.cpp'
),
]