1111#![ deny( warnings) ]
1212#![ no_std]
1313#![ no_main]
14- #![ feature( panic_info_message) ]
1514
1615use core:: arch:: global_asm;
1716use log:: * ;
@@ -29,35 +28,34 @@ global_asm!(include_str!("entry.asm"));
2928
3029/// clear BSS segment
3130pub fn clear_bss ( ) {
32- extern "C" {
33- fn sbss ( ) ;
34- fn ebss ( ) ;
31+ unsafe extern "C" {
32+ unsafe fn sbss ( ) ;
33+ unsafe fn ebss ( ) ;
3534 }
3635 ( sbss as usize ..ebss as usize ) . for_each ( |a| unsafe { ( a as * mut u8 ) . write_volatile ( 0 ) } ) ;
3736}
3837
3938/// the rust entry-point of os
40- #[ no_mangle]
39+ #[ unsafe ( no_mangle) ]
4140pub fn rust_main ( ) -> ! {
42- extern "C" {
43- fn stext ( ) ; // begin addr of text segment
44- fn etext ( ) ; // end addr of text segment
45- fn srodata ( ) ; // start addr of Read-Only data segment
46- fn erodata ( ) ; // end addr of Read-Only data ssegment
47- fn sdata ( ) ; // start addr of data segment
48- fn edata ( ) ; // end addr of data segment
49- fn sbss ( ) ; // start addr of BSS segment
50- fn ebss ( ) ; // end addr of BSS segment
51- fn boot_stack_lower_bound ( ) ; // stack lower bound
52- fn boot_stack_top ( ) ; // stack top
41+ unsafe extern "C" {
42+ unsafe fn stext ( ) ; // begin addr of text segment
43+ unsafe fn etext ( ) ; // end addr of text segment
44+ unsafe fn srodata ( ) ; // start addr of Read-Only data segment
45+ unsafe fn erodata ( ) ; // end addr of Read-Only data ssegment
46+ unsafe fn sdata ( ) ; // start addr of data segment
47+ unsafe fn edata ( ) ; // end addr of data segment
48+ unsafe fn sbss ( ) ; // start addr of BSS segment
49+ unsafe fn ebss ( ) ; // end addr of BSS segment
50+ unsafe fn boot_stack_lower_bound ( ) ; // stack lower bound
51+ unsafe fn boot_stack_top ( ) ; // stack top
5352 }
5453 clear_bss ( ) ;
5554 logging:: init ( ) ;
5655 println ! ( "[kernel] Hello, world!" ) ;
5756 trace ! (
5857 "[kernel] .text [{:#x}, {:#x})" ,
59- stext as usize ,
60- etext as usize
58+ stext as usize , etext as usize
6159 ) ;
6260 debug ! (
6361 "[kernel] .rodata [{:#x}, {:#x})" ,
@@ -75,5 +73,5 @@ pub fn rust_main() -> ! {
7573
7674 use crate :: board:: QEMUExit ;
7775 crate :: board:: QEMU_EXIT_HANDLE . exit_success ( ) ; // CI autotest success
78- //crate::board::QEMU_EXIT_HANDLE.exit_failure(); // CI autoest failed
76+ //crate::board::QEMU_EXIT_HANDLE.exit_failure(); // CI autoest failed
7977}
0 commit comments