Skip to content

Commit

Permalink
移除无用接口
Browse files Browse the repository at this point in the history
  • Loading branch information
ZR233 committed Feb 6, 2025
1 parent 37098f1 commit 919d5c0
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 38 deletions.
2 changes: 1 addition & 1 deletion crates/driver-interface/src/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pub enum DriverError {
Other(String),
}

pub type DriverResult<T> = core::result::Result<T, DriverError>;
pub type DriverResult<T=()> = core::result::Result<T, DriverError>;
1 change: 0 additions & 1 deletion crates/driver-interface/src/interrupt_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub trait InterfaceCPU: Send {
fn set_trigger(&mut self, irq: IrqId, triger: Trigger);
fn set_bind_cpu(&mut self, irq: IrqId, cpu_list: &[CpuId]);
fn parse_fdt_config(&self, prop_interrupts: &[u32]) -> Result<IrqConfig, Box<dyn Error>>;
fn irq_pin_to_id(&self, pin: usize) -> Result<IrqId, Box<dyn Error>>;
}

pub trait Interface: DriverGeneric {
Expand Down
4 changes: 2 additions & 2 deletions crates/driver-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub use err::{DriverError, DriverResult};
pub use interrupt_controller::IrqConfig;

pub trait DriverGeneric: Send {
fn open(&mut self) -> DriverResult<()>;
fn close(&mut self) -> DriverResult<()>;
fn open(&mut self) -> DriverResult;
fn close(&mut self) -> DriverResult;
}

#[derive(Debug, Clone, Copy)]
Expand Down
30 changes: 8 additions & 22 deletions crates/sparreal-kernel/src/irq/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ pub(crate) fn init_current_cpu() {

let device = Device::new(c.descriptor.clone(), device);

g.irq_chips.0.insert(id, Chip {
device,
mutex: Mutex::new(()),
handlers: UnsafeCell::new(Default::default()),
});
g.irq_chips.0.insert(
id,
Chip {
device,
mutex: Mutex::new(()),
handlers: UnsafeCell::new(Default::default()),
},
);
}
}

Expand Down Expand Up @@ -164,11 +167,6 @@ impl Chip {
chip.end_interrupt(irq);
Some(())
}

fn pin_to_id(&self, pin: usize) -> Result<IrqId, Box<dyn Error>> {
let chip = unsafe { &*self.device.force_use() };
chip.irq_pin_to_id(pin)
}
}

pub struct NoIrqGuard {
Expand Down Expand Up @@ -214,18 +212,6 @@ pub struct IrqParam {
}

impl IrqParam {
pub fn new_pin(pin: usize, irq_chip: DriverId) -> Result<Self, Box<dyn Error>> {
let chip = chip(irq_chip);
let irq_id = chip.pin_to_id(pin)?;
Ok(Self {
irq_chip,
cfg: IrqConfig {
irq: irq_id,
trigger: Trigger::LevelLow,
},
})
}

pub fn register_builder(
&self,
handler: impl Fn(IrqId) -> IrqHandleResult + 'static,
Expand Down
4 changes: 1 addition & 3 deletions crates/sparreal-rt/src/arch/aarch64/gic/gic_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ impl InterfaceCPU for GicV2PerCpu {
fdt_parse_irq_config(prop_interupt)
}

fn irq_pin_to_id(&self, pin: usize) -> Result<IrqId, Box<dyn Error>> {
super::irq_pin_to_id(pin)
}

}

impl DriverGeneric for GicV2 {
Expand Down
4 changes: 0 additions & 4 deletions crates/sparreal-rt/src/arch/aarch64/gic/gic_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ impl InterfaceCPU for GicPerCpu {
fn parse_fdt_config(&self, prop_interupt: &[u32]) -> Result<IrqConfig, Box<dyn Error>> {
fdt_parse_irq_config(prop_interupt)
}

fn irq_pin_to_id(&self, pin: usize) -> Result<IrqId, Box<dyn Error>> {
super::irq_pin_to_id(pin)
}
}

impl DriverGeneric for Gic {
Expand Down
5 changes: 0 additions & 5 deletions crates/sparreal-rt/src/arch/aarch64/gic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,3 @@ fn fdt_parse_irq_config(itr: &[u32]) -> Result<IrqConfig, Box<dyn Error>> {
trigger,
})
}

fn irq_pin_to_id(pin: usize) -> Result<IrqId, Box<dyn Error>> {
let irq_id = arm_gic_driver::IntId::spi(pin as _);
Ok((irq_id.to_u32() as usize).into())
}

0 comments on commit 919d5c0

Please sign in to comment.