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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#![crate_name = "kernel"]
#![feature(alloc)]
#![feature(asm)]
#![feature(collections)]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(fnbox)]
#![feature(heap_api)]
#![feature(lang_items)]
#![feature(libc)]
#![feature(no_std)]
#![feature(nonzero)]
#![feature(slice_bytes)]
#![feature(unicode)]
#![no_std]
#[macro_use] extern crate collections;
#[macro_use] pub mod bitflags;
#[macro_use] pub mod lazy_static;
#[macro_use] pub mod mutex;
#[macro_use] pub mod macros;
#[macro_use] mod test;
extern crate alloc;
extern crate libc;
extern crate syscall;
#[cfg(target_arch="x86_64")]
#[path="arch/amd64/mod.rs"]
pub mod arch;
#[cfg(target_arch="x86")]
#[path="arch/x86/mod.rs"]
pub mod arch;
pub mod bit_vec;
pub mod console;
pub mod deferred;
pub mod elf;
pub mod io;
pub mod ksyscall;
pub mod libc_helpers;
pub mod logging;
pub mod multiboot;
pub mod once;
pub mod phys_mem;
pub mod prelude;
pub mod process;
pub mod ptr;
pub mod singleton;
pub mod tar;
pub mod thread;
pub mod unwind;
pub mod virt_mem;
#[cfg(feature = "test")]
mod demo;
#[cfg(feature = "test")]
fn run_tests() {
use test::Fixture;
const TEST_FIXTURES: &'static [Fixture] = &[
ptr::test::TESTS,
arch::isr::test::TESTS,
arch::mmu::test::TESTS,
io::pipe::test::TESTS,
phys_mem::test::TESTS,
virt_mem::test::TESTS,
thread::test::TESTS,
process::test::TESTS,
demo::TESTS
];
log!("begin kmain");
for &(fixture_name, fixture) in TEST_FIXTURES {
for &(test_name, test_fn) in fixture {
log!("begin {}::{}", fixture_name, test_name);
test_fn();
log!("end {}::{}\n", fixture_name, test_name);
}
}
log!("end kmain");
}
#[cfg(not(feature = "test"))]
fn run_tests() {
}
#[lang="start"]
#[no_mangle]
pub unsafe fn kmain() -> ! {
arch::isr::init_once();
libc_helpers::init();
run_tests();
loop {
arch::cpu::wait_for_interrupt();
}
}