Skip to content

Commit 912e9cb

Browse files
committed
beauty: beautify code style
1 parent beba529 commit 912e9cb

File tree

9 files changed

+72
-110
lines changed

9 files changed

+72
-110
lines changed

acpi/src/iort.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
///Apart from the basic header, the table contains a number of IORT Nodes.
2-
/// Each node represents a component, which can be an SMMU,
3-
/// an ITS Group, a root complex, or a component that is described in the namespace.
4-
use core::marker::PhantomData;
51
use crate::{
62
sdt::{SdtHeader, Signature},
73
AcpiTable,
84
};
5+
///Apart from the basic header, the table contains a number of IORT Nodes.
6+
/// Each node represents a component, which can be an SMMU,
7+
/// an ITS Group, a root complex, or a component that is described in the namespace.
8+
use core::marker::PhantomData;
99

10-
pub enum IortError {
11-
12-
}
10+
pub enum IortError {}
1311

1412
#[derive(Debug, Clone, Copy)]
1513
#[repr(C, packed)]
@@ -47,11 +45,7 @@ impl Iort {
4745
let pointer = unsafe { (self as *const Iort).add(1) as *const u8 };
4846
let remaining_length = self.header.length as u32 - core::mem::size_of::<Iort>() as u32;
4947

50-
IortNodeIter {
51-
pointer,
52-
remaining_length,
53-
_phantom: PhantomData
54-
}
48+
IortNodeIter { pointer, remaining_length, _phantom: PhantomData }
5549
}
5650
}
5751

@@ -81,10 +75,10 @@ pub enum IortNode<'a> {
8175

