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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#![no_std]
#![feature(alloc_error_handler)]
#![feature(vec_into_raw_parts)]
pub mod allocator;
pub mod interrupt;
pub mod ipc;
pub mod semaphore;
pub mod task;
static mut PUTC: Option<fn(char)> = None;
extern "C" {
fn do_exit() -> usize;
fn do_sleep(seconds: u32) -> usize;
fn do_yield() -> usize;
}
pub fn set_putc(putc: fn(char)) {
unsafe {
PUTC = Some(putc);
}
}
pub fn putc(c: char) {
unsafe {
if let Some(callback) = PUTC {
callback(c);
}
}
}
pub fn print_msg(msg: &str) {
for c in msg.chars() {
putc(c);
}
}
pub fn exit() -> usize {
unsafe {
do_exit();
}
loop {}
}
pub fn sleep(ms: u32) -> usize {
unsafe {
do_sleep(ms);
}
0
}
pub fn r#yield() -> usize {
unsafe {
do_yield();
}
0
}