Forráskód Böngészése

Merge pull request #74 from toku-sa-n/fmt

style: apply `rustfmt`
Isaac Woods 4 éve
szülő
commit
1fb9bd9dfc
7 módosított fájl, 78 hozzáadás és 85 törlés
  1. 2 4
      src/boot_loader_name.rs
  2. 2 3
      src/command_line.rs
  3. 1 1
      src/framebuffer.rs
  4. 3 4
      src/header.rs
  5. 6 6
      src/module.rs
  6. 20 22
      src/rsdp.rs
  7. 44 45
      src/vbe_info.rs

+ 2 - 4
src/boot_loader_name.rs

@@ -1,4 +1,3 @@
-
 /// This Tag contains the name of the bootloader that is booting the kernel.
 ///
 /// The name is a normal C-style UTF-8 zero-terminated string that can be
@@ -23,11 +22,10 @@ impl BootLoaderNameTag {
     /// }
     /// ```
     pub fn name(&self) -> &str {
-        use core::{mem,str,slice};
+        use core::{mem, slice, str};
         unsafe {
             let strlen = self.size as usize - mem::size_of::<BootLoaderNameTag>();
-            str::from_utf8_unchecked(
-                slice::from_raw_parts((&self.string) as *const u8, strlen))
+            str::from_utf8_unchecked(slice::from_raw_parts((&self.string) as *const u8, strlen))
         }
     }
 }

+ 2 - 3
src/command_line.rs

@@ -22,11 +22,10 @@ impl CommandLineTag {
     /// }
     /// ```
     pub fn command_line(&self) -> &str {
-        use core::{mem,str,slice};
+        use core::{mem, slice, str};
         unsafe {
             let strlen = self.size as usize - mem::size_of::<CommandLineTag>();
-            str::from_utf8_unchecked(
-                slice::from_raw_parts((&self.string) as *const u8, strlen))
+            str::from_utf8_unchecked(slice::from_raw_parts((&self.string) as *const u8, strlen))
         }
     }
 }

+ 1 - 1
src/framebuffer.rs

@@ -1,6 +1,6 @@
-use ::Reader;
 use core::slice;
 use header::Tag;
+use Reader;
 
 /// The VBE Framebuffer information Tag.
 #[derive(Debug, PartialEq)]

+ 3 - 4
src/header.rs

@@ -27,8 +27,8 @@ impl<'a> Iterator for TagIter<'a> {
     type Item = &'a Tag;
 
     fn next(&mut self) -> Option<&'a Tag> {
-        match unsafe{&*self.current} {
-            &Tag{typ:0, size:8} => None, // end tag
+        match unsafe { &*self.current } {
+            &Tag { typ: 0, size: 8 } => None, // end tag
             tag => {
                 // go to next tag
                 let mut tag_addr = self.current as usize;
@@ -36,8 +36,7 @@ impl<'a> Iterator for TagIter<'a> {
                 self.current = tag_addr as *const _;
 
                 Some(tag)
-            },
+            }
         }
     }
 }
-

+ 6 - 6
src/module.rs

@@ -1,7 +1,7 @@
 use header::{Tag, TagIter};
 
 /// This tag indicates to the kernel what boot module was loaded along with
