blob: 9a3d62b329a0d7fe8dfb0c776366fa2f2497c660 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// SPDX-FileCopyrightText: 2024 Himbeer <himbeer@disroot.org>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
const riscv = @import("../riscv.zig");
const sbi = @import("../sbi.zig");
const ExtId: usize = 0x53525354;
const FnId = enum(usize) {
Reset,
};
pub const Type = enum(u32) {
Shutdown,
ColdReboot,
WarmReboot,
};
pub const Reason = enum(u32) {
None,
SysErr,
};
pub fn reset(@"type": Type, reason: Reason) !void {
if (!try sbi.probeExt(ExtId)) {
return sbi.Error.NotSupported;
}
const type_id = @intFromEnum(@"type");
const reason_id = @intFromEnum(reason);
const ret = riscv.ecall(ExtId, @intFromEnum(FnId.Reset), type_id, reason_id, 0);
if (ret.err != 0) {
return sbierr.errorFromCode(ret.err);
}
}
|