blob: aa410e5aaf761fb3f633acceafc9b0464a6b6f07 (
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
38
39
40
|
// SPDX-FileCopyrightText: 2024 Himbeer <himbeer@disroot.org>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
const base = @import("base.zig");
const instructions = @import("../instructions.zig");
const sbierr = @import("error.zig");
const SBIError = sbierr.SBIError;
const ExtId: usize = 0x53525354;
const FnId = enum(usize) {
Reset = 0,
};
pub const Type = enum(u32) {
Shutdown = 0,
ColdReboot = 1,
WarmReboot = 2,
};
pub const Reason = enum(u32) {
None = 0,
SysErr = 1,
};
pub fn reset(@"type": Type, reset_reason: Reason) !void {
if (!try base.probeExt(ExtId)) {
return SbiError.NotSupported;
}
const typeId = @intFromEnum(reset_type);
const reasonId = @intFromEnum(reset_reason);
const ret = instructions.ecall(ExtId, @intFromEnum(FnId.Reset), ty, reason, 0);
if (ret.err != 0) {
return sbierr.errorFromCode(ret.err);
}
}
|