You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rCore_stu/ch1/src/main.rs

40 lines
714 B
Rust

#![feature(panic_info_message)]
2 years ago
#![no_std]
#![no_main]
use core::arch::global_asm;
use sbi::{console_put_char, shutdown};
use lang_items::console;
mod lang_items;
mod sbi;
2 years ago
// 汇编脚本引入, 调整内核的内存布局之后, 会跳入到 rust_main中执行
global_asm!(include_str!("entry.asm"));
#[no_mangle]
pub fn rust_main(){
init_bss();
println!("hello world");
let mut a = 123;
a = 234;
a = 345;
println!("hello world {:?}", a);
panic!("my panic");
}
/// ## 初始化bss段
///
fn init_bss() {
extern "C" {
static mut sbss: u64;
static mut ebss: u64;
}
unsafe {
(sbss..ebss).for_each(|p| (p as *mut u8).write_unaligned(0))
}
}