From f96cf8f85c743033c4fac5cab98a3b85257c22d0 Mon Sep 17 00:00:00 2001 From: Berkus Decker Date: Sat, 5 Oct 2024 18:22:04 +0300 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A7=B9=20Rustfmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/chainofcommand/src/main.rs | 6 +++--- machine/src/arch/aarch64/cpu/smp.rs | 2 +- machine/src/arch/aarch64/exception/mod.rs | 8 +------- machine/src/arch/aarch64/memory/mmu/mod.rs | 5 ++++- .../arch/aarch64/memory/mmu/translation_table.rs | 5 ++--- machine/src/arch/aarch64/time.rs | 2 +- machine/src/console/mod.rs | 2 +- machine/src/drivers.rs | 2 +- machine/src/exception/asynchronous/mod.rs | 2 +- .../exception/asynchronous/null_irq_manager.rs | 2 +- machine/src/memory/mmu/mapping_record.rs | 14 ++++++++++---- machine/src/memory/mmu/mod.rs | 15 +++++---------- .../raspberrypi/device_driver/bcm/gpio.rs | 4 ++-- .../raspberrypi/device_driver/bcm/mini_uart.rs | 4 ++-- .../raspberrypi/device_driver/bcm/pl011_uart.rs | 6 +++--- machine/src/platform/raspberrypi/memory/mmu.rs | 2 +- machine/src/platform/raspberrypi/memory/mod.rs | 2 +- 17 files changed, 40 insertions(+), 43 deletions(-) diff --git a/bin/chainofcommand/src/main.rs b/bin/chainofcommand/src/main.rs index 6e706a01..d2aa7644 100644 --- a/bin/chainofcommand/src/main.rs +++ b/bin/chainofcommand/src/main.rs @@ -4,9 +4,9 @@ #![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}, @@ -14,7 +14,7 @@ use { tty::IsTty, }, defer::defer, - futures::{future::FutureExt, Stream}, + futures::{Stream, future::FutureExt}, seahash::SeaHasher, std::{ fmt::Formatter, diff --git a/machine/src/arch/aarch64/cpu/smp.rs b/machine/src/arch/aarch64/cpu/smp.rs index a8b36490..7d989c2c 100644 --- a/machine/src/arch/aarch64/cpu/smp.rs +++ b/machine/src/arch/aarch64/cpu/smp.rs @@ -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 diff --git a/machine/src/arch/aarch64/exception/mod.rs b/machine/src/arch/aarch64/exception/mod.rs index b27e4009..5cce2c0b 100644 --- a/machine/src/arch/aarch64/exception/mod.rs +++ b/machine/src/arch/aarch64/exception/mod.rs @@ -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() { diff --git a/machine/src/arch/aarch64/memory/mmu/mod.rs b/machine/src/arch/aarch64/memory/mmu/mod.rs index b796bc33..8f4e8372 100644 --- a/machine/src/arch/aarch64/memory/mmu/mod.rs +++ b/machine/src/arch/aarch64/memory/mmu/mod.rs @@ -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, }, diff --git a/machine/src/arch/aarch64/memory/mmu/translation_table.rs b/machine/src/arch/aarch64/memory/mmu/translation_table.rs index 5814bbcb..685162a8 100644 --- a/machine/src/arch/aarch64/memory/mmu/translation_table.rs +++ b/machine/src/arch/aarch64/memory/mmu/translation_table.rs @@ -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, }, diff --git a/machine/src/arch/aarch64/time.rs b/machine/src/arch/aarch64/time.rs index 90a43238..f862953e 100644 --- a/machine/src/arch/aarch64/time.rs +++ b/machine/src/arch/aarch64/time.rs @@ -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, }, diff --git a/machine/src/console/mod.rs b/machine/src/console/mod.rs index 0a4494e9..e76129f7 100644 --- a/machine/src/console/mod.rs +++ b/machine/src/console/mod.rs @@ -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)) { diff --git a/machine/src/drivers.rs b/machine/src/drivers.rs index 108f5576..d613eec2 100644 --- a/machine/src/drivers.rs +++ b/machine/src/drivers.rs @@ -1,6 +1,6 @@ use crate::{ exception, println, - synchronization::{interface::ReadWriteEx, IRQSafeNullLock, InitStateLock}, + synchronization::{IRQSafeNullLock, InitStateLock, interface::ReadWriteEx}, }; //-------------------------------------------------------------------------------------------------- diff --git a/machine/src/exception/asynchronous/mod.rs b/machine/src/exception/asynchronous/mod.rs index 98b8f367..6dd1bc96 100644 --- a/machine/src/exception/asynchronous/mod.rs +++ b/machine/src/exception/asynchronous/mod.rs @@ -101,7 +101,7 @@ use core::marker::PhantomData; //-------------------------------------------------------------------------------------------------- // Public Code //-------------------------------------------------------------------------------------------------- -use crate::synchronization::{interface::ReadWriteEx, InitStateLock}; +use crate::synchronization::{InitStateLock, interface::ReadWriteEx}; impl IRQHandlerDescriptor where diff --git a/machine/src/exception/asynchronous/null_irq_manager.rs b/machine/src/exception/asynchronous/null_irq_manager.rs index 438f9649..4cb999fd 100644 --- a/machine/src/exception/asynchronous/null_irq_manager.rs +++ b/machine/src/exception/asynchronous/null_irq_manager.rs @@ -4,7 +4,7 @@ //! Null IRQ Manager. -use super::{interface, IRQContext, IRQHandlerDescriptor}; +use super::{IRQContext, IRQHandlerDescriptor, interface}; //-------------------------------------------------------------------------------------------------- // Public Definitions diff --git a/machine/src/memory/mmu/mapping_record.rs b/machine/src/memory/mmu/mapping_record.rs index 48a00214..1dfa8ef2 100644 --- a/machine/src/memory/mmu/mapping_record.rs +++ b/machine/src/memory/mmu/mapping_record.rs @@ -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, @@ -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; @@ -203,7 +207,9 @@ impl MappingRecord { } } - info!(" -------------------------------------------------------------------------------------------------------------------------------------------"); + info!( + " -------------------------------------------------------------------------------------------------------------------------------------------" + ); } } diff --git a/machine/src/memory/mmu/mod.rs b/machine/src/memory/mmu/mod.rs index 41690fed..8f60d4d4 100644 --- a/machine/src/memory/mmu/mod.rs +++ b/machine/src/memory/mmu/mod.rs @@ -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() diff --git a/machine/src/platform/raspberrypi/device_driver/bcm/gpio.rs b/machine/src/platform/raspberrypi/device_driver/bcm/gpio.rs index b55bfa90..da5b9d63 100644 --- a/machine/src/platform/raspberrypi/device_driver/bcm/gpio.rs +++ b/machine/src/platform/raspberrypi/device_driver/bcm/gpio.rs @@ -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}, diff --git a/machine/src/platform/raspberrypi/device_driver/bcm/mini_uart.rs b/machine/src/platform/raspberrypi/device_driver/bcm/mini_uart.rs index 9292f943..179f2568 100644 --- a/machine/src/platform/raspberrypi/device_driver/bcm/mini_uart.rs +++ b/machine/src/platform/raspberrypi/device_driver/bcm/mini_uart.rs @@ -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::{ diff --git a/machine/src/platform/raspberrypi/device_driver/bcm/pl011_uart.rs b/machine/src/platform/raspberrypi/device_driver/bcm/pl011_uart.rs index 9d6aa163..95b4c015 100644 --- a/machine/src/platform/raspberrypi/device_driver/bcm/pl011_uart.rs +++ b/machine/src/platform/raspberrypi/device_driver/bcm/pl011_uart.rs @@ -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, @@ -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); diff --git a/machine/src/platform/raspberrypi/memory/mmu.rs b/machine/src/platform/raspberrypi/memory/mmu.rs index a55c368e..6ebeae50 100644 --- a/machine/src/platform/raspberrypi/memory/mmu.rs +++ b/machine/src/platform/raspberrypi/memory/mmu.rs @@ -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, }; diff --git a/machine/src/platform/raspberrypi/memory/mod.rs b/machine/src/platform/raspberrypi/memory/mod.rs index 7a248098..e112a6b5 100644 --- a/machine/src/platform/raspberrypi/memory/mod.rs +++ b/machine/src/platform/raspberrypi/memory/mod.rs @@ -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, };