SimpleKernel
0.0.1
boot.cpp
Go to the documentation of this file.
1
17
#ifdef __cplusplus
18
extern
"C"
{
19
#endif
20
21
#include "cstdint"
22
23
#include "sbi/sbi_ecall_interface.h"
24
25
struct
sbiret_t
{
27
long
error
;
29
long
value
;
30
};
31
32
sbiret_t
ecall
(
unsigned
long
_arg0,
unsigned
long
_arg1,
unsigned
long
_arg2,
33
unsigned
long
_arg3,
unsigned
long
_arg4,
unsigned
long
_arg5,
34
int
_fid,
int
_eid) {
35
sbiret_t
ret;
36
register
uintptr_t a0
asm
(
"a0"
) = (uintptr_t)(_arg0);
37
register
uintptr_t a1
asm
(
"a1"
) = (uintptr_t)(_arg1);
38
register
uintptr_t a2
asm
(
"a2"
) = (uintptr_t)(_arg2);
39
register
uintptr_t a3
asm
(
"a3"
) = (uintptr_t)(_arg3);
40
register
uintptr_t a4
asm
(
"a4"
) = (uintptr_t)(_arg4);
41
register
uintptr_t a5
asm
(
"a5"
) = (uintptr_t)(_arg5);
42
register
uintptr_t a6
asm
(
"a6"
) = (uintptr_t)(_fid);
43
register
uintptr_t a7
asm
(
"a7"
) = (uintptr_t)(_eid);
44
asm
(
"ecall"
45
:
"+r"
(a0),
"+r"
(a1)
46
:
"r"
(a2),
"r"
(a3),
"r"
(a4),
"r"
(a5),
"r"
(a6),
"r"
(a7)
47
:
"memory"
);
48
ret.
error
= a0;
49
ret.
value
= a1;
50
return
ret;
51
}
52
53
void
put_char
(
const
char
_c) {
54
ecall
(_c, 0, 0, 0, 0, 0, 0, SBI_EXT_0_1_CONSOLE_PUTCHAR);
55
return
;
56
}
57
58
int
main
(
int
,
char
**) {
59
put_char
(
'H'
);
60
put_char
(
'e'
);
61
put_char
(
'l'
);
62
put_char
(
'l'
);
63
put_char
(
'W'
);
64
put_char
(
'o'
);
65
put_char
(
'r'
);
66
put_char
(
'l'
);
67
put_char
(
'd'
);
68
put_char
(
'!'
);
69
70
return
0;
71
}
72
73
#ifdef __cplusplus
74
}
75
#endif
sbiret_t
Definition:
arch.cpp:25
sbiret_t::value
long value
返回值
Definition:
arch.cpp:29
sbiret_t::error
long error
错误码
Definition:
arch.cpp:27
main
int main(int, char **)
入口
Definition:
boot.cpp:58
put_char
void put_char(const char _c)
Definition:
boot.cpp:53
ecall
sbiret_t ecall(unsigned long _arg0, unsigned long _arg1, unsigned long _arg2, unsigned long _arg3, unsigned long _arg4, unsigned long _arg5, int _fid, int _eid)
Definition:
boot.cpp:32
test
system_test
opensbi_test
boot.cpp
Generated on Tue Sep 12 2023 13:20:13 for SimpleKernel by
1.9.1