diff --git a/apps/system/components/DebugConsole/kata-allocator/Cargo.toml b/apps/system/components/DebugConsole/kata-allocator/Cargo.toml index 8860113..43c3790 100644 --- a/apps/system/components/DebugConsole/kata-allocator/Cargo.toml +++ b/apps/system/components/DebugConsole/kata-allocator/Cargo.toml @@ -6,5 +6,4 @@ edition = "2018" [dependencies] linked_list_allocator = { version = "0.9", default-features = false, features = ["const_mut_refs"] } -log = "0.4" spin = "0.9" diff --git a/apps/system/components/DebugConsole/kata-allocator/src/lib.rs b/apps/system/components/DebugConsole/kata-allocator/src/lib.rs index 9642a2a..9ffa2c5 100644 --- a/apps/system/components/DebugConsole/kata-allocator/src/lib.rs +++ b/apps/system/components/DebugConsole/kata-allocator/src/lib.rs @@ -6,7 +6,6 @@ use core::alloc::{GlobalAlloc, Layout}; use core::panic; use core::ptr::{self, NonNull}; -use log::info; use linked_list_allocator::Heap; use spin::Mutex; @@ -53,10 +52,9 @@ impl KataHeap { /// /// Obey these or Bad Stuff will happen. /// - /// - This function must be called exactly ONCE. + /// - This function must be called exactly ONCE (per thread). /// - `size > 0` pub unsafe fn init(&self, start_addr: usize, size: usize) { - info!("init: start_addr {:#x} size {}", start_addr, size); (*self.heap.lock()).init(start_addr, size); } diff --git a/apps/system/components/DebugConsole/kata-debug-console/src/run.rs b/apps/system/components/DebugConsole/kata-debug-console/src/run.rs index 8e3dfc5..7abfda5 100644 --- a/apps/system/components/DebugConsole/kata-debug-console/src/run.rs +++ b/apps/system/components/DebugConsole/kata-debug-console/src/run.rs @@ -17,30 +17,31 @@ use kata_allocator; use kata_logger::KataLogger; use kata_shell; use kata_uart_client; -use log::debug; - -static KATA_LOGGER: KataLogger = KataLogger; +use log::trace; #[no_mangle] pub extern "C" fn pre_init() { + static KATA_LOGGER: KataLogger = KataLogger; log::set_logger(&KATA_LOGGER).unwrap(); + // NB: set to Trace for early-boot msgs log::set_max_level(log::LevelFilter::Debug); -} -#[no_mangle] -// NB: use post_init insted of pre_init so syslog interface is setup -pub extern "C" fn post_init() { // TODO(sleffler): temp until we integrate with seL4 static mut HEAP_MEMORY: [u8; 16 * 1024] = [0; 16 * 1024]; unsafe { kata_allocator::ALLOCATOR.init(HEAP_MEMORY.as_mut_ptr() as usize, HEAP_MEMORY.len()); + trace!( + "setup heap: start_addr {:p} size {}", + HEAP_MEMORY.as_ptr(), + HEAP_MEMORY.len() + ); } } /// Entry point for DebugConsole. Runs the shell with UART IO. #[no_mangle] pub extern "C" fn run() -> ! { - debug!("run"); + trace!("run"); let mut tx = kata_uart_client::Tx {}; let mut rx = kata_uart_client::Rx {}; kata_shell::repl(&mut tx, &mut rx); diff --git a/apps/system/components/DebugConsole/kata-logger/src/lib.rs b/apps/system/components/DebugConsole/kata-logger/src/lib.rs index 9004f2c..3939819 100644 --- a/apps/system/components/DebugConsole/kata-logger/src/lib.rs +++ b/apps/system/components/DebugConsole/kata-logger/src/lib.rs @@ -23,8 +23,7 @@ impl log::Log for KataLogger { let mut buf = [0 as u8; MAX_MSG_LEN]; let mut cur = Cursor::new(&mut buf[..]); // Log msgs are of the form: ':: - write!(&mut cur, "{}::{}\0", record.target(), record.args()) - .unwrap_or_else(|_| { + write!(&mut cur, "{}::{}\0", record.target(), record.args()).unwrap_or_else(|_| { // Too big, indicate overflow with a trailing "...". cur.set_position((MAX_MSG_LEN - 4) as u64); cur.write(b"...\0").expect("write!"); @@ -38,8 +37,7 @@ impl log::Log for KataLogger { record: &Record, ) -> &'a cstr_core::CStr { let mut cur = Cursor::new(&mut buf[..]); - write!(&mut cur, "{}::\0", record.target()) - .expect("nul!"); + write!(&mut cur, "{}::\0", record.target()).expect("nul!"); let pos = cur.position() as usize; CStr::from_bytes_with_nul(&buf[..pos]).unwrap() } diff --git a/apps/system/components/DebugConsole/kata-shell/src/lib.rs b/apps/system/components/DebugConsole/kata-shell/src/lib.rs index 898930e..4408678 100644 --- a/apps/system/components/DebugConsole/kata-shell/src/lib.rs +++ b/apps/system/components/DebugConsole/kata-shell/src/lib.rs @@ -3,7 +3,6 @@ use core::fmt; use core::fmt::Write; use cstr_core::CString; -use log::info; use kata_io as io; use kata_line_reader::LineReader; @@ -46,10 +45,9 @@ impl From for CommandError { /// Read-eval-print loop for the DebugConsole command line interface. pub fn repl(output: &mut dyn io::Write, input: &mut dyn io::Read) -> ! { - info!("DebugConsole::repl()"); let mut line_reader = LineReader::new(); loop { - const PROMPT: &str = "KATA_PROMPT> "; + const PROMPT: &str = "KATA> "; let _ = output.write_str(PROMPT); match line_reader.read_line(output, input) { Ok(cmdline) => dispatch_command(cmdline, output), diff --git a/apps/system/components/DebugConsole/kata-uart-client/src/lib.rs b/apps/system/components/DebugConsole/kata-uart-client/src/lib.rs index 0f25d25..03136f0 100644 --- a/apps/system/components/DebugConsole/kata-uart-client/src/lib.rs +++ b/apps/system/components/DebugConsole/kata-uart-client/src/lib.rs @@ -21,14 +21,12 @@ extern "C" { #[no_mangle] pub extern "C" fn logger_log(level: u8, msg: *const cstr_core::c_char) { use log::Level; - // TODO(sleffler): seems like this should be try_from? let l = match level { x if x == Level::Error as u8 => Level::Error, x if x == Level::Warn as u8 => Level::Warn, x if x == Level::Info as u8 => Level::Info, x if x == Level::Debug as u8 => Level::Debug, - x if x == Level::Trace as u8 => Level::Trace, - _ => { return }, // TODO(sleffler): accept or not? + _ => Level::Trace, }; if l <= log::max_level() { // TODO(sleffler): is the uart driver ok w/ multiple writers? diff --git a/apps/system/components/MlCoordinator/MlCoordinator.camkes b/apps/system/components/MlCoordinator/MlCoordinator.camkes index 863f773..18e0dcf 100644 --- a/apps/system/components/MlCoordinator/MlCoordinator.camkes +++ b/apps/system/components/MlCoordinator/MlCoordinator.camkes @@ -2,7 +2,6 @@ import ; import ; component MlCoordinator { - control; provides MlCoordinatorInterface mlcoord; uses LoggerInterface logger; diff --git a/apps/system/components/MlCoordinator/kata-ml-coordinator/src/run.rs b/apps/system/components/MlCoordinator/kata-ml-coordinator/src/run.rs index 1972e47..57fd0ef 100644 --- a/apps/system/components/MlCoordinator/kata-ml-coordinator/src/run.rs +++ b/apps/system/components/MlCoordinator/kata-ml-coordinator/src/run.rs @@ -5,24 +5,24 @@ extern crate kata_panic; use kata_logger::KataLogger; -use log::debug; - -static KATA_LOGGER: KataLogger = KataLogger; +use log::trace; #[no_mangle] pub extern "C" fn pre_init() { + static KATA_LOGGER: KataLogger = KataLogger; log::set_logger(&KATA_LOGGER).unwrap(); - log::set_max_level(log::LevelFilter::Debug); + log::set_max_level(log::LevelFilter::Trace); } #[no_mangle] -pub extern "C" fn run() { - debug!("run"); +pub extern "C" fn mlcoord__init() { + // TODO(sleffler): maybe not needed? + trace!("init"); } // TODO: Move out of this file into separate (auto-generated?) file. // TODO: Consider the modular_bitfield crate to represent bitfields. -fn vctop_ctrl(freeze: u32, vc_reset: u32, pc_start: u32) -> u32 { +fn vctop_ctrl(freeze: u32, vc_reset: u32, pc_start: u32) -> u32 { (pc_start << 2) + ((vc_reset & 1) << 1) + (freeze & 1) } @@ -38,4 +38,4 @@ pub extern "C" fn mlcoord_execute() { // Unhalt, start at default PC. vctop_set_ctrl(vctop_ctrl(0, 0, 0)); } -} \ No newline at end of file +} diff --git a/apps/system/components/ProcessManager/ProcessManager.camkes b/apps/system/components/ProcessManager/ProcessManager.camkes index 8262a1c..74cd831 100644 --- a/apps/system/components/ProcessManager/ProcessManager.camkes +++ b/apps/system/components/ProcessManager/ProcessManager.camkes @@ -1,14 +1,13 @@ // Kata OS ProcessManager services. import ; -import ; import ; +import ; import ; component ProcessManager { - control; - provides ProcessControlInterface proc_ctrl; provides PackageManagementInterface pkg_mgmt; + provides ProcessControlInterface proc_ctrl; uses LoggerInterface logger; uses SeL4DebugInterface sel4debug; diff --git a/apps/system/components/ProcessManager/kata-proc-common/src/lib.rs b/apps/system/components/ProcessManager/kata-proc-common/src/lib.rs index 8493aad..269e1e7 100644 --- a/apps/system/components/ProcessManager/kata-proc-common/src/lib.rs +++ b/apps/system/components/ProcessManager/kata-proc-common/src/lib.rs @@ -126,7 +126,8 @@ impl RawBundleIdData { // TODO(sleffler): handle truncation better pub fn pack_bundles(&mut self, bundles: &BundleIdArray) -> bare_io::Result<()> { let mut result = Cursor::new(&mut self.data[..]); - let bundle_count = [u8::try_from(bundles.len()).map_err(|_| bare_io::ErrorKind::InvalidData)?]; + let bundle_count = + [u8::try_from(bundles.len()).map_err(|_| bare_io::ErrorKind::InvalidData)?]; result.write(&bundle_count[..])?; // # bundles for bid in bundles.ids.as_slice().iter() { let bid_len = [u8::try_from(bid.len()).map_err(|_| bare_io::ErrorKind::InvalidData)?]; diff --git a/apps/system/components/ProcessManager/kata-proc-component/src/run.rs b/apps/system/components/ProcessManager/kata-proc-component/src/run.rs index 8277a4b..b2782d9 100644 --- a/apps/system/components/ProcessManager/kata-proc-component/src/run.rs +++ b/apps/system/components/ProcessManager/kata-proc-component/src/run.rs @@ -9,7 +9,7 @@ use kata_allocator; use kata_logger::KataLogger; use kata_proc_common::*; use kata_proc_manager::KATA_PROC; -use log::{info, trace}; +use log::trace; #[no_mangle] pub extern "C" fn pre_init() { @@ -22,25 +22,29 @@ pub extern "C" fn pre_init() { static mut HEAP_MEMORY: [u8; 16 * 1024] = [0; 16 * 1024]; unsafe { kata_allocator::ALLOCATOR.init(HEAP_MEMORY.as_mut_ptr() as usize, HEAP_MEMORY.len()); + trace!( + "setup heap: start_addr {:p} size {}", + HEAP_MEMORY.as_ptr(), + HEAP_MEMORY.len() + ); } // Complete KATA_PROC setup. This is as early as we can do it given that // it needs the GlobalAllocator. unsafe { KATA_PROC.init(); - info!( + trace!( "ProcessManager has capacity for {} bundles", KATA_PROC.capacity() ); } } -// TODO(sleffler): move to init or similar if a thread isn't needed #[no_mangle] -pub extern "C" fn run() { +pub extern "C" fn pkg_mgmt__init() { // Setup the userland address spaces, lifecycles, and system introspection // for third-party applications. - trace!("run"); + trace!("init"); } // PackageManagerInterface glue stubs.