//! The command `devices`: the hardware the kernel found and which driver //! took each, as a table for the terminal. #![no_std] #![no_main] extern crate alloc; use alloc::string::String; use alloc::vec::Vec; use pinnacle_rt::output::Output; #[unsafe(no_mangle)] fn main(argument: u64) -> u64 { let out = Output::start(argument); let devices = pinnacle_rt::devices(); let none = || String::from("–"); let rows: Vec> = devices .iter() .map(|d| { alloc::vec![ d.class.clone().unwrap_or_else(none), d.driver.clone().unwrap_or_else(none), d.name.clone(), ] }) .collect(); out.table(&["Class", "Driver", "Device"], rows); let claimed = devices.iter().filter(|d| d.driver.is_some()).count(); let summary = alloc::format!("{} devices, {claimed} with a driver", devices.len()); out.status(0, &summary) }