8276
impl IortNode<'_> {
8377
pub fn id_mapping_array(&self) -> Option<&[IortIdMapping]> {
84-
let node_header = unsafe{ *(self as *const IortNode as *const IortNodeHeader) };
78+
let node_header = unsafe { *(self as *const IortNode as *const IortNodeHeader) };
8579
let id_mapping_num = node_header.id_mapping_num;
8680
let id_mapping_array_offset = node_header.id_mapping_array_offset;
87-
81+
8882
if id_mapping_num == 0 {
8983
return None;
9084
} else {
@@ -99,7 +93,7 @@ impl IortNode<'_> {
9993
pub struct IortNodeIter<'a> {
10094
pointer: *const u8,
10195
remaining_length: u32,
102-
_phantom: PhantomData<&'a ()>
96+
_phantom: PhantomData<&'a ()>,
10397
}
10498

10599
impl<'a> Iterator for IortNodeIter<'a> {
@@ -131,7 +125,6 @@ impl<'a> Iterator for IortNodeIter<'a> {
131125
}
132126
}
133127

134-
135128
#[derive(Debug, Clone, Copy)]
136129
#[repr(C, packed)]
137130
pub struct ItsNode {
@@ -147,7 +140,7 @@ pub struct NamedComponentNode {
147140
node_flags: u32,
148141
mem_access_properties: u64,
149142
device_mem_address_size_limit: u8,
150-
// This is followed by a ASCII Null terminated string
143+
// This is followed by a ASCII Null terminated string
151144
// with the full path to the entry in the namespace for this object
152145
// and a padding to 32-bit word-aligned.
153146
}
@@ -234,4 +227,4 @@ pub struct IortIdMapping {
234227
output_base: u32,
235228
output_reference: u32,
236229
flags: u32,
237-
}
230+
}

acpi/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ pub mod bgrt;
7272
pub mod fadt;
7373
pub mod handler;
7474
pub mod hpet;
75+
pub mod iort;
7576
pub mod madt;
7677
pub mod mcfg;
78+
pub mod mpam;
7779
pub mod rsdp;
7880
pub mod sdt;
7981
pub mod spcr;
8082
pub mod srat;
81-
pub mod mpam;
82-
pub mod iort;
8383

8484
#[cfg(feature = "allocator_api")]
8585
mod managed_slice;

acpi/src/madt.rs

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::{
2-
sdt::{ExtendedField, SdtHeader, Signature}, AcpiTable
2+
sdt::{ExtendedField, SdtHeader, Signature},
3+
AcpiTable,
34
};
45
use bit_field::BitField;
56
use core::{marker::PhantomData, mem};
@@ -123,10 +124,7 @@ impl Madt {
123124
NmiProcessor,
124125
NmiSource,
125126
},
126-
processor::{
127-
X86Processor,
128-
ProcessorState,
129-
},
127+
processor::{ProcessorState, X86Processor},
130128
},
131129
AcpiError,
132130
};
@@ -156,8 +154,7 @@ impl Madt {
156154
let mut interrupt_source_overrides = crate::ManagedSlice::new_in(iso_count, allocator.clone())?;
157155
let mut nmi_sources = crate::ManagedSlice::new_in(nmi_source_count, allocator.clone())?;
158156
let mut local_apic_nmi_lines = crate::ManagedSlice::new_in(local_nmi_line_count, allocator.clone())?;
159-
let mut application_processors =
160-
crate::ManagedSlice::new_in(processor_count, allocator)?; // Subtract one for the BSP
157+
let mut application_processors = crate::ManagedSlice::new_in(processor_count, allocator)?; // Subtract one for the BSP
161158
let mut found_bsp = false;
162159

163160
io_apic_count = 0;
@@ -324,14 +321,7 @@ impl Madt {
324321
{
325322
use crate::{
326323
platform::{
327-
interrupt::{
328-
Gic,
329-
Gicd,
330-
Gicc,
331-
GicMsiFrame,
332-
Gicr,
333-
GicIts,
334-
},
324+
interrupt::{Gic, GicIts, GicMsiFrame, Gicc, Gicd, Gicr},
335325
processor::Arm64Processor,
336326
},
337327
AcpiError,
@@ -348,7 +338,10 @@ impl Madt {
348338

349339
for entry in self.entries() {
350340
match entry {
351-
MadtEntry::Gicc(_) => {gicc_count += 1; processor_count += 1;},
341+
MadtEntry::Gicc(_) => {
342+
gicc_count += 1;
343+
processor_count += 1;
344+
}
352345
MadtEntry::Gicd(_) => gicd_count += 1,
353346
MadtEntry::GicMsiFrame(_) => gic_msi_frame_count += 1,
354347
MadtEntry::GicRedistributor(_) => gicr_count += 1,
@@ -359,10 +352,13 @@ impl Madt {
359352

360353
let mut gicc: crate::ManagedSlice<Gicc, A> = crate::ManagedSlice::new_in(gicc_count, allocator.clone())?;
361354
let mut gicd: crate::ManagedSlice<Gicd, A> = crate::ManagedSlice::new_in(gicd_count, allocator.clone())?;
362-
let mut gic_msi_frame: crate::ManagedSlice<GicMsiFrame, A> = crate::ManagedSlice::new_in(gic_msi_frame_count, allocator.clone())?;
355+
let mut gic_msi_frame: crate::ManagedSlice<GicMsiFrame, A> =
356+
crate::ManagedSlice::new_in(gic_msi_frame_count, allocator.clone())?;
363357
let mut gicr: crate::ManagedSlice<Gicr, A> = crate::ManagedSlice::new_in(gicr_count, allocator.clone())?;
364-
let mut gic_its: crate::ManagedSlice<GicIts, A> = crate::ManagedSlice::new_in(gic_its_count, allocator.clone())?;
365-
let mut processors: crate::ManagedSlice<Arm64Processor, A> = crate::ManagedSlice::new_in(processor_count, allocator.clone())?;
358+
let mut gic_its: crate::ManagedSlice<GicIts, A> =
359+
crate::ManagedSlice::new_in(gic_its_count, allocator.clone())?;
360+
let mut processors: crate::ManagedSlice<Arm64Processor, A> =
361+
crate::ManagedSlice::new_in(processor_count, allocator.clone())?;
366362
// let mut boot_processor = None;
367363

368364
gicc_count = 0;
@@ -425,25 +421,20 @@ impl Madt {
425421
gicr_count += 1;
426422
}
427423
MadtEntry::GicInterruptTranslationService(entry) => {
428-
gic_its[gic_its_count] = GicIts {
429-
id: entry.id,
430-
physical_base_address: entry.physical_base_address,
431-
};
424+
gic_its[gic_its_count] =
425+
GicIts { id: entry.id, physical_base_address: entry.physical_base_address };
432426
gic_its_count += 1;
433427
}
434428
_ => {
435429
return Err(AcpiError::InvalidMadt(MadtError::UnexpectedEntry));
436-
},
430+
}
437431
}
438432
}
439433

440-
Ok((InterruptModel::Gic(Gic::new(
441-
gicc,
442-
gicd,
443-
gic_msi_frame,
444-
gicr,
445-
gic_its,
446-
)), Some(ProcessorInfo::new_arm64(processors))))
434+
Ok((
435+
InterruptModel::Gic(Gic::new(gicc, gicd, gic_msi_frame, gicr, gic_its)),
436+
Some(ProcessorInfo::new_arm64(processors)),
437+
))
447438
}
448439

449440
pub fn entries(&self) -> MadtEntryIter {

acpi/src/mpam.rs

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,20 @@ impl Mpam {
4343
let pointer = unsafe { (self as *const Mpam).add(1) as *const u8 };
4444
let remaining_length = self.header.length as u32 - size_of::<Mpam>() as u32;
4545

46-
MscNodeIter {
47-
pointer,
48-
remaining_length,
49-
_phantom: PhantomData
50-
}
46+
MscNodeIter { pointer, remaining_length, _phantom: PhantomData }
5147
}
5248

5349
pub fn mmio_ranges(&self) -> impl Iterator<Item = (u64, u32)> + '_ {
5450
self.nodes().filter_map(|node| {
55-
return if node.if_type == 0x00 {
56-
Some((node.base_address, node.mmio_size))
57-
} else {
58-
None
59-
};
51+
return if node.if_type == 0x00 { Some((node.base_address, node.mmio_size)) } else { None };
6052
})
6153
}
6254
}
6355

6456
pub struct MscNodeIter<'a> {
6557
pointer: *const u8,
6658
remaining_length: u32,
67-
_phantom: PhantomData<&'a ()>
59+
_phantom: PhantomData<&'a ()>,
6860
}
6961

7062
impl Iterator for MscNodeIter<'_> {
@@ -77,7 +69,7 @@ impl Iterator for MscNodeIter<'_> {
7769

7870
let node = unsafe { &*(self.pointer as *const MscNode) };
7971
let node_length = node.length as u32;
80-
72+
8173
self.pointer = unsafe { self.pointer.add(node_length as usize) };
8274
self.remaining_length -= node_length;
8375

@@ -95,12 +87,12 @@ pub struct MscNode {
9587
pub id: u32,
9688
pub base_address: u64,
9789
pub mmio_size: u32,
98-
90+
9991
pub overflow_interrupt: u32,
10092
pub overflow_interrupt_flags: u32,
10193
pub reserved2: u32,
10294
pub overflow_interrupt_affinity: u32,
103-
95+
10496
pub error_interrupt: u32,
10597
pub error_interrupt_flags: u32,
10698
pub reserved3: u32,
@@ -135,7 +127,7 @@ impl MscNode {
135127
pointer: ptr,
136128
remaining_length,
137129
remaining_nodes: self.resource_node_num,
138-
_phantom: PhantomData
130+
_phantom: PhantomData,
139131
}
140132
}
141133
}
@@ -144,7 +136,7 @@ pub struct ResourceNodeIter<'a> {
144136
pointer: *const u8,
145137
remaining_length: u32,
146138
remaining_nodes: u32,
147-
_phantom: PhantomData<&'a ()>
139+
_phantom: PhantomData<&'a ()>,
148140
}
149141

