From 6e293d029bd60f5565bb18629e3baf2d049e53cf Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Wed, 24 Aug 2022 19:29:00 -0700 Subject: *cargo fmt --- src/kernel.rs | 140 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 77 insertions(+), 63 deletions(-) (limited to 'src/kernel.rs') diff --git a/src/kernel.rs b/src/kernel.rs index e92c701..24de020 100644 --- a/src/kernel.rs +++ b/src/kernel.rs @@ -4,10 +4,11 @@ //! - UART //! - Allocators -#![doc(html_logo_url = "https://raw.githubusercontent.com/rust-embedded/wg/master/assets/logo/ewg-logo-blue-white-on-transparent.png")] - +#![doc( + html_logo_url = "https://raw.githubusercontent.com/rust-embedded/wg/master/assets/logo/ewg-logo-blue-white-on-transparent.png" +)] #![allow(non_snake_case)] -#![allow(clippy::upper_case_acronyms,dead_code)] +#![allow(clippy::upper_case_acronyms, dead_code)] #![feature(format_args_nl)] #![feature(panic_info_message)] #![feature(trait_alias)] @@ -19,8 +20,8 @@ extern crate alloc; pub use alloc::boxed::Box; -pub use alloc::string::String; pub use alloc::format; +pub use alloc::string::String; mod console; mod cpu; @@ -41,7 +42,7 @@ use crate::mem::alloc::allocator; /// - Box /// - String /// - format! -/// - UART +/// - UART /// - print! /// - println! /// - vprint! @@ -50,74 +51,87 @@ use crate::mem::alloc::allocator; /// After initialization, jump to /// the regular main. unsafe fn kernel_init() -> ! { - console().init().unwrap(); - allocator().init().unwrap(); - kernel_main() + console().init().unwrap(); + allocator().init().unwrap(); + kernel_main() } /// # Post-initialization /// /// TODO: Figure out what to do here fn kernel_main() -> ! { - #[cfg(not(feature="verbose"))] - { - #[cfg(feature="flag")] - { - draw::draw_ukraine_flag(); - println!(); - draw::draw_american_flag(); - println!(); - } + #[cfg(not(feature = "verbose"))] + { + #[cfg(feature = "flag")] + { + draw::draw_ukraine_flag(); + println!(); + draw::draw_american_flag(); + println!(); + } - println!("\x1b[91mInitialized\x1b[0m \x1b[92m{}\x1b[0m \x1b[93mv{}\x1b[0m", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")); - println!("\x1b[94mAuthors:\x1b[0m \x1b[95m{}\x1b[0m", env!("CARGO_PKG_AUTHORS")); - use crate::console::interface::Statistics; - println!("Characters written to UART: \x1b[91m{}\x1b[0m", console().chars_written()); - } + println!( + "\x1b[91mInitialized\x1b[0m \x1b[92m{}\x1b[0m \x1b[93mv{}\x1b[0m", + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_VERSION") + ); + println!( + "\x1b[94mAuthors:\x1b[0m \x1b[95m{}\x1b[0m", + env!("CARGO_PKG_AUTHORS") + ); + use crate::console::interface::Statistics; + println!( + "Characters written to UART: \x1b[91m{}\x1b[0m", + console().chars_written() + ); + } - #[cfg(feature="verbose")] - run_verbose(); + #[cfg(feature = "verbose")] + run_verbose(); - loop { } + loop {} } fn run_verbose() { - println!("U8: {:?}", mem::alloc::U8_GRAND_ALLOC); - { - let mut s = String::new(); - for _ in 0..128 { - s += "TEST"; - } - assert_eq!(s.capacity(), 512); - } - { - let s = format!("{:X}", 0xCAFEBABE as u32); - assert_eq!(s, "CAFEBABE"); - assert_eq!(s.capacity(), 8); - } - { - let a: Box = Box::new(1); - assert_eq!(*a, 1); - println!("{}", a); - } - { - let a: Box = Box::new(2); - let b: Box = Box::new(3); - let c: Box = Box::new(4); - assert_eq!(*a, 2); - assert_eq!(*b, 3); - assert_eq!(*c, 4); - println!("{} {} {}", a, b, c); - } - { - let a: Box = Box::new(5); - let b: Box = Box::new(6); - let c: Box = Box::new(7); - assert_eq!(*a, 5); - assert_eq!(*b, 6); - assert_eq!(*c, 7); - println!("{} {} {}", a, b, c); - } - use crate::console::interface::Statistics; - println!("Characters written to UART: \x1b[91m{}\x1b[0m", console().chars_written()); + println!("U8: {:?}", mem::alloc::U8_GRAND_ALLOC); + { + let mut s = String::new(); + for _ in 0..128 { + s += "TEST"; + } + assert_eq!(s.capacity(), 512); + } + { + let s = format!("{:X}", 0xCAFEBABE as u32); + assert_eq!(s, "CAFEBABE"); + assert_eq!(s.capacity(), 8); + } + { + let a: Box = Box::new(1); + assert_eq!(*a, 1); + println!("{}", a); + } + { + let a: Box = Box::new(2); + let b: Box = Box::new(3); + let c: Box = Box::new(4); + assert_eq!(*a, 2); + assert_eq!(*b, 3); + assert_eq!(*c, 4); + println!("{} {} {}", a, b, c); + } + { + let a: Box = Box::new(5); + let b: Box = Box::new(6); + let c: Box = Box::new(7); + assert_eq!(*a, 5); + assert_eq!(*b, 6); + assert_eq!(*c, 7); + println!("{} {} {}", a, b, c); + } + use crate::console::interface::Statistics; + println!( + "Characters written to UART: \x1b[91m{}\x1b[0m", + console().chars_written() + ); } -- cgit v1.2.1