Update `riscv` dependency

This commit is contained in:
luojia65 2021-03-09 14:56:09 +08:00
parent 67dc1ff705
commit c959c6a5a8
3 changed files with 8 additions and 19 deletions

2
Cargo.lock generated
View File

@ -92,7 +92,7 @@ checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
[[package]] [[package]]
name = "riscv" name = "riscv"
version = "0.6.0" version = "0.6.0"
source = "git+https://github.com/rust-embedded/riscv?rev=7358eda6#7358eda6668b3798baf2aa89a688aacc466472bc" source = "git+https://github.com/rust-embedded/riscv?rev=a40253e1#a40253e17a8bca83acdcd75cc386d585959a1a1d"
dependencies = [ dependencies = [
"bare-metal", "bare-metal",
"bit_field", "bit_field",

View File

@ -8,7 +8,7 @@ edition = "2018"
[dependencies] [dependencies]
buddy_system_allocator = "0.6" buddy_system_allocator = "0.6"
riscv = { git = "https://github.com/rust-embedded/riscv", rev = "7358eda6" } riscv = { git = "https://github.com/rust-embedded/riscv", rev = "a40253e1" }
spin = "0.7" spin = "0.7"
woke = "0.0.2" woke = "0.0.2"
lazy_static = { version = "1.4", features = ["spin_no_std"] } lazy_static = { version = "1.4", features = ["spin_no_std"] }

View File

@ -132,25 +132,14 @@ impl Mapping {
} }
/// 把当前的映射保存到satp寄存器 /// 把当前的映射保存到satp寄存器
pub fn activate(&self, asid: AddressSpaceId) { pub fn activate(&self, asid: AddressSpaceId) {
// use riscv::{register::satp::{self, Mode}, asm}; use riscv::register::satp::{self, Mode};
// unsafe {
// // 保存到satp寄存器
// satp::set(Mode::Sv39, 0 /* asid */, self.root_ppn.into());
// // 刷新页表缓存
// asm::sfence_vma_all();
// }
// satp的0..=43位为页号44..=59位为地址空间编号高 4 位为模式8 表示 Sv39
let root_ppn: usize = self.root_ppn.into();
let asid = asid.into_inner(); let asid = asid.into_inner();
let new_satp = root_ppn | (asid << 44) | (8 << 60); unsafe {
unsafe { asm!( // 将新的ppn和asid值写到satp寄存器
// 将 new_satp 的值写到 satp 寄存器 satp::set(Mode::Sv39, asid, self.root_ppn.into());
"csrw satp, {satp}",
// 刷新页表。rs1=x0、rs2=asid说明刷新与这个地址空间有关的所有地址 // 刷新页表。rs1=x0、rs2=asid说明刷新与这个地址空间有关的所有地址
"sfence.vma x0, {asid}", asm!("sfence.vma x0, {asid}", asid = in(reg) asid);
satp = in(reg) new_satp, }
asid = in(reg) asid
) };
} }
} }