OpenSBI: Added SRST(System Reset) extension
This commit is contained in:
parent
03fcf4dbb2
commit
e149b8d503
3 changed files with 59 additions and 1 deletions
28
kernel/drivers/opensbi/extensions/srst.cpp
Normal file
28
kernel/drivers/opensbi/extensions/srst.cpp
Normal 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
|
||||
|
29
kernel/drivers/opensbi/include/opensbi/extensions/srst.h
Normal file
29
kernel/drivers/opensbi/include/opensbi/extensions/srst.h
Normal 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
|
|
@ -6,7 +6,8 @@ kernel_sources += [
|
|||
'extensions/timer.cpp',
|
||||
'extensions/ipi.cpp',
|
||||
'extensions/rfence.cpp',
|
||||
'extensions/hsm.cpp'
|
||||
'extensions/hsm.cpp',
|
||||
'extensions/srst.cpp'
|
||||
),
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue