Karg
v0.2.0
The kernel of CargOS
sbi.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
types.h
>
4
5
typedef
struct
{
6
isize
err
;
7
isize
val
;
8
}
sbi_res_t
;
9
10
sbi_res_t
sbi_ecall
(
i32
eid,
i32
fid, ...);
11
i32
sbi_map_err
(
isize
err);
12
13
#define SBI_EID_TIME 0x54494D45
14
15
static
inline
i32
sbi_set_timer(
u64
time
) {
16
return
sbi_map_err
(
sbi_ecall
(
SBI_EID_TIME
, 0,
time
).err);
17
}
18
19
#define SBI_EID_SRST 0x53525354
20
21
typedef
enum
{
22
SBI_REBOOT_TYPE_SHUTDOWN
= 0,
23
SBI_REBOOT_TYPE_REBOOT
= 1,
24
}
sbi_reboot_type_t
;
25
26
typedef
enum
{
27
SBI_REBOOT_REASON_NONE
= 0,
28
}
sbi_reboot_reason_t
;
29
30
static
inline
i32
sbi_reboot(
sbi_reboot_type_t
type,
31
sbi_reboot_reason_t
reason) {
32
return
sbi_map_err
(
sbi_ecall
(
SBI_EID_SRST
, 0, type, reason).err);
33
}
sbi_reboot_reason_t
sbi_reboot_reason_t
Definition:
sbi.h:26
SBI_REBOOT_REASON_NONE
@ SBI_REBOOT_REASON_NONE
Definition:
sbi.h:27
SBI_EID_SRST
#define SBI_EID_SRST
Definition:
sbi.h:19
sbi_reboot_type_t
sbi_reboot_type_t
Definition:
sbi.h:21
SBI_REBOOT_TYPE_SHUTDOWN
@ SBI_REBOOT_TYPE_SHUTDOWN
Definition:
sbi.h:22
SBI_REBOOT_TYPE_REBOOT
@ SBI_REBOOT_TYPE_REBOOT
Definition:
sbi.h:23
sbi_map_err
i32 sbi_map_err(isize err)
Definition:
sbi.c:38
sbi_ecall
sbi_res_t sbi_ecall(i32 eid, i32 fid,...)
SBI_EID_TIME
#define SBI_EID_TIME
Definition:
sbi.h:13
sbi_res_t
Definition:
sbi.h:5
sbi_res_t::err
isize err
Definition:
sbi.h:6
sbi_res_t::val
isize val
Definition:
sbi.h:7
time
time_t time(void)
Definition:
time.c:5
types.h
isize
__INTPTR_TYPE__ isize
Definition:
types.h:29
i32
__INT32_TYPE__ i32
Definition:
types.h:15
u64
__UINT64_TYPE__ u64
Definition:
types.h:6
include
arch
riscv
sbi.h
Generated by
1.9.1