150142
impl Iterator for ResourceNodeIter<'_> {
@@ -156,8 +148,9 @@ impl Iterator for ResourceNodeIter<'_> {
156148
}
157149

158150
let node = unsafe { &*(self.pointer as *const ResourceNode) };
159-
let node_length = size_of::<ResourceNode>() + (node.func_dep_num as usize) * size_of::<FunctionDependency>();
160-
151+
let node_length =
152+
size_of::<ResourceNode>() + (node.func_dep_num as usize) * size_of::<FunctionDependency>();
153+
161154
self.pointer = unsafe { self.pointer.add(node_length) };
162155
self.remaining_length -= node_length as u32;
163156
self.remaining_nodes -= 1;
@@ -194,9 +187,7 @@ impl ResourceNode {
194187
let ptr = self as *const ResourceNode;
195188
let ptr = unsafe { ptr.add(1) };
196189
let ptr = ptr as *const FunctionDependency;
197-
unsafe {
198-
core::slice::from_raw_parts(ptr, self.func_dep_num as usize)
199-
}
190+
unsafe { core::slice::from_raw_parts(ptr, self.func_dep_num as usize) }
200191
}
201192
}
202193

@@ -206,4 +197,4 @@ pub struct FunctionDependency {
206197
// Function dependency structure
207198
pub producer: u32,
208199
pub reserved: u32,
209-
}
200+
}

