Skip to content

Commit

Permalink
chore: 🧹 Rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
berkus committed Oct 5, 2024
1 parent 4d78488 commit f96cf8f
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 43 deletions.
6 changes: 3 additions & 3 deletions bin/chainofcommand/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
#![feature(slice_take)]

use {
anyhow::{anyhow, Result},
anyhow::{Result, anyhow},
bytes::Bytes,
clap::{value_parser, Arg, ArgAction, Command},
clap::{Arg, ArgAction, Command, value_parser},
crossterm::{
cursor,
event::{Event, EventStream, KeyCode, KeyEvent, KeyModifiers},
execute, style, terminal,
tty::IsTty,
},
defer::defer,
futures::{future::FutureExt, Stream},
futures::{Stream, future::FutureExt},
seahash::SeaHasher,
std::{
fmt::Formatter,
Expand Down
2 changes: 1 addition & 1 deletion machine/src/arch/aarch64/cpu/smp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[inline(always)]
pub fn core_id() -> u64 {
use aarch64_cpu::registers::{Readable, MPIDR_EL1};
use aarch64_cpu::registers::{MPIDR_EL1, Readable};

const CORE_MASK: u64 = 0x3;
MPIDR_EL1.get() & CORE_MASK
Expand Down
8 changes: 1 addition & 7 deletions machine/src/arch/aarch64/exception/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,7 @@ impl fmt::Display for ExceptionContext {
writeln!(f)?;
writeln!(f, "General purpose register:")?;

let alternating = |x| -> _ {
if x % 2 == 0 {
" "
} else {
"\n"
}
};
let alternating = |x| -> _ { if x % 2 == 0 { " " } else { "\n" } };

// Print two registers per line.
for (i, reg) in self.gpr.iter().enumerate() {
Expand Down
5 changes: 4 additions & 1 deletion machine/src/arch/aarch64/memory/mmu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
use {
crate::{
memory::{
mmu::{interface, interface::MMU, AddressSpace, MMUEnableError, TranslationGranule},
Address, Physical,
mmu::{
AddressSpace, MMUEnableError, TranslationGranule,
interface::{self, MMU},
},
},
platform, println,
},
Expand Down
5 changes: 2 additions & 3 deletions machine/src/arch/aarch64/memory/mmu/translation_table.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use {
super::{mair, Granule512MiB, Granule64KiB},
super::{Granule64KiB, Granule512MiB, mair},
crate::{
memory::{
self,
self, Address, Physical, Virtual,
mmu::{AccessPermissions, AttributeFields, MemAttributes, MemoryRegion, PageAddress},
Address, Physical, Virtual,
},
platform,
},
Expand Down
2 changes: 1 addition & 1 deletion machine/src/arch/aarch64/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use {
crate::{synchronization, warn},
aarch64_cpu::{asm::barrier, registers::*},
core::{
num::{NonZeroU128, NonZeroU32, NonZeroU64},
num::{NonZeroU32, NonZeroU64, NonZeroU128},
ops::{Add, Div},
time::Duration,
},
Expand Down
2 changes: 1 addition & 1 deletion machine/src/console/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static CONSOLE: InitStateLock<&'static (dyn interface::All + Sync)> =
// Public Code
//--------------------------------------------------------------------------------------------------

use crate::synchronization::{interface::ReadWriteEx, InitStateLock};
use crate::synchronization::{InitStateLock, interface::ReadWriteEx};

/// Register a new console.
pub fn register_console(new_console: &'static (dyn interface::All + Sync)) {
Expand Down
2 changes: 1 addition & 1 deletion machine/src/drivers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
exception, println,
synchronization::{interface::ReadWriteEx, IRQSafeNullLock, InitStateLock},
synchronization::{IRQSafeNullLock, InitStateLock, interface::ReadWriteEx},
};

//--------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion machine/src/exception/asynchronous/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ use core::marker::PhantomData;
//--------------------------------------------------------------------------------------------------
// Public Code
//--------------------------------------------------------------------------------------------------
use crate::synchronization::{interface::ReadWriteEx, InitStateLock};
use crate::synchronization::{InitStateLock, interface::ReadWriteEx};

impl<T> IRQHandlerDescriptor<T>
where
Expand Down
2 changes: 1 addition & 1 deletion machine/src/exception/asynchronous/null_irq_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//! Null IRQ Manager.
use super::{interface, IRQContext, IRQHandlerDescriptor};
use super::{IRQContext, IRQHandlerDescriptor, interface};

//--------------------------------------------------------------------------------------------------
// Public Definitions
Expand Down
14 changes: 10 additions & 4 deletions machine/src/memory/mmu/mapping_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use {
super::{
types::{AccessPermissions, AttributeFields, MMIODescriptor, MemAttributes, MemoryRegion},
Address, Physical, Virtual,
types::{AccessPermissions, AttributeFields, MMIODescriptor, MemAttributes, MemoryRegion},
},
crate::{
info, mm, platform,
Expand Down Expand Up @@ -146,12 +146,16 @@ impl MappingRecord {
}

pub fn print(&self) {
info!(" -------------------------------------------------------------------------------------------------------------------------------------------");
info!(
" -------------------------------------------------------------------------------------------------------------------------------------------"
);
info!(
" {:^44} {:^30} {:^7} {:^9} {:^35}",
"Virtual", "Physical", "Size", "Attr", "Entity"
);
info!(" -------------------------------------------------------------------------------------------------------------------------------------------");
info!(
" -------------------------------------------------------------------------------------------------------------------------------------------"
);

for i in self.inner.iter().flatten() {
let size = i.num_pages * platform::memory::mmu::KernelGranule::SIZE;
Expand Down Expand Up @@ -203,7 +207,9 @@ impl MappingRecord {
}
}

info!(" -------------------------------------------------------------------------------------------------------------------------------------------");
info!(
" -------------------------------------------------------------------------------------------------------------------------------------------"
);
}
}

Expand Down
15 changes: 5 additions & 10 deletions machine/src/memory/mmu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,11 @@ pub unsafe fn kernel_map_mmio(
page_alloc::kernel_mmio_va_allocator().lock(|allocator| allocator.alloc(num_pages))?;

unsafe {
kernel_map_at_unchecked(
name,
&virt_region,
&phys_region,
&AttributeFields {
mem_attributes: MemAttributes::Device,
acc_perms: AccessPermissions::ReadWrite,
execute_never: true,
},
)?
kernel_map_at_unchecked(name, &virt_region, &phys_region, &AttributeFields {
mem_attributes: MemAttributes::Device,
acc_perms: AccessPermissions::ReadWrite,
execute_never: true,
})?
};

virt_region.start_addr()
Expand Down
4 changes: 2 additions & 2 deletions machine/src/platform/raspberrypi/device_driver/bcm/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use {
crate::{
memory::{Address, Virtual},
platform::{
device_driver::{common::MMIODerefWrapper, IRQNumber},
BcmHost,
device_driver::{IRQNumber, common::MMIODerefWrapper},
},
synchronization::{interface::Mutex, IRQSafeNullLock},
synchronization::{IRQSafeNullLock, interface::Mutex},
time,
},
core::{marker::PhantomData, time::Duration},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ use {
exception::asynchronous::IRQNumber,
memory::{Address, Virtual},
platform::{
device_driver::{common::MMIODerefWrapper, gpio},
BcmHost,
device_driver::{common::MMIODerefWrapper, gpio},
},
synchronization::{interface::Mutex, IRQSafeNullLock},
synchronization::{IRQSafeNullLock, interface::Mutex},
},
cfg_if::cfg_if,
core::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use {
devices::serial::SerialOps,
exception,
memory::{Address, Virtual},
platform::device_driver::{common::MMIODerefWrapper, gpio, IRQNumber},
synchronization::{interface::Mutex, IRQSafeNullLock},
platform::device_driver::{IRQNumber, common::MMIODerefWrapper, gpio},
synchronization::{IRQSafeNullLock, interface::Mutex},
},
core::fmt::{self, Arguments},
snafu::Snafu,
Expand Down Expand Up @@ -520,7 +520,7 @@ impl crate::drivers::interface::DeviceDriver for PL011Uart {
&'static self,
irq_number: &Self::IRQNumberType,
) -> Result<(), &'static str> {
use exception::asynchronous::{irq_manager, IRQHandlerDescriptor};
use exception::asynchronous::{IRQHandlerDescriptor, irq_manager};

let descriptor = IRQHandlerDescriptor::new(*irq_number, Self::COMPATIBLE, self);

Expand Down
2 changes: 1 addition & 1 deletion machine/src/platform/raspberrypi/memory/mmu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
use crate::{
memory::{
Physical, Virtual,
mmu::{
self as generic_mmu, AccessPermissions, AddressSpace, AssociatedTranslationTable,
AttributeFields, MemAttributes, MemoryRegion, PageAddress, TranslationGranule,
},
Physical, Virtual,
},
synchronization::InitStateLock,
};
Expand Down
2 changes: 1 addition & 1 deletion machine/src/platform/raspberrypi/memory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub mod mmu;
//--------------------------------------------------------------------------------------------------

use {
crate::memory::{mmu::PageAddress, Address, Physical, Virtual},
crate::memory::{Address, Physical, Virtual, mmu::PageAddress},
core::cell::UnsafeCell,
};

Expand Down

0 comments on commit f96cf8f

Please sign in to comment.