-/// the kernel image, and where it can be found. 
+/// the kernel image, and where it can be found.
 #[derive(Clone, Copy, Debug)]
 #[repr(C, packed)] // only repr(C) would add unwanted padding near name_byte.
 pub struct ModuleTag {
@@ -18,11 +18,10 @@ impl ModuleTag {
     // defined behavior
     /// Get the name of the module.
     pub fn name(&self) -> &str {
-        use core::{mem,str,slice};
+        use core::{mem, slice, str};
         let strlen = self.size as usize - mem::size_of::<ModuleTag>();
         unsafe {
-            str::from_utf8_unchecked(
-                slice::from_raw_parts(&self.name_byte as *const u8, strlen))
+            str::from_utf8_unchecked(slice::from_raw_parts(&self.name_byte as *const u8, strlen))
         }
     }
 
@@ -51,7 +50,8 @@ impl<'a> Iterator for ModuleIter<'a> {
     type Item = &'a ModuleTag;
 
     fn next(&mut self) -> Option<&'a ModuleTag> {
-        self.iter.find(|x| x.typ == 3)
-            .map(|tag| unsafe{&*(tag as *const Tag as *const ModuleTag)})
+        self.iter
+            .find(|x| x.typ == 3)
+            .map(|tag| unsafe { &*(tag as *const Tag as *const ModuleTag) })
     }
 }

+ 20 - 22
src/rsdp.rs

@@ -5,7 +5,6 @@
 ///
 /// Even though the bootloader should give the address of the real RSDP/XSDT, the checksum and
 /// signature should be manually verified.
-
 use core::slice;
 use core::str;
 
@@ -29,7 +28,7 @@ impl EFISdt32 {
 
 /// EFI system table in 64 bit mode
 #[derive(Clone, Copy, Debug)]
-#[repr(C)] 
+#[repr(C)]
 pub struct EFISdt64 {
     typ: u32,
     size: u32,
@@ -61,7 +60,7 @@ pub struct EFIImageHandle64 {
     pointer: u64,
 }
 
-/// If the image has relocatable header tag, this tag contains the image's 
+/// If the image has relocatable header tag, this tag contains the image's
 /// base physical address.
 #[derive(Debug)]
 #[repr(C)]
@@ -71,7 +70,7 @@ pub struct ImageLoadPhysAddr {
     load_base_addr: u32,
 }
 
-/// This tag contains a copy of RSDP as defined per ACPI 1.0 specification. 
+/// This tag contains a copy of RSDP as defined per ACPI 1.0 specification.
 #[derive(Clone, Copy, Debug)]
 #[repr(C, packed)]
 pub struct RsdpV1Tag {
@@ -81,7 +80,7 @@ pub struct RsdpV1Tag {
     checksum: u8,
     oem_id: [u8; 6],
     revision: u8,
-    rsdt_address: u32,  // This is the PHYSICAL address of the RSDT
+    rsdt_address: u32, // This is the PHYSICAL address of the RSDT
 }
 
 impl RsdpV1Tag {
@@ -94,16 +93,15 @@ impl RsdpV1Tag {
 
     /// Validation of the RSDPv1 checksum
     pub fn checksum_is_valid(&self) -> bool {
-        let bytes = unsafe {
-            slice::from_raw_parts(
-                self as *const _ as *const u8,
-                RSDPV1_LENGTH + 8
-            )
-        };
-        bytes[8..].iter().fold(0u8, |acc, val| acc.wrapping_add(*val)) == 0
+        let bytes =
+            unsafe { slice::from_raw_parts(self as *const _ as *const u8, RSDPV1_LENGTH + 8) };
+        bytes[8..]
+            .iter()
+            .fold(0u8, |acc, val| acc.wrapping_add(*val))
+            == 0
     }
 
-    /// An OEM-supplied string that identifies the OEM. 
+    /// An OEM-supplied string that identifies the OEM.
     pub fn oem_id<'a>(&'a self) -> Option<&'a str> {
         str::from_utf8(&self.oem_id).ok()
     }
@@ -119,7 +117,7 @@ impl RsdpV1Tag {
     }
 }
 
-/// This tag contains a copy of RSDP as defined per ACPI 2.0 or later specification. 
+/// This tag contains a copy of RSDP as defined per ACPI 2.0 or later specification.
 #[derive(Clone, Copy, Debug)]
 #[repr(C, packed)]
 pub struct RsdpV2Tag {
@@ -131,7 +129,7 @@ pub struct RsdpV2Tag {
     revision: u8,
     _rsdt_address: u32,
     length: u32,
-    xsdt_address: u64,  // This is the PHYSICAL address of the XSDT
+    xsdt_address: u64, // This is the PHYSICAL address of the XSDT
     ext_checksum: u8,
     _reserved: [u8; 3],
 }
@@ -147,15 +145,15 @@ impl RsdpV2Tag {
     /// Validation of the RSDPv2 extended checksum
     pub fn checksum_is_valid(&self) -> bool {
         let bytes = unsafe {
-            slice::from_raw_parts(
-                self as *const _ as *const u8,
-                self.length as usize + 8
-            )
+            slice::from_raw_parts(self as *const _ as *const u8, self.length as usize + 8)
         };
-        bytes[8..].iter().fold(0u8, |acc, val| acc.wrapping_add(*val)) == 0
+        bytes[8..]
+            .iter()
+            .fold(0u8, |acc, val| acc.wrapping_add(*val))
+            == 0
     }
 
-    /// An OEM-supplied string that identifies the OEM. 
+    /// An OEM-supplied string that identifies the OEM.
     pub fn oem_id<'a>(&'a self) -> Option<&'a str> {
         str::from_utf8(&self.oem_id).ok()
     }
@@ -172,7 +170,7 @@ impl RsdpV2Tag {
         self.xsdt_address as usize
     }
 
-    /// This field is used to calculate the checksum of the entire table, including both checksum fields. 
+    /// This field is used to calculate the checksum of the entire table, including both checksum fields.
     pub fn ext_checksum(&self) -> u8 {
         self.ext_checksum
     }

+ 44 - 45
src/vbe_info.rs

@@ -8,7 +8,7 @@ pub struct VBEInfoTag {
     typ: u32,
     length: u32,
 
-    /// Indicates current video mode in the format specified in VBE 3.0. 
+    /// Indicates current video mode in the format specified in VBE 3.0.
     pub mode: u16,
 
     /// Contain the segment of the table of a protected mode interface defined in VBE 2.0+.
@@ -33,7 +33,7 @@ pub struct VBEInfoTag {
     pub control_info: VBEControlInfo,
 
     /// Contains VBE mode information returned by the VBE Function `01h`.
-    pub mode_info: VBEModeInfo
+    pub mode_info: VBEModeInfo,
 }
 
 /// VBE controller information.
@@ -81,29 +81,28 @@ pub struct VBEControlInfo {
     reserved: [u8; 222],
 
     /// Data area for OEM strings.
-    oem_data: [u8; 256]
+    oem_data: [u8; 256],
 }
 
 impl fmt::Debug for VBEControlInfo {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         unsafe {
             f.debug_struct("VBEControlInfo")
-             .field("signature", &self.signature)
-             .field("version", &self.version)
-             .field("oem_string_ptr", &self.oem_string_ptr)
-             .field("capabilities", &self.capabilities)
-             .field("mode_list_ptr", &self.mode_list_ptr)
-             .field("total_memory", &self.total_memory)
-             .field("oem_software_revision", &self.oem_software_revision)
-             .field("oem_vendor_name_ptr", &self.oem_vendor_name_ptr)
-             .field("oem_product_name_ptr", &self.oem_product_name_ptr)
-             .field("oem_product_revision_ptr", &self.oem_product_revision_ptr)
-             .finish()
+                .field("signature", &self.signature)
+                .field("version", &self.version)
+                .field("oem_string_ptr", &self.oem_string_ptr)
+                .field("capabilities", &self.capabilities)
+                .field("mode_list_ptr", &self.mode_list_ptr)
+                .field("total_memory", &self.total_memory)
+                .field("oem_software_revision", &self.oem_software_revision)
+                .field("oem_vendor_name_ptr", &self.oem_vendor_name_ptr)
+                .field("oem_product_name_ptr", &self.oem_product_name_ptr)
+                .field("oem_product_revision_ptr", &self.oem_product_revision_ptr)
+                .finish()
         }
     }
 }
 
-
 /// Extended information about a specific VBE display mode from the
 /// mode list returned by `VBEControlInfo` (VBE Function `00h`).
 #[derive(Copy, Clone)]
@@ -196,39 +195,39 @@ pub struct VBEModeInfo {
     pub offscreen_memory_size: u16,
 
     /// Remainder of mode info block
-    reserved1: [u8; 206]
+    reserved1: [u8; 206],
 }
 
 impl fmt::Debug for VBEModeInfo {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         unsafe {
             f.debug_struct("VBEModeInfo")
-             .field("mode_attributes", &self.mode_attributes)
-             .field("window_a_attributes", &self.window_a_attributes)
-             .field("window_b_attributes", &self.window_b_attributes)
-             .field("window_granularity", &self.window_granularity)
-             .field("window_size", &self.window_size)
-             .field("window_a_segment", &self.window_a_segment)
-             .field("window_b_segment", &self.window_b_segment)
-             .field("window_function_ptr", &self.window_function_ptr)
-             .field("pitch", &self.pitch)
-             .field("resolution", &self.resolution)
-             .field("character_size", &self.character_size)
-             .field("number_of_planes", &self.number_of_planes)
-             .field("bpp", &self.bpp)
-             .field("number_of_banks", &self.number_of_banks)
-             .field("memory_model", &self.memory_model)
-             .field("bank_size", &self.bank_size)
-             .field("number_of_image_pages", &self.number_of_image_pages)
-             .field("red_field", &self.red_field)
-             .field("green_field", &self.green_field)
-             .field("blue_field", &self.blue_field)
-             .field("reserved_field", &self.reserved_field)
-             .field("direct_color_attributes", &self.direct_color_attributes)
-             .field("framebuffer_base_ptr", &self.framebuffer_base_ptr)
-             .field("offscreen_memory_offset", &self.offscreen_memory_offset)
-             .field("offscreen_memory_size", &self.offscreen_memory_size)
-             .finish()
+                .field("mode_attributes", &self.mode_attributes)
+                .field("window_a_attributes", &self.window_a_attributes)
+                .field("window_b_attributes", &self.window_b_attributes)
+                .field("window_granularity", &self.window_granularity)
+                .field("window_size", &self.window_size)
+                .field("window_a_segment", &self.window_a_segment)
+                .field("window_b_segment", &self.window_b_segment)
+                .field("window_function_ptr", &self.window_function_ptr)
+                .field("pitch", &self.pitch)
+                .field("resolution", &self.resolution)
+                .field("character_size", &self.character_size)
+                .field("number_of_planes", &self.number_of_planes)
+                .field("bpp", &self.bpp)
+                .field("number_of_banks", &self.number_of_banks)
+                .field("memory_model", &self.memory_model)
+                .field("bank_size", &self.bank_size)
+                .field("number_of_image_pages", &self.number_of_image_pages)
+                .field("red_field", &self.red_field)
+                .field("green_field", &self.green_field)
+                .field("blue_field", &self.blue_field)
+                .field("reserved_field", &self.reserved_field)
+                .field("direct_color_attributes", &self.direct_color_attributes)
+                .field("framebuffer_base_ptr", &self.framebuffer_base_ptr)
+                .field("offscreen_memory_offset", &self.offscreen_memory_offset)
+                .field("offscreen_memory_size", &self.offscreen_memory_size)
+                .finish()
         }
     }
 }
@@ -244,7 +243,7 @@ pub struct VBEField {
 
     /// define the bit position within the direct color pixel or YUV pixel of
     /// the least significant bit of the respective color component.
-    pub position: u8
+    pub position: u8,
 }
 
 bitflags! {
@@ -283,7 +282,7 @@ bitflags! {
 
         /// VGA Window compatibility.
         ///
-        /// If this is set, the window A and B fields of VBEModeInfo are invalid. 
+        /// If this is set, the window A and B fields of VBEModeInfo are invalid.
         const NO_VGA_WINDOW = 0x40;
 
         /// Linear framebuffer availability.
@@ -340,5 +339,5 @@ pub enum VBEMemoryModel {
     PackedPixel = 0x04,
     Unchained = 0x05,
     DirectColor = 0x06,
-    YUV = 0x07
+    YUV = 0x07,
 }