diff --git a/xernel/kernel/src/arch/amd64/interrupts/ipl.rs b/xernel/kernel/src/arch/amd64/interrupts/ipl.rs index d4e46af9..afb8adb7 100644 --- a/xernel/kernel/src/arch/amd64/interrupts/ipl.rs +++ b/xernel/kernel/src/arch/amd64/interrupts/ipl.rs @@ -5,18 +5,18 @@ use crate::dpc::dpc_interrupt_dispatch; #[macro_export] macro_rules! lock_with_ipl { - ($name:ident) => { - { - let old = raise_ipl(IPL::DPC); - OnDrop::new($name.lock(), move || { set_ipl(old); }) - } - }; - ($name:ident, $ipl:expr) => { - { - let _ = raise_ipl(IPL::DPC); - OnDrop::new($name.lock(), || { set_ipl($ipl); }) - } - }; + ($name:ident) => {{ + let old = raise_ipl(IPL::DPC); + OnDrop::new($name.lock(), move || { + set_ipl(old); + }) + }}; + ($name:ident, $ipl:expr) => {{ + let _ = raise_ipl(IPL::DPC); + OnDrop::new($name.lock(), || { + set_ipl($ipl); + }) + }}; } #[derive(Debug, Clone, Copy, PartialEq, PartialOrd)] diff --git a/xernel/kernel/src/arch/amd64/interrupts/mod.rs b/xernel/kernel/src/arch/amd64/interrupts/mod.rs index 54e3a7a8..b1365ed3 100644 --- a/xernel/kernel/src/arch/amd64/interrupts/mod.rs +++ b/xernel/kernel/src/arch/amd64/interrupts/mod.rs @@ -80,15 +80,15 @@ pub fn disable() { pub fn allocate_vector(ipl: IPL) -> Option { let starting = core::cmp::max((ipl as u8) << 4, 32); - + let handlers = INTERRUPT_HANDLERS.lock(); - - for i in starting..starting+16 { + + for i in starting..starting + 16 { if let IRQHandler::None = handlers[i as usize] { return Some(i); } } - + None } diff --git a/xernel/kernel/src/cpu.rs b/xernel/kernel/src/cpu.rs index 57acdfd6..434d0431 100644 --- a/xernel/kernel/src/cpu.rs +++ b/xernel/kernel/src/cpu.rs @@ -1,6 +1,6 @@ use crate::arch::amd64::apic::APIC; -use crate::dpc::DpcQueue; use crate::arch::amd64::{rdmsr, wrmsr, KERNEL_GS_BASE}; +use crate::dpc::DpcQueue; use crate::sched::process::Process; use crate::sched::thread::Thread; use crate::timer::timer_queue::TimerQueue; diff --git a/xernel/kernel/src/dpc.rs b/xernel/kernel/src/dpc.rs index d03894b8..e460beac 100644 --- a/xernel/kernel/src/dpc.rs +++ b/xernel/kernel/src/dpc.rs @@ -28,7 +28,6 @@ pub struct DpcQueue { pub dpcs: VecDeque>, } - impl DpcCall for Dpc { fn call(self: Box) { (self.callback)(self.arg) diff --git a/xernel/kernel/src/main.rs b/xernel/kernel/src/main.rs index 6f1a494b..4258e0ce 100644 --- a/xernel/kernel/src/main.rs +++ b/xernel/kernel/src/main.rs @@ -24,6 +24,7 @@ mod acpi; mod allocator; mod arch; mod cpu; +mod dpc; mod drivers; mod framebuffer; mod fs; @@ -31,7 +32,6 @@ mod mem; mod sched; mod syscall; mod timer; -mod dpc; use alloc::sync::Arc; use core::arch::asm; diff --git a/xernel/kernel/src/sched/thread.rs b/xernel/kernel/src/sched/thread.rs index 38cbf636..f830bd56 100644 --- a/xernel/kernel/src/sched/thread.rs +++ b/xernel/kernel/src/sched/thread.rs @@ -179,7 +179,7 @@ impl Thread { let end_of_combined_frame = -27; (ptr.offset(frame_begin) as *mut TrapFrame).write(trap_frame); - + if is_user { ptr.offset(frame_begin + 19).write(trap_frame.rsp); } else { diff --git a/xernel/kernel/src/timer/mod.rs b/xernel/kernel/src/timer/mod.rs index dcb40179..aba9526f 100644 --- a/xernel/kernel/src/timer/mod.rs +++ b/xernel/kernel/src/timer/mod.rs @@ -6,7 +6,10 @@ use core::{ time::Duration, }; -use crate::{cpu::current_cpu, arch::amd64::interrupts::{allocate_vector, ipl::IPL}}; +use crate::{ + arch::amd64::interrupts::{allocate_vector, ipl::IPL}, + cpu::current_cpu, +}; use self::timer_event::TimerEvent; diff --git a/xernel/kernel/src/timer/timer_event.rs b/xernel/kernel/src/timer/timer_event.rs index 943ed8be..768577bf 100644 --- a/xernel/kernel/src/timer/timer_event.rs +++ b/xernel/kernel/src/timer/timer_event.rs @@ -1,5 +1,5 @@ +use crate::dpc::{Dpc, DpcCall}; use core::time::Duration; -use crate::dpc::{DpcCall, Dpc}; use crate::current_cpu; use alloc::boxed::Box; diff --git a/xernel/kernel/src/utils/defer.rs b/xernel/kernel/src/utils/defer.rs index 38a13d8a..20cf3c27 100644 --- a/xernel/kernel/src/utils/defer.rs +++ b/xernel/kernel/src/utils/defer.rs @@ -1,15 +1,11 @@ #[macro_export] macro_rules! on_drop { - ($name:ident, $t:expr) => { - { - OnDrop::new($name, $t) - } - }; - ($name:expr, $t:expr) => { - { - OnDrop::new($name, $t) - } - }; + ($name:ident, $t:expr) => {{ + OnDrop::new($name, $t) + }}; + ($name:expr, $t:expr) => {{ + OnDrop::new($name, $t) + }}; } #[macro_export] @@ -18,6 +14,6 @@ macro_rules! defer { let _guard = OnDrop::new((), $t); }; ($t:tt) => { - let _guard = OnDrop::new((), || { $t }); - } + let _guard = OnDrop::new((), || $t); + }; } diff --git a/xernel/kernel/src/utils/mod.rs b/xernel/kernel/src/utils/mod.rs index 7596b68c..78119cd4 100644 --- a/xernel/kernel/src/utils/mod.rs +++ b/xernel/kernel/src/utils/mod.rs @@ -1,4 +1,4 @@ pub mod backtrace; +pub mod defer; pub mod limine_module; pub mod rtc; -pub mod defer;