Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Lockna committed Jan 22, 2024
1 parent 353bd8c commit d771bc8
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 35 deletions.
24 changes: 12 additions & 12 deletions xernel/kernel/src/arch/amd64/interrupts/ipl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
8 changes: 4 additions & 4 deletions xernel/kernel/src/arch/amd64/interrupts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ pub fn disable() {

pub fn allocate_vector(ipl: IPL) -> Option<u8> {
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
}

Expand Down
2 changes: 1 addition & 1 deletion xernel/kernel/src/cpu.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion xernel/kernel/src/dpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub struct DpcQueue {
pub dpcs: VecDeque<Box<dyn DpcCall>>,
}


impl<T> DpcCall for Dpc<T> {
fn call(self: Box<Self>) {
(self.callback)(self.arg)
Expand Down
2 changes: 1 addition & 1 deletion xernel/kernel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ mod acpi;
mod allocator;
mod arch;
mod cpu;
mod dpc;
mod drivers;
mod framebuffer;
mod fs;
mod mem;
mod sched;
mod syscall;
mod timer;
mod dpc;

use alloc::sync::Arc;
use core::arch::asm;
Expand Down
2 changes: 1 addition & 1 deletion xernel/kernel/src/sched/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion xernel/kernel/src/timer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion xernel/kernel/src/timer/timer_event.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
20 changes: 8 additions & 12 deletions xernel/kernel/src/utils/defer.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -18,6 +14,6 @@ macro_rules! defer {
let _guard = OnDrop::new((), $t);
};
($t:tt) => {
let _guard = OnDrop::new((), || { $t });
}
let _guard = OnDrop::new((), || $t);
};
}
2 changes: 1 addition & 1 deletion xernel/kernel/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod backtrace;
pub mod defer;
pub mod limine_module;
pub mod rtc;
pub mod defer;

0 comments on commit d771bc8

Please sign in to comment.