finish arch
This commit is contained in:
parent
8edb4c2427
commit
9693d83bde
@ -1,5 +1,5 @@
|
|||||||
#[cfg(target_arch = "riscv64")]
|
#[cfg(target_arch = "riscv64")]
|
||||||
pub mod riscv;
|
mod riscv;
|
||||||
#[cfg(target_arch = "riscv64")]
|
#[cfg(target_arch = "riscv64")]
|
||||||
pub use riscv::hardware;
|
pub use riscv::hardware;
|
||||||
|
|
||||||
@ -43,6 +43,11 @@ pub mod mem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod virtual_memory {
|
||||||
|
#[cfg(target_arch = "riscv64")]
|
||||||
|
pub use super::riscv::virtual_memory::{kvminit as init, kvminithart as inithart, copyin, copyinstr, copyout, mappages, uvmalloc, uvmcopy, uvmcreate, uvmdealloc, uvmfree, uvmunmap};
|
||||||
|
}
|
||||||
|
|
||||||
pub mod power {
|
pub mod power {
|
||||||
#[cfg(target_arch = "riscv64")]
|
#[cfg(target_arch = "riscv64")]
|
||||||
pub use super::riscv::power::shutdown;
|
pub use super::riscv::power::shutdown;
|
||||||
|
@ -7,8 +7,7 @@ pub mod plic;
|
|||||||
pub mod power;
|
pub mod power;
|
||||||
pub mod start;
|
pub mod start;
|
||||||
pub mod trap;
|
pub mod trap;
|
||||||
|
pub mod virtual_memory;
|
||||||
pub use mem::make_satp;
|
|
||||||
|
|
||||||
/// Previous mode
|
/// Previous mode
|
||||||
pub const MSTATUS_MPP_MASK: u64 = 3 << 11;
|
pub const MSTATUS_MPP_MASK: u64 = 3 << 11;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use super::{asm, mem::{make_satp, pte2pa}, plic::PLIC, power::QEMU_POWER};
|
||||||
use crate::{
|
use crate::{
|
||||||
arch::{
|
arch::{
|
||||||
self,
|
self,
|
||||||
@ -6,7 +7,6 @@ use crate::{
|
|||||||
round_down_page, round_up_page, Pagetable, PagetableEntry, KERNEL_BASE, PAGE_SIZE,
|
round_down_page, round_up_page, Pagetable, PagetableEntry, KERNEL_BASE, PAGE_SIZE,
|
||||||
PHYSICAL_END, PTE_R, PTE_U, PTE_V, PTE_W, PTE_X, TRAMPOLINE, VIRTUAL_MAX,
|
PHYSICAL_END, PTE_R, PTE_U, PTE_V, PTE_W, PTE_X, TRAMPOLINE, VIRTUAL_MAX,
|
||||||
},
|
},
|
||||||
riscv::{asm, make_satp, mem::pte2pa, plic::PLIC, power::QEMU_POWER},
|
|
||||||
},
|
},
|
||||||
mem::{
|
mem::{
|
||||||
kalloc::{kalloc, kfree},
|
kalloc::{kalloc, kfree},
|
@ -3,7 +3,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
fs::{log, stat::Stat},
|
fs::{log, stat::Stat},
|
||||||
io::pipe::Pipe,
|
io::pipe::Pipe,
|
||||||
mem::virtual_memory::copyout,
|
arch::virtual_memory::copyout,
|
||||||
proc::process::Process,
|
proc::process::Process,
|
||||||
sync::{sleeplock::Sleeplock, spinlock::Spinlock},
|
sync::{sleeplock::Sleeplock, spinlock::Spinlock},
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
fs::file::{filealloc, fileclose, File, FileType},
|
fs::file::{filealloc, fileclose, File, FileType},
|
||||||
mem::{
|
mem::kalloc::{kalloc, kfree},
|
||||||
kalloc::{kalloc, kfree},
|
arch::virtual_memory::{copyin, copyout},
|
||||||
virtual_memory::{copyin, copyout},
|
|
||||||
},
|
|
||||||
proc::{process::Process, scheduler::wakeup},
|
proc::{process::Process, scheduler::wakeup},
|
||||||
sync::spinlock::Spinlock,
|
sync::spinlock::Spinlock,
|
||||||
};
|
};
|
||||||
|
@ -59,8 +59,8 @@ pub unsafe fn main() -> ! {
|
|||||||
console::consoleinit();
|
console::consoleinit();
|
||||||
mem::kalloc::kinit();
|
mem::kalloc::kinit();
|
||||||
println!("\nxv6 kernel is booting");
|
println!("\nxv6 kernel is booting");
|
||||||
mem::virtual_memory::kvminit();
|
arch::virtual_memory::init();
|
||||||
mem::virtual_memory::kvminithart();
|
arch::virtual_memory::inithart();
|
||||||
proc::process::procinit();
|
proc::process::procinit();
|
||||||
arch::trap::inithart();
|
arch::trap::inithart();
|
||||||
arch::interrupt::init();
|
arch::interrupt::init();
|
||||||
@ -75,7 +75,7 @@ pub unsafe fn main() -> ! {
|
|||||||
while !STARTED {
|
while !STARTED {
|
||||||
core::hint::spin_loop();
|
core::hint::spin_loop();
|
||||||
}
|
}
|
||||||
mem::virtual_memory::kvminithart();
|
arch::virtual_memory::inithart();
|
||||||
arch::trap::inithart();
|
arch::trap::inithart();
|
||||||
arch::interrupt::inithart();
|
arch::interrupt::inithart();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
pub mod kalloc;
|
pub mod kalloc;
|
||||||
pub mod virtual_memory;
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn memset(dst: *mut u8, data: i32, max_bytes: u32) -> *mut u8 {
|
pub unsafe extern "C" fn memset(dst: *mut u8, data: i32, max_bytes: u32) -> *mut u8 {
|
||||||
|
@ -10,6 +10,9 @@ use crate::{
|
|||||||
arch::{
|
arch::{
|
||||||
mem::{Pagetable, PAGE_SIZE, PTE_R, PTE_W, PTE_X, TRAMPOLINE, TRAPFRAME},
|
mem::{Pagetable, PAGE_SIZE, PTE_R, PTE_W, PTE_X, TRAMPOLINE, TRAPFRAME},
|
||||||
trap::InterruptBlocker,
|
trap::InterruptBlocker,
|
||||||
|
virtual_memory::{
|
||||||
|
copyout, mappages, uvmalloc, uvmcopy, uvmcreate, uvmdealloc, uvmfree, uvmunmap,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
fs::{
|
fs::{
|
||||||
file::{fileclose, filedup, File, Inode},
|
file::{fileclose, filedup, File, Inode},
|
||||||
@ -19,9 +22,6 @@ use crate::{
|
|||||||
mem::{
|
mem::{
|
||||||
kalloc::{kalloc, kfree},
|
kalloc::{kalloc, kfree},
|
||||||
memset,
|
memset,
|
||||||
virtual_memory::{
|
|
||||||
copyout, mappages, uvmalloc, uvmcopy, uvmcreate, uvmdealloc, uvmfree, uvmunmap,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
sync::spinlock::Spinlock,
|
sync::spinlock::Spinlock,
|
||||||
uprintln,
|
uprintln,
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
arch::{clock::CLOCK_TICKS, power::shutdown},
|
arch::{clock::CLOCK_TICKS, power::shutdown, virtual_memory::{copyin, copyinstr}},
|
||||||
fs::{
|
fs::{
|
||||||
self,
|
self,
|
||||||
file::{self, File},
|
file::{self, File},
|
||||||
log::LogOperation,
|
log::LogOperation,
|
||||||
stat::KIND_DIR,
|
stat::KIND_DIR,
|
||||||
},
|
},
|
||||||
mem::virtual_memory::{copyin, copyinstr},
|
|
||||||
println,
|
println,
|
||||||
proc::process::Process,
|
proc::process::Process,
|
||||||
string::strlen,
|
string::strlen,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user