2018-04-02 11:28:32 +04:00
|
|
|
#![feature(ptr_internals)]
|
2017-04-11 17:02:21 +04:00
|
|
|
#![feature(lang_items)]
|
2017-04-12 21:16:04 +04:00
|
|
|
#![feature(const_fn)]
|
2017-11-19 15:41:20 +04:00
|
|
|
#![feature(alloc)]
|
2018-04-25 21:00:32 +04:00
|
|
|
#![feature(naked_functions)]
|
2018-04-18 17:53:39 +04:00
|
|
|
#![feature(asm)]
|
2018-06-04 21:32:21 +04:00
|
|
|
#![feature(optin_builtin_traits)]
|
2018-09-08 21:25:14 +04:00
|
|
|
#![feature(panic_handler)]
|
2018-06-19 19:43:40 +04:00
|
|
|
#![feature(panic_info_message)]
|
2018-07-04 12:23:11 +04:00
|
|
|
#![feature(global_asm)]
|
2018-07-14 08:28:55 +04:00
|
|
|
#![feature(compiler_builtins_lib)]
|
2018-10-23 20:27:25 +04:00
|
|
|
#![feature(raw)]
|
2018-10-31 20:45:02 +04:00
|
|
|
#![feature(vec_resize_default)]
|
2017-04-11 17:02:21 +04:00
|
|
|
#![no_std]
|
|
|
|
|
2017-11-19 15:41:20 +04:00
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
extern crate alloc;
|
2018-06-04 20:34:34 +04:00
|
|
|
extern crate bit_allocator;
|
|
|
|
extern crate bit_field;
|
2017-04-13 20:27:39 +04:00
|
|
|
#[macro_use]
|
|
|
|
extern crate bitflags;
|
2018-04-18 17:53:39 +04:00
|
|
|
#[macro_use]
|
2017-04-18 17:15:44 +04:00
|
|
|
extern crate lazy_static;
|
2018-06-04 20:34:34 +04:00
|
|
|
extern crate linked_list_allocator;
|
2018-05-19 14:42:08 +04:00
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
2018-06-04 20:34:34 +04:00
|
|
|
#[macro_use]
|
|
|
|
extern crate once;
|
2018-05-18 07:49:27 +04:00
|
|
|
extern crate simple_filesystem;
|
2018-06-04 20:34:34 +04:00
|
|
|
extern crate spin;
|
2018-06-23 15:11:41 +04:00
|
|
|
extern crate ucore_memory;
|
2018-07-16 21:56:28 +04:00
|
|
|
extern crate ucore_process;
|
2018-06-04 20:34:34 +04:00
|
|
|
extern crate volatile;
|
2018-07-03 18:27:55 +04:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
2018-06-04 20:34:34 +04:00
|
|
|
extern crate x86_64;
|
|
|
|
extern crate xmas_elf;
|
|
|
|
|
2018-10-24 17:32:23 +04:00
|
|
|
pub use process::{processor, new_kernel_context};
|
|
|
|
use ucore_process::thread;
|
2018-06-04 20:34:34 +04:00
|
|
|
use linked_list_allocator::LockedHeap;
|
2018-04-04 16:56:56 +04:00
|
|
|
|
2018-04-04 20:58:23 +04:00
|
|
|
#[macro_use] // print!
|
2018-08-04 19:08:10 +04:00
|
|
|
pub mod logging;
|
2017-04-13 19:59:12 +04:00
|
|
|
mod memory;
|
2018-04-04 16:56:56 +04:00
|
|
|
mod lang;
|
2018-04-05 18:36:39 +04:00
|
|
|
mod util;
|
2018-04-12 16:57:56 +04:00
|
|
|
mod consts;
|
2018-04-26 17:53:20 +04:00
|
|
|
mod process;
|
2018-05-12 23:41:41 +04:00
|
|
|
mod syscall;
|
2018-05-18 07:49:27 +04:00
|
|
|
mod fs;
|
2018-05-31 16:23:26 +04:00
|
|
|
mod sync;
|
2018-07-12 20:00:42 +04:00
|
|
|
mod trap;
|
2018-07-16 13:31:29 +04:00
|
|
|
mod console;
|
2017-04-12 21:16:04 +04:00
|
|
|
|
2018-04-04 16:56:56 +04:00
|
|
|
#[allow(dead_code)]
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
#[path = "arch/x86_64/mod.rs"]
|
2018-08-05 13:50:56 +04:00
|
|
|
pub mod arch;
|
2018-04-04 16:56:56 +04:00
|
|
|
|
2018-08-04 12:20:25 +04:00
|
|
|
#[cfg(target_arch = "riscv32")]
|
2018-07-04 12:23:11 +04:00
|
|
|
#[path = "arch/riscv32/mod.rs"]
|
2018-08-04 19:08:10 +04:00
|
|
|
pub mod arch;
|
2018-07-04 12:23:11 +04:00
|
|
|
|
2018-09-08 21:25:14 +04:00
|
|
|
pub fn kmain() -> ! {
|
2018-10-23 20:27:25 +04:00
|
|
|
process::processor().run();
|
2018-07-16 13:31:29 +04:00
|
|
|
|
2018-07-12 13:19:55 +04:00
|
|
|
// thread::test::local_key();
|
2018-06-01 07:47:58 +04:00
|
|
|
// thread::test::unpack();
|
2018-06-04 21:32:21 +04:00
|
|
|
// sync::test::philosopher_using_mutex();
|
|
|
|
// sync::test::philosopher_using_monitor();
|
2018-07-11 06:57:07 +04:00
|
|
|
// sync::mpsc::test::test_all();
|
2018-04-18 08:26:21 +04:00
|
|
|
}
|
|
|
|
|
2018-05-13 11:06:44 +04:00
|
|
|
/// Global heap allocator
|
|
|
|
///
|
|
|
|
/// Available after `memory::init()`.
|
|
|
|
///
|
|
|
|
/// It should be defined in memory mod, but in Rust `global_allocator` must be in root mod.
|
2017-11-19 16:13:18 +04:00
|
|
|
#[global_allocator]
|
2017-11-19 17:16:33 +04:00
|
|
|
static HEAP_ALLOCATOR: LockedHeap = LockedHeap::empty();
|