add cargo fmt in Makefile, and exec make fmt

This commit is contained in:
Yu Chen 2022-05-20 08:50:52 +08:00
parent daf439cff4
commit 3aa7fac88a
17 changed files with 57 additions and 63 deletions

View file

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

View file

@ -3,4 +3,3 @@ pub const CLOCK_FREQ: usize = 12500000;
pub const MMIO: &[(usize, usize)] = &[(0x10001000, 0x1000)]; pub const MMIO: &[(usize, usize)] = &[(0x10001000, 0x1000)];
pub type BlockDeviceImpl = crate::drivers::block::VirtIOBlock; pub type BlockDeviceImpl = crate::drivers::block::VirtIOBlock;

View file

@ -12,4 +12,3 @@ pub const TRAMPOLINE: usize = usize::MAX - PAGE_SIZE + 1;
pub const TRAP_CONTEXT: usize = TRAMPOLINE - PAGE_SIZE; pub const TRAP_CONTEXT: usize = TRAMPOLINE - PAGE_SIZE;
pub use crate::board::{CLOCK_FREQ, MMIO}; pub use crate::board::{CLOCK_FREQ, MMIO};

View file

@ -1,13 +1,13 @@
mod sdcard; mod sdcard;
mod virtio_blk; mod virtio_blk;
pub use virtio_blk::VirtIOBlock;
pub use sdcard::SDCardWrapper; pub use sdcard::SDCardWrapper;
pub use virtio_blk::VirtIOBlock;
use crate::board::BlockDeviceImpl;
use alloc::sync::Arc; use alloc::sync::Arc;
use easy_fs::BlockDevice; use easy_fs::BlockDevice;
use lazy_static::*; use lazy_static::*;
use crate::board::BlockDeviceImpl;
lazy_static! { lazy_static! {
pub static ref BLOCK_DEVICE: Arc<dyn BlockDevice> = Arc::new(BlockDeviceImpl::new()); pub static ref BLOCK_DEVICE: Arc<dyn BlockDevice> = Arc::new(BlockDeviceImpl::new());

View file

@ -389,26 +389,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
); .page_table
assert!( .translate(mid_rodata.floor())
!kernel_space .unwrap()
.page_table .writable(),);
.translate(mid_rodata.floor()) assert!(!kernel_space
.unwrap() .page_table
.writable(), .translate(mid_data.floor())
); .unwrap()
assert!( .executable(),);
!kernel_space
.page_table
.translate(mid_data.floor())
.unwrap()
.executable(),
);
println!("remap_test passed!"); println!("remap_test passed!");
} }

View file

@ -155,8 +155,8 @@ impl PageTable {
8usize << 60 | self.root_ppn.0 8usize << 60 | self.root_ppn.0
} }
} }
/// Translate a pointer to a mutable u8 Vec through page table /// Translate a pointer to a mutable u8 Vec through page table
pub fn translated_byte_buffer(token: usize, ptr: *const u8, len: usize) -> Vec<&'static mut [u8]> { pub fn translated_byte_buffer(token: usize, ptr: *const u8, len: usize) -> Vec<&'static mut [u8]> {
let page_table = PageTable::from_token(token); let page_table = PageTable::from_token(token);
let mut start = ptr as usize; let mut start = ptr as usize;
let end = start + len; let end = start + len;

View file

@ -27,14 +27,15 @@ use crate::fs::{open_file, OpenFlags};
use alloc::sync::Arc; use alloc::sync::Arc;
pub use context::TaskContext; pub use context::TaskContext;
use lazy_static::*; use lazy_static::*;
pub use manager::{fetch_task,TaskManager}; pub use manager::{fetch_task, TaskManager};
use switch::__switch; use switch::__switch;
use task::{TaskControlBlock, TaskStatus}; use task::{TaskControlBlock, TaskStatus};
pub use manager::add_task; pub use manager::add_task;
pub use pid::{pid_alloc, KernelStack, PidHandle,PidAllocator}; pub use pid::{pid_alloc, KernelStack, PidAllocator, PidHandle};
pub use processor::{ pub use processor::{
current_task, current_trap_cx, current_user_token, run_tasks, schedule, take_current_task,Processor current_task, current_trap_cx, current_user_token, run_tasks, schedule, take_current_task,
Processor,
}; };
/// Suspend the current 'Running' task and run the next task in task list. /// Suspend the current 'Running' task and run the next task in task list.
pub fn suspend_current_and_run_next() { pub fn suspend_current_and_run_next() {

View file

@ -1,4 +1,3 @@
//! RISC-V timer-related functionality //! RISC-V timer-related functionality
use crate::config::CLOCK_FREQ; use crate::config::CLOCK_FREQ;