acpi/src/platform/interrupt.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,7 @@ where
188188
gicr: ManagedSlice<'a, Gicr, A>,
189189
gic_its: ManagedSlice<'a, GicIts, A>,
190190
) -> Self {
191-
Self {
192-
gicc,
193-
gicd,
194-
gic_msi_frame,
195-
gicr,
196-
gic_its,
197-
}
191+
Self { gicc, gicd, gic_msi_frame, gicr, gic_its }
198192
}
199193
}
200194

acpi/src/platform/processor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::alloc::Allocator;
33

44
/// Processor trait
55
pub trait Processor {
6-
/// The OS associates this GICC Structure with a processor device object in the namespace
6+
/// The OS associates this GICC Structure with a processor device object in the namespace
77
/// when the _UID child object of the processor device evaluates to a numeric value that matches the numeric value in this field.
88
fn processor_uid(&self) -> u32;
99
}
@@ -23,7 +23,7 @@ impl Processor for X86Processor {
2323
/// Arm64 processor
2424
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
2525
pub struct Arm64Processor {
26-
/// The OS associates this GICC Structure with a processor device object in the namespace
26+
/// The OS associates this GICC Structure with a processor device object in the namespace
2727
/// when the _UID child object of the processor device evaluates to a numeric value that matches the numeric value in this field.
2828
pub processor_uid: u32,
2929
/// This fields follows the MPIDR formatting of ARM architecture.
@@ -89,4 +89,4 @@ where
8989
pub fn new_arm64(processors: ManagedSlice<'a, Arm64Processor, A>) -> Self {
9090
ProcessorInfo::Arm64Processors(processors)
9191
}
92-
}
92+
}

acpi/src/rsdp.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use uefi::table::{cfg::ACPI2_GUID, Boot, SystemTable};
22

33
use crate::{AcpiError, AcpiHandler, AcpiResult, PhysicalMapping};
4-
use core::{mem, ops::Range, slice, str, ffi::c_void};
4+
use core::{ffi::c_void, mem, ops::Range, slice, str};
55

66
/// The size in bytes of the ACPI 1.0 RSDP.
77
const RSDP_V1_LENGTH: usize = 20;
@@ -112,14 +112,13 @@ impl Rsdp {
112112
where
113113
H: AcpiHandler,
114114
{
115-
let system_table = unsafe {
116-
SystemTable::<Boot>::from_ptr(system_table as *mut c_void).unwrap()
117-
};
115+
let system_table = unsafe { SystemTable::<Boot>::from_ptr(system_table as *mut c_void).unwrap() };
118116

119117
let config_table = system_table.config_table();
120118
let rsdp = config_table.iter().find_map(|entry| {
121119
if entry.guid == ACPI2_GUID {
122-
let rsdp_mapping = unsafe { handler.map_physical_region::<Rsdp>(entry.address as usize, mem::size_of::<Rsdp>()) };
120+
let rsdp_mapping =
121+
unsafe { handler.map_physical_region::<Rsdp>(entry.address as usize, mem::size_of::<Rsdp>()) };
123122
match rsdp_mapping.validate() {
124123
Ok(()) => Some(rsdp_mapping),
125124
Err(AcpiError::RsdpIncorrectSignature) => None,

0 commit comments

Comments
 (0)