Skip to content

Commit

Permalink
fix: fix some Code
Browse files Browse the repository at this point in the history
  • Loading branch information
yfblock committed Aug 7, 2024
1 parent 21574e0 commit df6355f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
4 changes: 0 additions & 4 deletions src/components/boot/riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,10 @@ pub(crate) fn rust_main(hartid: usize, device_tree: usize) {
crate::components::debug_console::DebugConsole::log_init();
// Init allocator
crate::components::percpu::set_local_thread_pointer(hartid);
println!("CPU_ID offset: {:#x}", CPU_ID.offset());
println!("init success, CPU_ID: {}", CPU_ID.read_current());
CPU_ID.write_current(hartid);
#[cfg(feature = "trap")]
crate::components::trap::init();

println!("CPU_ID offset: {:#x}", CPU_ID.offset());

unsafe {
// Enable SUM for access user memory directly.
// TODO: Call set_sum() for riscv version up than 1.0, Close when below 1.0
Expand Down
4 changes: 2 additions & 2 deletions src/components/pagetable/riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl PageTable {
#[inline]
pub fn restore(&self) {
self.release();
let kernel_arr = Self::get_pte_list(crate::boot::boot_page_table().0);
let kernel_arr = Self::get_pte_list(Self::current().0);
let arr = Self::get_pte_list(self.0);
arr[0x100..].copy_from_slice(&kernel_arr[0x100..]);
arr[0..0x100].fill(PTE(0));
Expand All @@ -193,7 +193,7 @@ impl PageTable {
#[inline]
pub fn change(&self) {
// Write page table entry for
satp::write((8 << 60) | (self.0 .0 >> 12));
satp::write((8 << 60) | (self.0.0 >> 12));
TLB::flush_all();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/trap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum TrapType {
Irq(IRQVector),
}

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EscapeReason {
NoReason,
IRQ,
Expand Down
1 change: 1 addition & 0 deletions src/components/trap/riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ fn kernel_callback(context: &mut TrapFrame) -> TrapType {
TrapType::Timer
}
Trap::Exception(Exception::StorePageFault) => TrapType::StorePageFault(stval),
Trap::Exception(Exception::StoreFault) => TrapType::StorePageFault(stval),
Trap::Exception(Exception::InstructionPageFault) => TrapType::InstructionPageFault(stval),
Trap::Exception(Exception::IllegalInstruction) => TrapType::IllegalInstruction(stval),
Trap::Exception(Exception::LoadPageFault) => TrapType::LoadPageFault(stval),
Expand Down

0 comments on commit df6355f

Please sign in to comment.