mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
feat: kernel/driver/irq/plic: drop lock, plat/irq is responsible for locks
This commit is contained in:
parent
55c27e371d
commit
3da5eec0eb
@ -4,7 +4,6 @@ use crate::entry::HART_ID;
|
||||
use crate::plat::irq::IrqController;
|
||||
use fdt::{node::FdtNode, Fdt};
|
||||
use log::trace;
|
||||
use spin::Mutex;
|
||||
|
||||
const IRQ_OCCUPIED: usize = u32::MAX as usize; // OpenSBI will rewrite IRQ_M_EXT to this value
|
||||
const IRQ_S_EXT: usize = 9;
|
||||
@ -34,7 +33,6 @@ where IrqPlic: IrqDriver
|
||||
control: *mut PlicCtrl,
|
||||
|
||||
nr_irqs: usize,
|
||||
lock: Mutex<()>,
|
||||
}
|
||||
|
||||
impl Driver for IrqPlic {
|
||||
@ -96,7 +94,6 @@ impl Driver for IrqPlic {
|
||||
enable: unsafe { base_address.add(PLIC_ENABLE_OFFSET + ctx_id * PLIC_ENABLE_STRIDE) as *mut u32 },
|
||||
control: unsafe { (base_address.add(PLIC_CONTROL_OFFSET) as *mut PlicCtrl).add(ctx_id) },
|
||||
nr_irqs: nr_irqs.unwrap(),
|
||||
lock: Mutex::new(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,15 +107,9 @@ impl IrqController for IrqPlic {
|
||||
let word = irq / 32;
|
||||
let bit = irq % 32;
|
||||
|
||||
{
|
||||
let guard = self.lock.lock();
|
||||
|
||||
let val = unsafe { self.enable.add(word).read_volatile() };
|
||||
let val = val | (1 << bit);
|
||||
unsafe { self.enable.add(word).write_volatile(val) };
|
||||
|
||||
drop(guard);
|
||||
}
|
||||
}
|
||||
|
||||
fn disable(&mut self, irq: usize) {
|
||||
@ -129,15 +120,9 @@ impl IrqController for IrqPlic {
|
||||
let word = irq / 32;
|
||||
let bit = irq % 32;
|
||||
|
||||
{
|
||||
let guard = self.lock.lock();
|
||||
|
||||
let val = unsafe { self.enable.add(word).read_volatile() };
|
||||
let val = val & !(1 << bit);
|
||||
unsafe { self.enable.add(word).write_volatile(val) };
|
||||
|
||||
drop(guard);
|
||||
}
|
||||
}
|
||||
|
||||
fn is_pending(&mut self, irq: usize) -> bool {
|
||||
|
Loading…
Reference in New Issue
Block a user