From 67b920cc16cbbb83b2fe79ff2c0042f1f06f097b Mon Sep 17 00:00:00 2001 From: equation314 Date: Wed, 7 Nov 2018 13:09:50 +0800 Subject: [PATCH] aarch64: format paging.rs --- kernel/Cargo.lock | 2 -- kernel/Cargo.toml | 5 ----- kernel/src/arch/aarch64/memory.rs | 1 + kernel/src/arch/aarch64/mod.rs | 18 +++++++--------- kernel/src/arch/aarch64/paging.rs | 34 ++++++++++++++----------------- kernel/src/lib.rs | 2 -- 6 files changed, 23 insertions(+), 39 deletions(-) diff --git a/kernel/Cargo.lock b/kernel/Cargo.lock index 4e27780..e1b7d05 100644 --- a/kernel/Cargo.lock +++ b/kernel/Cargo.lock @@ -263,8 +263,6 @@ dependencies = [ "uart_16550 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "ucore-memory 0.1.0", "ucore-process 0.1.0", - "usize_conversions 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ux 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "volatile 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "x86_64 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "xmas-elf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 21080d5..e2bba97 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -33,10 +33,6 @@ ucore-memory = { path = "../crate/memory" } ucore-process = { path = "../crate/process" } simple-filesystem = { git = "https://github.com/wangrunji0408/SimpleFileSystem-Rust" } -[dependencies.ux] -default-features = false -version = "0.1.0" - [target.'cfg(target_arch = "x86_64")'.dependencies] bootloader = "0.3" x86_64 = "0.2.11" @@ -49,7 +45,6 @@ bbl = { path = "../crate/bbl" } [target.'cfg(target_arch = "aarch64")'.dependencies] cortex-a = "2.2.1" -usize_conversions = "0.2.0" atags = { path = "../crate/atags" } bcm2837 = { path = "../crate/bcm2837", features = ["use_generic_timer"] } diff --git a/kernel/src/arch/aarch64/memory.rs b/kernel/src/arch/aarch64/memory.rs index 085ab36..bf55354 100644 --- a/kernel/src/arch/aarch64/memory.rs +++ b/kernel/src/arch/aarch64/memory.rs @@ -10,6 +10,7 @@ pub fn init() { unsafe { HEAP_ALLOCATOR.lock().init(start, end - start); } + info!("memory: init end"); } extern "C" { diff --git a/kernel/src/arch/aarch64/mod.rs b/kernel/src/arch/aarch64/mod.rs index d3d0e6d..8c9585d 100644 --- a/kernel/src/arch/aarch64/mod.rs +++ b/kernel/src/arch/aarch64/mod.rs @@ -1,9 +1,6 @@ //! Entrance and initialization for aarch64. extern crate atags; -extern crate bitflags; -extern crate usize_conversions; -pub extern crate ux; pub mod io; pub mod paging; @@ -23,23 +20,22 @@ pub extern "C" fn rust_main() -> ! { // Init board to enable serial port. board::init(); + // First init log mod, so that we can print log info. + // FIXME + ::logging::init(); + let (start, end) = memory::memory_map().expect("failed to find memory map"); - println!("The value of start is: {}, end is {}", start, end); + println!("The value of start is: {:#x?}, end is {:#x?}", start, end); + interrupt::init(); memory::init(); - println!("memory init over"); + timer::init(); //let mut v = vec![]; //for i in 0..1000 { // v.push(i); // println!("{:?}", v); //} - - // First init log mod, so that we can print log info. - // FIXME - ::logging::init(); - interrupt::init(); - timer::init(); ::process::init(); diff --git a/kernel/src/arch/aarch64/paging.rs b/kernel/src/arch/aarch64/paging.rs index 76c395c..e9cc43e 100644 --- a/kernel/src/arch/aarch64/paging.rs +++ b/kernel/src/arch/aarch64/paging.rs @@ -3,11 +3,11 @@ use ucore_memory::memory_set::*; use ucore_memory::paging::*; -type VirtAddr=usize; -type PhysAddr=usize; +type VirtAddr = usize; +type PhysAddr = usize; use alloc::alloc::{alloc, Layout}; -use memory::alloc_stack; +use memory::{active_table, alloc_frame, alloc_stack, dealloc_frame}; /// TODO pub struct ActivePageTable { @@ -36,7 +36,7 @@ impl PageTable for ActivePageTable { } // For testing with mock - fn get_page_slice_mut<'a,'b>(&'a mut self, addr: VirtAddr) -> &'b mut [u8] { + fn get_page_slice_mut<'a, 'b>(&'a mut self, addr: VirtAddr) -> &'b mut [u8] { unimplemented!() } @@ -82,7 +82,6 @@ impl Entry for PageEntry { unimplemented!() } - fn clear_accessed(&mut self) { unimplemented!() } @@ -99,7 +98,6 @@ impl Entry for PageEntry { unimplemented!() } - fn target(&self) -> PhysAddr { unimplemented!() } @@ -108,7 +106,6 @@ impl Entry for PageEntry { unimplemented!() } - // For Copy-on-write extension fn writable_shared(&self) -> bool { unimplemented!() @@ -126,7 +123,6 @@ impl Entry for PageEntry { unimplemented!() } - // For Swap extension fn swapped(&self) -> bool { unimplemented!() @@ -136,7 +132,6 @@ impl Entry for PageEntry { unimplemented!() } - fn user(&self) -> bool { unimplemented!() } @@ -152,7 +147,6 @@ impl Entry for PageEntry { fn set_execute(&mut self, value: bool) { unimplemented!() } - } #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] @@ -186,14 +180,16 @@ impl InactivePageTable for InactivePageTable0 { type Active = ActivePageTable; fn new() -> Self { - unsafe {let layout = Layout::new::(); - let ptr = alloc(layout); - let frame = MockFrame::of_addr(*ptr as usize); - InactivePageTable0 { p4_frame: frame }} + unsafe { + let layout = Layout::new::(); + let ptr = alloc(layout); + let frame = MockFrame::of_addr(*ptr as usize); + InactivePageTable0 { p4_frame: frame } + } } fn new_bare() -> Self { - Self::new() + unimplemented!() } fn edit(&mut self, f: impl FnOnce(&mut Self::Active)) { @@ -201,11 +197,11 @@ impl InactivePageTable for InactivePageTable0 { } unsafe fn activate(&self) { - + unimplemented!() } unsafe fn with(&self, f: impl FnOnce()) { - + unimplemented!() } fn token(&self) -> usize { @@ -213,11 +209,11 @@ impl InactivePageTable for InactivePageTable0 { } fn alloc_frame() -> Option { - unimplemented!() + alloc_frame() } fn dealloc_frame(target: PhysAddr) { - + dealloc_frame(target) } fn alloc_stack() -> Stack { diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 9d87616..8305a77 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -9,7 +9,6 @@ #![feature(panic_info_message)] #![feature(global_asm)] #![feature(compiler_builtins_lib)] -#![feature(try_from)] #![no_std] @@ -34,7 +33,6 @@ extern crate volatile; #[cfg(target_arch = "x86_64")] extern crate x86_64; extern crate xmas_elf; -extern crate usize_conversions; use linked_list_allocator::LockedHeap;