OpenSBI: Added SRST(System Reset) extension

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

View file

@ -0,0 +1,28 @@
#include "opensbi/extensions/srst.h"
namespace drivers {
namespace opensbi::srst {
namespace {
enum class ExtensionId {
SRST = 0x53525354
};
enum class FunctionId {
SYSTEM_RESET
};
}
SbiRet system_reset(
ResetType reset_type,
ResetReason reset_reason) {
return ecall(
static_cast<sbiword_t>(ExtensionId::SRST),
static_cast<sbiword_t>(FunctionId::SYSTEM_RESET),
static_cast<uint32_t>(reset_type),
static_cast<uint32_t>(reset_reason));
}
} // End namespace opensbi::srst
} // End namespace drivers

View file

@ -0,0 +1,29 @@
#pragma once
#include "opensbi/opensbi.h"
namespace drivers {
namespace opensbi::srst {
enum class ResetType : uint32_t {
SHUTDOWN,
COLD_REBOOT,
WARM_REBOOT
// 0x00000003 - 0xEFFFFFFF: Reserved
// 0xF0000000 - 0xFFFFFFFF: Vendor specific
};
enum class ResetReason : uint32_t {
NO_REASON,
SYSTEM_FAILURE
// 0x00000002 - 0xDFFFFFFF: Reserved
// 0xE0000000 - 0xEFFFFFFF: SBI implimentation specific
// 0xF0000000 - 0xFFFFFFFF: Vendor or platform specific
};
SbiRet system_reset(
ResetType reset_type,
ResetReason reset_reason);
} // End namespace opensbi::srst
} // End namespace drivers

View file

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