From b9a4e11a64779a3066557b97000d07a8ab886143 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Tue, 16 Feb 2021 20:25:42 +0800 Subject: [PATCH] kernel: riscv: use bit flags for irq handler Instead of hardcoding bit values, use the symbolic names. This will ensure we don't make mistakes by using magic numbers. Signed-off-by: Sean Cross --- kernel/src/arch/riscv/irq.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/src/arch/riscv/irq.rs b/kernel/src/arch/riscv/irq.rs index 8139f446b..ddc426a4f 100644 --- a/kernel/src/arch/riscv/irq.rs +++ b/kernel/src/arch/riscv/irq.rs @@ -1,5 +1,5 @@ use crate::arch::current_pid; -use crate::arch::mem::MemoryMapping; +use crate::arch::mem::{MemoryMapping, MMUFlags}; use crate::arch::process::Process as ArchProcess; use crate::arch::process::{Thread, RETURN_FROM_ISR}; use crate::mem::{MemoryManager, PAGE_SIZE}; @@ -145,7 +145,7 @@ pub extern "C" fn trap_handler( // If the flags are nonzero, but the "Valid" bit is not 1 and // the page isn't shared, then this is a reserved page. Allocate // a real page to back it and resume execution. - if flags & 1 == 0 && flags != 0 && flags & (1 << 8) == 0 { + if flags & MMUFlags::VALID.bits() == 0 && flags != 0 && flags & MMUFlags::S.bits() == 0 { let new_page = MemoryManager::with_mut(|mm| { mm.alloc_page(pid).expect("Couldn't allocate new page") });