add cargo fmt in Makefile, and exec make fmt

This commit is contained in:
Yu Chen 2022-05-20 08:55:07 +08:00
parent e87bb122a8
commit ab99bc8c28
10 changed files with 36 additions and 40 deletions

View file

@ -6,3 +6,5 @@ docker:
build_docker: build_docker:
docker build -t ${DOCKER_NAME} . docker build -t ${DOCKER_NAME} .
fmt:
cd os ; cargo fmt; cd ../user; cargo fmt; cd ..

View file

@ -1,2 +1 @@
pub const CLOCK_FREQ: usize = 403000000 / 62; pub const CLOCK_FREQ: usize = 403000000 / 62;

View file

@ -324,26 +324,20 @@ pub fn remap_test() {
let mid_text: VirtAddr = ((stext as usize + etext as usize) / 2).into(); let mid_text: VirtAddr = ((stext as usize + etext as usize) / 2).into();
let mid_rodata: VirtAddr = ((srodata as usize + erodata as usize) / 2).into(); let mid_rodata: VirtAddr = ((srodata as usize + erodata as usize) / 2).into();
let mid_data: VirtAddr = ((sdata as usize + edata as usize) / 2).into(); let mid_data: VirtAddr = ((sdata as usize + edata as usize) / 2).into();
assert!( assert!(!kernel_space
!kernel_space
.page_table .page_table
.translate(mid_text.floor()) .translate(mid_text.floor())
.unwrap() .unwrap()
.writable(), .writable(),);
); assert!(!kernel_space
assert!(
!kernel_space
.page_table .page_table
.translate(mid_rodata.floor()) .translate(mid_rodata.floor())
.unwrap() .unwrap()
.writable(), .writable(),);
); assert!(!kernel_space
assert!(
!kernel_space
.page_table .page_table
.translate(mid_data.floor()) .translate(mid_data.floor())
.unwrap() .unwrap()
.executable(), .executable(),);
);
println!("remap_test passed!"); println!("remap_test passed!");
} }

View file

@ -6,7 +6,6 @@
//! //!
//! Every task or process has a memory_set to control its virtual memory. //! Every task or process has a memory_set to control its virtual memory.
mod address; mod address;
mod frame_allocator; mod frame_allocator;
mod heap_allocator; mod heap_allocator;

View file

@ -64,8 +64,10 @@ pub fn trap_handler() -> ! {
cx.sepc += 4; cx.sepc += 4;
cx.x[10] = syscall(cx.x[17], [cx.x[10], cx.x[11], cx.x[12]]) as usize; cx.x[10] = syscall(cx.x[17], [cx.x[10], cx.x[11], cx.x[12]]) as usize;
} }
Trap::Exception(Exception::StoreFault) | Trap::Exception(Exception::StorePageFault) | Trap::Exception(Exception::StoreFault)
Trap::Exception(Exception::LoadFault) | Trap::Exception(Exception::LoadPageFault) => { | Trap::Exception(Exception::StorePageFault)
| Trap::Exception(Exception::LoadFault)
| Trap::Exception(Exception::LoadPageFault) => {
println!("[kernel] PageFault in application, bad addr = {:#x}, bad instruction = {:#x}, kernel killed it.", stval, cx.sepc); println!("[kernel] PageFault in application, bad addr = {:#x}, bad instruction = {:#x}, kernel killed it.", stval, cx.sepc);
exit_current_and_run_next(); exit_current_and_run_next();
} }

View file

@ -4,7 +4,7 @@
#[macro_use] #[macro_use]
extern crate user_lib; extern crate user_lib;
use core::ptr::{read_volatile,null_mut}; use core::ptr::{null_mut, read_volatile};
#[no_mangle] #[no_mangle]
fn main() -> i32 { fn main() -> i32 {