|
|
|
@ -1,3 +1,14 @@
|
|
|
|
|
//! The main module and entrypoint
|
|
|
|
|
//!
|
|
|
|
|
//! The operating system and app also starts in this module. Kernel code starts
|
|
|
|
|
//! executing from `entry.asm`, after which [`rust_main()`] is called to
|
|
|
|
|
//! initialize various pieces of functionality [`clear_bss()`]. (See its source code for
|
|
|
|
|
//! details.)
|
|
|
|
|
//!
|
|
|
|
|
//! We then call [`println!`] to display `Hello, world!`.
|
|
|
|
|
|
|
|
|
|
#![deny(missing_docs)]
|
|
|
|
|
#![deny(warnings)]
|
|
|
|
|
#![no_std]
|
|
|
|
|
#![no_main]
|
|
|
|
|
#![feature(panic_info_message)]
|
|
|
|
@ -11,6 +22,7 @@ mod sbi;
|
|
|
|
|
|
|
|
|
|
global_asm!(include_str!("entry.asm"));
|
|
|
|
|
|
|
|
|
|
/// clear BSS segment
|
|
|
|
|
fn clear_bss() {
|
|
|
|
|
extern "C" {
|
|
|
|
|
fn sbss();
|
|
|
|
@ -19,6 +31,7 @@ fn clear_bss() {
|
|
|
|
|
(sbss as usize..ebss as usize).for_each(|a| unsafe { (a as *mut u8).write_volatile(0) });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// the rust entry-point of os
|
|
|
|
|
#[no_mangle]
|
|
|
|
|
pub fn rust_main() -> ! {
|
|
|
|
|
extern "C" {
|
|
|
|
|