浏览代码

Format all crates

Isaac Woods 5 年之前
父节点
当前提交
b8f9690989
共有 13 个文件被更改,包括 35 次插入80 次删除
  1. 2 4
      acpi/src/lib.rs
  2. 2 6
      acpi/src/madt.rs
  3. 2 2
      acpi/src/mcfg.rs
  4. 1 2
      acpi/src/rsdp_search.rs
  5. 3 9
      acpi/src/sdt.rs
  6. 2 3
      aml/src/misc.rs
  7. 1 5
      aml/src/opcode.rs
  8. 2 9
      aml/src/parser.rs
  9. 4 3
      aml/src/pkg_length.rs
  10. 4 15
      aml/src/term_object.rs
  11. 1 2
      aml/src/type1.rs
  12. 4 4
      aml/src/type2.rs
  13. 7 16
      aml_tester/src/main.rs

+ 2 - 4
acpi/src/lib.rs

@@ -219,8 +219,7 @@ where
         (*mapping).validate(b"RSDT")?;
 
         let num_tables = ((*mapping).length() as usize - mem::size_of::<SdtHeader>()) / mem::size_of::<u32>();
-        let tables_base =
-            ((mapping.virtual_start.as_ptr() as usize) + mem::size_of::<SdtHeader>()) as *const u32;
+        let tables_base = ((mapping.virtual_start.as_ptr() as usize) + mem::size_of::<SdtHeader>()) as *const u32;
 
         for i in 0..num_tables {
             sdt::dispatch_sdt(&mut acpi, handler, unsafe { *tables_base.offset(i as isize) } as usize)?;
@@ -232,8 +231,7 @@ where
         (*mapping).validate(b"XSDT")?;
 
         let num_tables = ((*mapping).length() as usize - mem::size_of::<SdtHeader>()) / mem::size_of::<u64>();
-        let tables_base =
-            ((mapping.virtual_start.as_ptr() as usize) + mem::size_of::<SdtHeader>()) as *const u64;
+        let tables_base = ((mapping.virtual_start.as_ptr() as usize) + mem::size_of::<SdtHeader>()) as *const u64;
 
         for i in 0..num_tables {
             sdt::dispatch_sdt(&mut acpi, handler, unsafe { *tables_base.offset(i as isize) } as usize)?;

+ 2 - 6
acpi/src/madt.rs

@@ -432,12 +432,8 @@ fn parse_apic_model(acpi: &mut Acpi, mapping: &PhysicalMapping<Madt>) -> Result<
                     (false, false) => ProcessorState::Running,
                 };
 
-                let processor = Processor {
-                    processor_uid: entry.processor_id,
-                    local_apic_id: entry.apic_id,
-                    state,
-                    is_ap,
-                };
+                let processor =
+                    Processor { processor_uid: entry.processor_id, local_apic_id: entry.apic_id, state, is_ap };
 
                 if is_ap {
                     acpi.application_processors.push(processor);

+ 2 - 2
acpi/src/mcfg.rs

@@ -48,8 +48,8 @@ impl Mcfg {
         let num_entries = length / mem::size_of::<McfgEntry>();
 
         unsafe {
-            let pointer = (self as *const Mcfg as *const u8).offset(mem::size_of::<Mcfg>() as isize)
-                as *const McfgEntry;
+            let pointer =
+                (self as *const Mcfg as *const u8).offset(mem::size_of::<Mcfg>() as isize) as *const McfgEntry;
             slice::from_raw_parts(pointer, num_entries)
         }
     }

+ 1 - 2
acpi/src/rsdp_search.rs

@@ -25,8 +25,7 @@ where
 {
     // Read base segment from BIOS area. This is not always given by the bios, so it needs to be
     // checked. We left shift 4 because it is a segment ptr.
-    let ebda_start_mapping =
-        handler.map_physical_region::<u16>(EBDA_START_SEGMENT_PTR, mem::size_of::<u16>());
+    let ebda_start_mapping = handler.map_physical_region::<u16>(EBDA_START_SEGMENT_PTR, mem::size_of::<u16>());
     let ebda_start = (*ebda_start_mapping as usize) << 4;
     handler.unmap_physical_region(ebda_start_mapping);
 

+ 3 - 9
acpi/src/sdt.rs

@@ -156,11 +156,7 @@ where
 
 /// This takes the physical address of an SDT, maps it correctly and dispatches it to whatever
 /// function parses that table.
-pub(crate) fn dispatch_sdt<H>(
-    acpi: &mut Acpi,
-    handler: &mut H,
-    physical_address: usize,
-) -> Result<(), AcpiError>
+pub(crate) fn dispatch_sdt<H>(acpi: &mut Acpi, handler: &mut H, physical_address: usize) -> Result<(), AcpiError>
 where
     H: AcpiHandler,
 {
@@ -186,15 +182,13 @@ where
         }
 
         "APIC" => {
-            let madt_mapping =
-                handler.map_physical_region::<Madt>(physical_address, header.length() as usize);
+            let madt_mapping = handler.map_physical_region::<Madt>(physical_address, header.length() as usize);
             crate::madt::parse_madt(acpi, handler, &madt_mapping)?;
             handler.unmap_physical_region(madt_mapping);
         }
 
         "MCFG" => {
-            let mcfg_mapping =
-                handler.map_physical_region::<Mcfg>(physical_address, header.length() as usize);
+            let mcfg_mapping = handler.map_physical_region::<Mcfg>(physical_address, header.length() as usize);
             crate::mcfg::parse_mcfg(acpi, &mcfg_mapping)?;
             handler.unmap_physical_region(mcfg_mapping);
         }

+ 2 - 3
aml/src/misc.rs

@@ -64,9 +64,8 @@ where
      * Arg5Op = 0x6d
      * Arg6Op = 0x6e
      */
-    let arg_parser = |i, arg_opcode| {
-        opcode(arg_opcode).then(comment_scope_verbose("ArgObj", id())).map(move |((), _)| Ok(i))
-    };
+    let arg_parser =
+        |i, arg_opcode| opcode(arg_opcode).then(comment_scope_verbose("ArgObj", id())).map(move |((), _)| Ok(i));
 
     choice!(
         arg_parser(0, opcode::ARG0_OP),

+ 1 - 5
aml/src/opcode.rs

@@ -94,11 +94,7 @@ mod tests {
     fn empty() {
         let mut context = AmlContext::new();
         check_err!(opcode(NULL_NAME).parse(&[], &mut context), AmlError::UnexpectedEndOfStream, &[]);
-        check_err!(
-            ext_opcode(EXT_DEF_FIELD_OP).parse(&[], &mut context),
-            AmlError::UnexpectedEndOfStream,
-            &[]
-        );
+        check_err!(ext_opcode(EXT_DEF_FIELD_OP).parse(&[], &mut context), AmlError::UnexpectedEndOfStream, &[]);
     }
 
     #[test]

+ 2 - 9
aml/src/parser.rs

@@ -115,10 +115,7 @@ where
         Ok((
             &input[4..],
             context,
-            input[0] as u32
-                + ((input[1] as u32) << 8)
-                + ((input[2] as u32) << 16)
-                + ((input[3] as u32) << 24),
+            input[0] as u32 + ((input[1] as u32) << 8) + ((input[2] as u32) << 16) + ((input[3] as u32) << 24),
         ))
     }
 }
@@ -471,11 +468,7 @@ mod tests {
         check_err!(take_u16().parse(&[0x34], &mut context), AmlError::UnexpectedEndOfStream, &[0x34]);
         check_ok!(take_u16().parse(&[0x34, 0x12], &mut context), 0x1234, &[]);
 
-        check_err!(
-            take_u32().parse(&[0x34, 0x12], &mut context),
-            AmlError::UnexpectedEndOfStream,
-            &[0x34, 0x12]
-        );
+        check_err!(take_u32().parse(&[0x34, 0x12], &mut context), AmlError::UnexpectedEndOfStream, &[0x34, 0x12]);
         check_ok!(take_u32().parse(&[0x34, 0x12, 0xf4, 0xc3, 0x3e], &mut context), 0xc3f41234, &[0x3e]);
 
         check_err!(take_u64().parse(&[0x34], &mut context), AmlError::UnexpectedEndOfStream, &[0x34]);

+ 4 - 3
aml/src/pkg_length.rs

@@ -70,9 +70,10 @@ where
                     (
                         new_input,
                         context,
-                        bytes.iter().enumerate().fold(initial_length, |length, (i, &byte)| {
-                            length + (u32::from(byte) << (4 + i * 8))
-                        }),
+                        bytes
+                            .iter()
+                            .enumerate()
+                            .fold(initial_length, |length, (i, &byte)| length + (u32::from(byte) << (4 + i * 8))),
                     )
                 }
 

+ 4 - 15
aml/src/term_object.rs

@@ -603,9 +603,7 @@ where
             opcode::DWORD_CONST => {
                 take_u32().map(|value| Ok(AmlValue::Integer(value as u64))).parse(new_input, context)
             }
-            opcode::QWORD_CONST => {
-                take_u64().map(|value| Ok(AmlValue::Integer(value))).parse(new_input, context)
-            }
+            opcode::QWORD_CONST => take_u64().map(|value| Ok(AmlValue::Integer(value))).parse(new_input, context),
             opcode::STRING_PREFIX => string_parser.parse(new_input, context),
             opcode::ZERO_OP => Ok((new_input, context, AmlValue::Integer(0))),
             opcode::ONE_OP => Ok((new_input, context, AmlValue::Integer(1))),
@@ -618,8 +616,7 @@ where
     comment_scope_verbose(
         "ComputationalData",
         choice!(
-            ext_opcode(opcode::EXT_REVISION_OP)
-                .map(|_| Ok(AmlValue::Integer(crate::AML_INTERPRETER_REVISION))),
+            ext_opcode(opcode::EXT_REVISION_OP).map(|_| Ok(AmlValue::Integer(crate::AML_INTERPRETER_REVISION))),
             const_parser,
             make_parser_concrete!(def_buffer())
         ),
@@ -654,16 +651,8 @@ mod test {
             AmlValue::Integer(crate::AML_INTERPRETER_REVISION),
             &[]
         );
-        check_ok!(
-            computational_data().parse(&[0x0a, 0xf3, 0x35], &mut context),
-            AmlValue::Integer(0xf3),
-            &[0x35]
-        );
-        check_ok!(
-            computational_data().parse(&[0x0b, 0xf3, 0x35], &mut context),
-            AmlValue::Integer(0x35f3),
-            &[]
-        );
+        check_ok!(computational_data().parse(&[0x0a, 0xf3, 0x35], &mut context), AmlValue::Integer(0xf3), &[0x35]);
+        check_ok!(computational_data().parse(&[0x0b, 0xf3, 0x35], &mut context), AmlValue::Integer(0x35f3), &[]);
         check_ok!(
             computational_data().parse(&[0x0c, 0xf3, 0x35, 0x12, 0x65, 0xff, 0x00], &mut context),
             AmlValue::Integer(0x651235f3),

+ 1 - 2
aml/src/type1.rs

@@ -56,8 +56,7 @@ where
                 .map_with_context(|((predicate, then_branch), else_branch), context| {
                     let branch = if predicate { then_branch } else { else_branch };
 
-                    match term_list(PkgLength::from_raw_length(branch, branch.len() as u32))
-                        .parse(branch, context)
+                    match term_list(PkgLength::from_raw_length(branch, branch.len() as u32)).parse(branch, context)
                     {
                         Ok((_, context, result)) => (Ok(result), context),
                         Err((_, context, err)) => (Err(err), context),

+ 4 - 4
aml/src/type2.rs

@@ -58,9 +58,8 @@ where
      * after the store (as opposed to the data we think we put into it), because some stores can
      * alter the data during the store.
      */
-    opcode(opcode::DEF_STORE_OP)
-        .then(comment_scope("DefStore", term_arg().then(super_name())))
-        .map_with_context(|((), (value, target)), context| {
+    opcode(opcode::DEF_STORE_OP).then(comment_scope("DefStore", term_arg().then(super_name()))).map_with_context(
+        |((), (value, target)), context| {
             match target {
                 Target::Name(ref path) => {
                     let handle =
@@ -88,7 +87,8 @@ where
                     unimplemented!()
                 }
             }
-        })
+        },
+    )
 }
 
 fn method_invocation<'a, 'c>() -> impl Parser<'a, 'c, AmlValue>

+ 7 - 16
aml_tester/src/main.rs

@@ -2,10 +2,10 @@
  * This is a small program that is meant for testing the AML parser on artificial
  * AML. We want to:
  *      - scan a directory for ASL files
- *      - compile them using `iasl` into AML files (these should be gitignored), but only if the ASL file
- *        has a newer timestamp than the AML file (or just compile if there isn't a corresponding AML file)
- *      - Run the AML parser on each AML file, printing test output like `cargo test` does in a nice table
- *        for each AML file
+ *      - compile them using `iasl` into AML files (these should be gitignored), but only if the ASL file has a
+ *        newer timestamp than the AML file (or just compile if there isn't a corresponding AML file)
+ *      - Run the AML parser on each AML file, printing test output like `cargo test` does in a nice table for
+ *        each AML file
  *      - For failing tests, print out a nice summary of the errors for each file
  */
 
@@ -41,9 +41,7 @@ fn main() -> std::io::Result<()> {
      * parser.
      */
     let aml_files = fs::read_dir(dir_path)?
-        .filter(|entry| {
-            entry.is_ok() && entry.as_ref().unwrap().path().extension() == Some(OsStr::new("aml"))
-        })
+        .filter(|entry| entry.is_ok() && entry.as_ref().unwrap().path().extension() == Some(OsStr::new("aml")))
         .map(|entry| entry.unwrap());
 
     let (passed, failed) = aml_files.fold((0, 0), |(passed, failed), file_entry| {
@@ -63,12 +61,7 @@ fn main() -> std::io::Result<()> {
             }
 
             Err(err) => {
-                println!(
-                    "{}Failed ({:?}){}",
-                    termion::color::Fg(termion::color::Red),
-                    err,
-                    termion::style::Reset
-                );
+                println!("{}Failed ({:?}){}", termion::color::Fg(termion::color::Red), err, termion::style::Reset);
                 (passed, failed + 1)
             }
         }
@@ -80,9 +73,7 @@ fn main() -> std::io::Result<()> {
 
 fn compile_asl_files(dir_path: &Path) -> std::io::Result<()> {
     let mut asl_files = fs::read_dir(dir_path)?
-        .filter(|entry| {
-            entry.is_ok() && entry.as_ref().unwrap().path().extension() == Some(OsStr::new("asl"))
-        })
+        .filter(|entry| entry.is_ok() && entry.as_ref().unwrap().path().extension() == Some(OsStr::new("asl")))
         .map(|file| file.unwrap())
         .peekable();