diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-04-17 13:40:56 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-04-17 13:40:56 +0300 |
| commit | 1ceed7525272b82c1028ebd353e65c3a63bd2714 (patch) | |
| tree | 828105db350e36df681bf79740434b47e6748e36 /arch/riscv64/kernel/power.c | |
| parent | 2a256aa4f1abb65afa6f3856998bfe00ac960d61 (diff) | |
| download | kmi-1ceed7525272b82c1028ebd353e65c3a63bd2714.tar.gz kmi-1ceed7525272b82c1028ebd353e65c3a63bd2714.zip | |
expand sbi implementation a bit
Diffstat (limited to 'arch/riscv64/kernel/power.c')
| -rw-r--r-- | arch/riscv64/kernel/power.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/arch/riscv64/kernel/power.c b/arch/riscv64/kernel/power.c new file mode 100644 index 0000000..877c001 --- /dev/null +++ b/arch/riscv64/kernel/power.c @@ -0,0 +1,31 @@ +#include <apos/power.h> +#include <sbi.h> + +/* shutdown reason */ +#define SBI_NO_REASON 0 + +/* shutdown type */ +#define SBI_SHUTDOWN 0 +#define SBI_COLD_REBOOT 1 +#define SBI_WARM_REBOOT 2 + +stat_t poweroff(enum poweroff_type type) +{ + /* TODO: this only shuts down the cpu itself, but may leave the SOC + * active. Should read from fdt poweroff and syscon-poweroff etc */ + switch (type) { + case SHUTDOWN: + sbi_system_reset(SBI_SHUTDOWN, SBI_NO_REASON); + return ERR_MISC; + + case COLD_REBOOT: + sbi_system_reset(SBI_COLD_REBOOT, SBI_NO_REASON); + return ERR_MISC; + + case WARM_REBOOT: + sbi_system_reset(SBI_WARM_REBOOT, SBI_NO_REASON); + return ERR_MISC; + }; + + return ERR_INVAL; +} |
