From 422a11b0a90989a1d667ef6d7a57decba0fe0f82 Mon Sep 17 00:00:00 2001 From: "Cliff L. Biffle" Date: Wed, 17 Apr 2024 12:19:50 -0700 Subject: [PATCH] Begin removing/disabling wildcard imports. This starts with the "core" code in sys, test, and jefe, and works out from there. Any package can opt into this at any time by adding this to its Cargo.toml: [lints] workspace = true This will also cause it to pick up any future lints we decide on. --- Cargo.toml | 3 + lib/multitimer/Cargo.toml | 3 + lib/multitimer/src/lib.rs | 9 +- sys/abi/Cargo.toml | 3 + sys/kern/Cargo.toml | 3 + sys/kern/src/startup.rs | 2 +- sys/kerncore/Cargo.toml | 3 + sys/num-tasks/Cargo.toml | 3 + sys/userlib/Cargo.toml | 3 + task/jefe/Cargo.toml | 3 + task/jefe/src/dump.rs | 13 ++- task/jefe/src/external.rs | 4 +- task/jefe/src/main.rs | 12 +-- test/test-api/Cargo.toml | 3 + test/test-api/src/lib.rs | 2 +- test/test-assist/Cargo.toml | 3 + test/test-assist/src/main.rs | 6 +- test/test-idol-api/Cargo.toml | 3 + test/test-idol-api/src/lib.rs | 2 +- test/test-idol-server/Cargo.toml | 3 + test/test-idol-server/src/main.rs | 5 +- test/test-runner/Cargo.toml | 3 + test/test-runner/src/main.rs | 6 +- test/test-suite/Cargo.toml | 3 + test/test-suite/src/main.rs | 172 +++++++++++++++++------------- 25 files changed, 176 insertions(+), 99 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index eba43860f..54c6f558b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,3 +135,6 @@ tlvc = { git = "https://github.com/oxidecomputer/tlvc", default-features = false tlvc-text = { git = "https://github.com/oxidecomputer/tlvc", default-features = false, version = "0.3.0" } transceiver-messages = { git = "https://github.com/oxidecomputer/transceiver-control/", default-features = false} vsc7448-pac = { git = "https://github.com/oxidecomputer/vsc7448", default-features = false } + +[workspace.lints.clippy] +wildcard_imports = "deny" diff --git a/lib/multitimer/Cargo.toml b/lib/multitimer/Cargo.toml index 24feb43a7..1aa91a4ab 100644 --- a/lib/multitimer/Cargo.toml +++ b/lib/multitimer/Cargo.toml @@ -8,3 +8,6 @@ enum-map = { workspace = true } [target.'cfg(target_os = "none")'.dependencies] userlib = {path = "../../sys/userlib"} + +[lints] +workspace = true diff --git a/lib/multitimer/src/lib.rs b/lib/multitimer/src/lib.rs index 7c7066d25..62665b0c8 100644 --- a/lib/multitimer/src/lib.rs +++ b/lib/multitimer/src/lib.rs @@ -213,8 +213,8 @@ mod fakes { use core::cell::Cell; thread_local! { - pub static CURRENT_TIME: Cell = Cell::new(0); - pub static TIMER_SETTING: Cell<(Option, u32)> = Cell::default(); + pub static CURRENT_TIME: Cell = const { Cell::new(0) }; + pub static TIMER_SETTING: Cell<(Option, u32)> = const { Cell::new((None, 0)) }; } pub fn sys_set_timer(deadline: Option, not: u32) { @@ -239,11 +239,12 @@ mod fakes { } } #[cfg(not(target_os = "none"))] -use self::fakes::*; +use self::fakes::{sys_get_timer, sys_set_timer}; #[cfg(test)] mod tests { - use super::*; + use super::fakes::CURRENT_TIME; + use super::{sys_get_timer, EnumMap, Multitimer, Repeat, Timer}; fn change_time(time: u64) { CURRENT_TIME.with(|t| t.set(time)); diff --git a/sys/abi/Cargo.toml b/sys/abi/Cargo.toml index c4faa677f..a53e0e5bf 100644 --- a/sys/abi/Cargo.toml +++ b/sys/abi/Cargo.toml @@ -9,3 +9,6 @@ bitflags = { workspace = true } byteorder = { workspace = true } serde = { workspace = true } phash = { path = "../../lib/phash" } + +[lints] +workspace = true diff --git a/sys/kern/Cargo.toml b/sys/kern/Cargo.toml index ee8558a77..0e50c8754 100644 --- a/sys/kern/Cargo.toml +++ b/sys/kern/Cargo.toml @@ -41,3 +41,6 @@ nano = [] test = false doctest = false bench = false + +[lints] +workspace = true diff --git a/sys/kern/src/startup.rs b/sys/kern/src/startup.rs index 1c6094805..b4a9a01e8 100644 --- a/sys/kern/src/startup.rs +++ b/sys/kern/src/startup.rs @@ -5,7 +5,7 @@ //! Kernel startup. use crate::atomic::AtomicExt; -use crate::descs::*; +use crate::descs::{RegionAttributes, RegionDesc, TaskDesc, TaskFlags}; use crate::task::Task; use core::mem::MaybeUninit; use core::sync::atomic::{AtomicBool, Ordering}; diff --git a/sys/kerncore/Cargo.toml b/sys/kerncore/Cargo.toml index ff34de899..ae0ad5c21 100644 --- a/sys/kerncore/Cargo.toml +++ b/sys/kerncore/Cargo.toml @@ -6,3 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] + +[lints] +workspace = true diff --git a/sys/num-tasks/Cargo.toml b/sys/num-tasks/Cargo.toml index 0e382f09b..666cadf11 100644 --- a/sys/num-tasks/Cargo.toml +++ b/sys/num-tasks/Cargo.toml @@ -13,3 +13,6 @@ task-enum = [] test = false doctest = false bench = false + +[lints] +workspace = true diff --git a/sys/userlib/Cargo.toml b/sys/userlib/Cargo.toml index fa9a9f9ae..80f0a0803 100644 --- a/sys/userlib/Cargo.toml +++ b/sys/userlib/Cargo.toml @@ -51,3 +51,6 @@ build-util = { path = "../../build/util" } test = false doctest = false bench = false + +[lints] +workspace = true diff --git a/task/jefe/Cargo.toml b/task/jefe/Cargo.toml index 58adf36ae..820b47b59 100644 --- a/task/jefe/Cargo.toml +++ b/task/jefe/Cargo.toml @@ -39,3 +39,6 @@ name = "task-jefe" test = false doctest = false bench = false + +[lints] +workspace = true diff --git a/task/jefe/src/dump.rs b/task/jefe/src/dump.rs index 7ea79c03d..ec4548607 100644 --- a/task/jefe/src/dump.rs +++ b/task/jefe/src/dump.rs @@ -6,9 +6,9 @@ use crate::generated::{DUMP_ADDRESS_MAX, DUMP_ADDRESS_MIN, DUMP_AREAS}; use humpty::{DumpArea, DumpContents}; -use ringbuf::*; +use ringbuf::{ringbuf, ringbuf_entry}; use task_jefe_api::DumpAgentError; -use userlib::*; +use userlib::{kipc, TaskDumpRegion, UnwrapLite}; #[cfg(all( armv8m, @@ -182,14 +182,17 @@ fn dump_task_setup( /// Once a task dump is set up, this function executes it fn dump_task_run(base: u32, task: usize) -> Result<(), DumpAgentError> { ringbuf_entry!(Trace::DumpStart { base }); - let start = sys_get_timer().now; + let start = userlib::sys_get_timer().now; // // The humpty dance is your chance... to do the dump! // let r = humpty::dump::<(), 512, { humpty::DUMPER_JEFE }>( base, - Some(humpty::DumpTask::new(task as u16, sys_get_timer().now)), + Some(humpty::DumpTask::new( + task as u16, + userlib::sys_get_timer().now, + )), || Ok(None), |addr, buf, meta| { ringbuf_entry!(Trace::DumpReading { @@ -232,7 +235,7 @@ fn dump_task_run(base: u32, task: usize) -> Result<(), DumpAgentError> { ringbuf_entry!(Trace::DumpDone(r)); ringbuf_entry!(Trace::DumpTime { start, - end: sys_get_timer().now + end: userlib::sys_get_timer().now }); r.map_err(|_| DumpAgentError::DumpFailed)?; diff --git a/task/jefe/src/external.rs b/task/jefe/src/external.rs index a17b60a23..2058aa550 100644 --- a/task/jefe/src/external.rs +++ b/task/jefe/src/external.rs @@ -50,8 +50,8 @@ use core::sync::atomic::{AtomicU32, Ordering}; #[allow(unused_imports)] use armv6m_atomic_hack::AtomicU32Ext; -use ringbuf::*; -use userlib::*; +use ringbuf::{ringbuf, ringbuf_entry}; +use userlib::{kipc, FromPrimitive}; /// The actual requests that we honor from an external source entity #[derive(FromPrimitive, Copy, Clone, Debug, Eq, PartialEq)] diff --git a/task/jefe/src/main.rs b/task/jefe/src/main.rs index 4817099e8..252b27853 100644 --- a/task/jefe/src/main.rs +++ b/task/jefe/src/main.rs @@ -37,7 +37,7 @@ use hubris_num_tasks::NUM_TASKS; use humpty::DumpArea; use idol_runtime::RequestError; use task_jefe_api::{DumpAgentError, ResetReason}; -use userlib::*; +use userlib::{kipc, Generation, TaskId}; #[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] pub enum Disposition { @@ -61,7 +61,7 @@ fn main() -> ! { } let deadline = - set_timer_relative(TIMER_INTERVAL, notifications::TIMER_MASK); + userlib::set_timer_relative(TIMER_INTERVAL, notifications::TIMER_MASK); external::set_ready(); @@ -133,8 +133,8 @@ impl idl::InOrderJefeImpl for ServerImpl<'_> { for (task, mask) in generated::MAILING_LIST { let taskid = TaskId::for_index_and_gen(task as usize, Generation::ZERO); - let taskid = sys_refresh_task_id(taskid); - sys_post(taskid, mask); + let taskid = userlib::sys_refresh_task_id(taskid); + userlib::sys_post(taskid, mask); } } Ok(()) @@ -293,8 +293,8 @@ impl idol_runtime::NotificationHandler for ServerImpl<'_> { if bits & notifications::TIMER_MASK != 0 { // If our timer went off, we need to reestablish it - if sys_get_timer().now >= self.deadline { - self.deadline = set_timer_relative( + if userlib::sys_get_timer().now >= self.deadline { + self.deadline = userlib::set_timer_relative( TIMER_INTERVAL, notifications::TIMER_MASK, ); diff --git a/test/test-api/Cargo.toml b/test/test-api/Cargo.toml index f54df9cbb..6e1a39b3a 100644 --- a/test/test-api/Cargo.toml +++ b/test/test-api/Cargo.toml @@ -17,3 +17,6 @@ build-util = { path = "../../build/util" } test = false doctest = false bench = false + +[lints] +workspace = true diff --git a/test/test-api/src/lib.rs b/test/test-api/src/lib.rs index aae9d9ae9..5ed45bc6a 100644 --- a/test/test-api/src/lib.rs +++ b/test/test-api/src/lib.rs @@ -4,7 +4,7 @@ #![no_std] -use userlib::*; +use userlib::FromPrimitive; /// Operations that are performed by the test-assist #[derive(FromPrimitive, Debug, Eq, PartialEq)] diff --git a/test/test-assist/Cargo.toml b/test/test-assist/Cargo.toml index d0c109965..33805cff2 100644 --- a/test/test-assist/Cargo.toml +++ b/test/test-assist/Cargo.toml @@ -22,3 +22,6 @@ name = "test-assist" test = false doctest = false bench = false + +[lints] +workspace = true diff --git a/test/test-assist/src/main.rs b/test/test-assist/src/main.rs index ed6a308a4..a95480aa7 100644 --- a/test/test-assist/src/main.rs +++ b/test/test-assist/src/main.rs @@ -9,8 +9,10 @@ use core::arch::asm; use hubris_num_tasks::NUM_TASKS; -use test_api::*; -use userlib::*; +use test_api::AssistOp; +use userlib::{ + hl, kipc, sys_refresh_task_id, sys_send, Generation, Lease, TaskId, +}; use zerocopy::AsBytes; #[inline(never)] diff --git a/test/test-idol-api/Cargo.toml b/test/test-idol-api/Cargo.toml index 48d17ce99..770099b72 100644 --- a/test/test-idol-api/Cargo.toml +++ b/test/test-idol-api/Cargo.toml @@ -22,3 +22,6 @@ bench = false [build-dependencies] idol = { workspace = true } + +[lints] +workspace = true diff --git a/test/test-idol-api/src/lib.rs b/test/test-idol-api/src/lib.rs index e28864d7a..536c48308 100644 --- a/test/test-idol-api/src/lib.rs +++ b/test/test-idol-api/src/lib.rs @@ -8,7 +8,7 @@ use derive_idol_err::IdolError; use serde::{Deserialize, Serialize}; -use userlib::*; +use userlib::{sys_send, FromPrimitive}; #[derive( Copy, Clone, Debug, Eq, PartialEq, FromPrimitive, IdolError, counters::Count, diff --git a/test/test-idol-server/Cargo.toml b/test/test-idol-server/Cargo.toml index f9f27e82a..b5843a7bb 100644 --- a/test/test-idol-server/Cargo.toml +++ b/test/test-idol-server/Cargo.toml @@ -24,3 +24,6 @@ name = "test-idol-server" test = false doctest = false bench = false + +[lints] +workspace = true diff --git a/test/test-idol-server/src/main.rs b/test/test-idol-server/src/main.rs index 5ccf6e23f..0d58d7fc9 100644 --- a/test/test-idol-server/src/main.rs +++ b/test/test-idol-server/src/main.rs @@ -7,7 +7,7 @@ use idol_runtime::{NotificationHandler, RequestError}; use test_idol_api::{FancyTestType, IdolTestError, SocketName, UdpMetadata}; -use userlib::*; +use userlib::RecvMessage; struct ServerImpl; @@ -103,7 +103,8 @@ fn main() -> ! { } mod idl { - use super::*; + use super::FancyTestType; + use test_idol_api::{IdolTestError, SocketName, UdpMetadata}; include!(concat!(env!("OUT_DIR"), "/server_stub.rs")); } diff --git a/test/test-runner/Cargo.toml b/test/test-runner/Cargo.toml index 6078888b9..7b0998a43 100644 --- a/test/test-runner/Cargo.toml +++ b/test/test-runner/Cargo.toml @@ -25,3 +25,6 @@ name = "test-runner" test = false doctest = false bench = false + +[lints] +workspace = true diff --git a/test/test-runner/src/main.rs b/test/test-runner/src/main.rs index 4d93b3d3a..7bf782622 100644 --- a/test/test-runner/src/main.rs +++ b/test/test-runner/src/main.rs @@ -48,9 +48,9 @@ #![no_std] #![no_main] -use ringbuf::*; -use test_api::*; -use userlib::*; +use ringbuf::{ringbuf, ringbuf_entry}; +use test_api::{RunnerOp, TestResult}; +use userlib::{hl, kipc, TaskId, TaskState}; /// We are sensitive to all notifications, to catch unexpected ones in test. const ALL_NOTIFICATIONS: u32 = !0; diff --git a/test/test-suite/Cargo.toml b/test/test-suite/Cargo.toml index e896055be..946cf0d00 100644 --- a/test/test-suite/Cargo.toml +++ b/test/test-suite/Cargo.toml @@ -32,3 +32,6 @@ name = "test-suite" test = false doctest = false bench = false + +[lints] +workspace = true diff --git a/test/test-suite/src/main.rs b/test/test-suite/src/main.rs index 4510f02bb..2683a5f48 100644 --- a/test/test-suite/src/main.rs +++ b/test/test-suite/src/main.rs @@ -23,9 +23,13 @@ #![no_main] use hubris_num_tasks::NUM_TASKS; -use ringbuf::*; -use test_api::*; -use userlib::*; +use ringbuf::{ringbuf, ringbuf_entry}; +use test_api::{AssistOp, RunnerOp, SuiteOp}; +use userlib::{ + hl, kipc, task_slot, FaultInfo, FaultSource, Generation, IrqStatus, + LeaseAttributes, ReplyFaultReason, SchedState, TaskId, TaskState, + UsageError, +}; use zerocopy::AsBytes; #[derive(Copy, Clone, PartialEq)] @@ -137,7 +141,7 @@ fn test_send() { let assist = assist_task_id(); let challenge = 0xDEADBEEF_u32; let mut response = 0_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::JustReply as u16, &challenge.to_le_bytes(), @@ -156,7 +160,7 @@ fn test_recv_reply() { // Ask the assistant to send us a message containing this challenge value. let challenge = 0xCAFE_F00Du32; let mut response = 0_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::SendBack as u16, &challenge.to_le_bytes(), @@ -168,7 +172,7 @@ fn test_recv_reply() { // Don't actually care about the response in this case // Switch roles and wait for the message, blocking notifications. - let rm = sys_recv_open(response.as_bytes_mut(), 0); + let rm = userlib::sys_recv_open(response.as_bytes_mut(), 0); assert_eq!(rm.sender, assist); assert_eq!(rm.operation, 42); // assistant always sends this @@ -182,10 +186,10 @@ fn test_recv_reply() { // Send a recognizeable value in our reply; the assistant will record it. let reply_token = 0x1DE_u32; - sys_reply(assist, 0, &reply_token.to_le_bytes()); + userlib::sys_reply(assist, 0, &reply_token.to_le_bytes()); // Call back to the assistant and request a copy of our most recent reply. - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::LastReply as u16, &challenge.to_le_bytes(), @@ -204,7 +208,7 @@ fn test_recv_reply_fault() { // Ask the assistant to send us a message containing this challenge value. let challenge = 0xCAFE_F00Du32; let mut response = 0_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::SendBack as u16, &challenge.to_le_bytes(), @@ -215,16 +219,16 @@ fn test_recv_reply_fault() { assert_eq!(len, 4); // Now take the message. This is necessary to be able to fault the task. - let _rm = sys_recv_open(response.as_bytes_mut(), 0); + let _rm = userlib::sys_recv_open(response.as_bytes_mut(), 0); // We don't validate the message itself because the test_recv_reply above // covers that. We're specifically interested in what happens if we... - sys_reply_fault(assist, ReplyFaultReason::AccessViolation); + userlib::sys_reply_fault(assist, ReplyFaultReason::AccessViolation); // Ask the kernel to report the assistant's state. let status = kipc::read_task_status(ASSIST.get_task_index().into()); let this_task = TaskId::for_index_and_gen(1, Generation::default()); - let this_task = sys_refresh_task_id(this_task); + let this_task = userlib::sys_refresh_task_id(this_task); match status { TaskState::Faulted { fault, .. } => { @@ -249,7 +253,7 @@ fn test_fault(op: AssistOp, arg: u32) -> FaultInfo { let assist = assist_task_id(); let mut response = 0_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, op as u16, &arg.to_le_bytes(), @@ -281,7 +285,10 @@ cfg_if::cfg_if! { if #[cfg(armv6m)] { macro_rules! assert_fault_eq { ($name:expr, $expected:expr) => { - assert_eq!($name, FaultInfo::InvalidOperation(0)); + assert_eq!($name, { + let _expected = $expected; + FaultInfo::InvalidOperation(0) + }); }; } } else { @@ -454,7 +461,7 @@ fn test_panic() { // Ask the assistant to panic. let mut response = 0_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::Panic as u16, &0u32.to_le_bytes(), @@ -554,7 +561,7 @@ fn test_idol_ssmarshal() { } fn test_idol_ssmarshal_multiarg() { - use test_idol_api::*; + use test_idol_api::{Address, Ipv6Address, UdpMetadata}; let idol = idol_handle(); let r = idol .extract_vid( @@ -574,7 +581,7 @@ fn test_idol_ssmarshal_multiarg() { } fn test_idol_ssmarshal_multiarg_enum() { - use test_idol_api::*; + use test_idol_api::{Address, Ipv6Address, SocketName, UdpMetadata}; let idol = idol_handle(); let r = idol .extract_vid_enum( @@ -603,8 +610,8 @@ task_slot!(I2C, i2c_driver); // a single cfg block #[cfg(feature = "fru-id-eeprom")] mod at24csw080 { - use super::*; - use drv_i2c_devices::at24csw080::*; + use super::{i2c_config, I2C}; + use drv_i2c_devices::at24csw080::{At24Csw080, Error, WriteProtectBlock}; const EEPROM_SIZE: u16 = 1024; const PAGE_SIZE: u16 = 16; @@ -867,7 +874,7 @@ fn test_restart() { // value is swapped for the previous contents, which should be zero. let value = 0xDEAD_F00D_u32; let mut response = 0_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::Store as u16, &value.to_le_bytes(), @@ -882,7 +889,7 @@ fn test_restart() { // Read it back and replace it. let value2 = 0x1DE_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::Store as u16, &value2.to_le_bytes(), @@ -899,7 +906,7 @@ fn test_restart() { let assist = assist_task_id(); // Swap values again. - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::Store as u16, &value.to_le_bytes(), @@ -920,7 +927,7 @@ fn test_restart_taskgen() { // Ask the assistant to panic. let mut response = 0_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::Panic as u16, &0u32.to_le_bytes(), @@ -945,7 +952,7 @@ fn test_restart_taskgen() { // with a hint as to our generation. let payload = 0xDEAD_F00Du32; let mut response = 0_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::SendBack as u16, &payload.to_le_bytes(), @@ -971,7 +978,7 @@ fn test_borrow_info() { // Ask the assistant to call us back with two particularly shaped loans // (which are hardcoded in the assistant, not encoded here). let mut response = 0_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::SendBackWithLoans as u16, &0u32.to_le_bytes(), @@ -1014,7 +1021,7 @@ fn test_borrow_read() { // Ask the assistant to call us back with two particularly shaped loans // (which are hardcoded in the assistant, not encoded here). let mut response = 0_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::SendBackWithLoans as u16, &0u32.to_le_bytes(), @@ -1055,7 +1062,7 @@ fn test_borrow_write() { // Ask the assistant to call us back with two particularly shaped loans // (which are hardcoded in the assistant, not encoded here). let mut response = 0_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::SendBackWithLoans as u16, &0u32.to_le_bytes(), @@ -1098,22 +1105,22 @@ fn test_borrow_without_peer_waiting() { let initial_id = assist_task_id(); // First, try getting borrow info (which shouldn't exist) - let info = sys_borrow_info(initial_id, 0); + let info = userlib::sys_borrow_info(initial_id, 0); assert!(info.is_none(), "expected to fail sys_borrow_info"); - let new_id = sys_refresh_task_id(initial_id); + let new_id = userlib::sys_refresh_task_id(initial_id); assert_eq!(initial_id, new_id, "id should not change"); // Next, attempt to do a non-existent borrow read let mut buf = [0; 16]; - let (rc, _n) = sys_borrow_read(initial_id, 0, 0, &mut buf); - assert_eq!(rc, DEFECT, "expected to fail sys_borrow_read"); - let new_id = sys_refresh_task_id(initial_id); + let (rc, _n) = userlib::sys_borrow_read(initial_id, 0, 0, &mut buf); + assert_eq!(rc, userlib::DEFECT, "expected to fail sys_borrow_read"); + let new_id = userlib::sys_refresh_task_id(initial_id); assert_eq!(initial_id, new_id, "id should not change"); // Finally, attempt to do a non-existent borrow read - let (rc, _n) = sys_borrow_write(initial_id, 0, 0, &buf); - assert_eq!(rc, DEFECT, "expected to fail sys_borrow_write"); - let new_id = sys_refresh_task_id(initial_id); + let (rc, _n) = userlib::sys_borrow_write(initial_id, 0, 0, &buf); + assert_eq!(rc, userlib::DEFECT, "expected to fail sys_borrow_write"); + let new_id = userlib::sys_refresh_task_id(initial_id); assert_eq!(initial_id, new_id, "id should not change"); } @@ -1132,7 +1139,7 @@ fn test_supervisor_fault_notification() { let assist = assist_task_id(); let mut response = 0_u32; // Request a crash - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::Panic as u16, &0u32.to_le_bytes(), @@ -1155,8 +1162,8 @@ fn test_supervisor_fault_notification() { /// This test will fail by hanging. We can't set an iteration limit because who /// knows how fast our computer is in relation to the tick rate? fn test_timer_advance() { - let initial_time = sys_get_timer().now; - while sys_get_timer().now == initial_time { + let initial_time = userlib::sys_get_timer().now; + while userlib::sys_get_timer().now == initial_time { // doot doot } } @@ -1165,15 +1172,19 @@ fn test_timer_advance() { fn test_timer_notify() { const ARBITRARY_NOTIFICATION: u32 = 1 << 16; - let start_time = sys_get_timer().now; + let start_time = userlib::sys_get_timer().now; // We'll arbitrarily set our deadline 2 ticks in the future. let deadline = start_time + 2; - sys_set_timer(Some(deadline), ARBITRARY_NOTIFICATION); + userlib::sys_set_timer(Some(deadline), ARBITRARY_NOTIFICATION); // Deliberately not using the sys_recv_notification convenience operation so // that we can examine more of the results. - let rm = sys_recv_closed(&mut [], ARBITRARY_NOTIFICATION, TaskId::KERNEL) - .unwrap(); + let rm = userlib::sys_recv_closed( + &mut [], + ARBITRARY_NOTIFICATION, + TaskId::KERNEL, + ) + .unwrap(); assert_eq!(rm.sender, TaskId::KERNEL); assert_eq!(rm.operation, ARBITRARY_NOTIFICATION); @@ -1183,21 +1194,25 @@ fn test_timer_notify() { // In the interest of not making this test performance-sensitive, we merely // verify that the timer is at _or beyond_ our deadline. - assert!(sys_get_timer().now >= deadline); + assert!(userlib::sys_get_timer().now >= deadline); } /// Tests that we can set a timer in the past and get immediate notification. fn test_timer_notify_past() { const ARBITRARY_NOTIFICATION: u32 = 1 << 16; - let start_time = sys_get_timer().now; + let start_time = userlib::sys_get_timer().now; let deadline = start_time; - sys_set_timer(Some(deadline), ARBITRARY_NOTIFICATION); + userlib::sys_set_timer(Some(deadline), ARBITRARY_NOTIFICATION); // Deliberately not using the sys_recv_notification convenience operation so // that we can examine more of the results. - let rm = sys_recv_closed(&mut [], ARBITRARY_NOTIFICATION, TaskId::KERNEL) - .unwrap(); + let rm = userlib::sys_recv_closed( + &mut [], + ARBITRARY_NOTIFICATION, + TaskId::KERNEL, + ) + .unwrap(); assert_eq!(rm.sender, TaskId::KERNEL); assert_eq!(rm.operation, ARBITRARY_NOTIFICATION); @@ -1239,7 +1254,7 @@ fn test_floating_point(highregs: bool) { let mut response = 0_u32; let which = highregs as u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::EatSomePi as u16, &which.to_le_bytes(), @@ -1290,7 +1305,7 @@ fn test_task_status() { loop { let mut response = 0_u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::ReadTaskStatus as u16, &id.to_le_bytes(), @@ -1350,7 +1365,7 @@ fn test_task_fault_injection() { fn test_refresh_task_id_basic() { let initial_id = assist_task_id(); restart_assistant(); - let new_id = sys_refresh_task_id(initial_id); + let new_id = userlib::sys_refresh_task_id(initial_id); assert_eq!( new_id.index(), @@ -1384,7 +1399,7 @@ fn test_post() { // Do an initial call to drain any previously posted bits. let unused = 0u32; - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::ReadNotifications as u16, unused.as_bytes(), @@ -1396,12 +1411,12 @@ fn test_post() { // Now, post some bits. const ARBITRARY_MASK: u32 = 0xAA00006A; - let post_rc = sys_post(assist, ARBITRARY_MASK); + let post_rc = userlib::sys_post(assist, ARBITRARY_MASK); // Should not have died. assert_eq!(post_rc, 0); // And read them back. - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( assist, AssistOp::ReadNotifications as u16, unused.as_bytes(), @@ -1416,15 +1431,18 @@ fn test_post() { /// Tests that a task is notified on receipt of a hardware interrupt. fn test_irq_notif() { - sys_irq_control(notifications::TEST_IRQ_MASK, true); + userlib::sys_irq_control(notifications::TEST_IRQ_MASK, true); trigger_test_irq(); // Deliberately not using the sys_recv_notification convenience operation so // that we can examine more of the results. - let rm = - sys_recv_closed(&mut [], notifications::TEST_IRQ_MASK, TaskId::KERNEL) - .unwrap(); + let rm = userlib::sys_recv_closed( + &mut [], + notifications::TEST_IRQ_MASK, + TaskId::KERNEL, + ) + .unwrap(); assert_eq!(rm.sender, TaskId::KERNEL); assert_eq!(rm.operation, notifications::TEST_IRQ_MASK); @@ -1435,25 +1453,25 @@ fn test_irq_notif() { /// Tests the IRQ_STATUS syscall. fn test_irq_status() { - sys_irq_control(notifications::TEST_IRQ_MASK, false); + userlib::sys_irq_control(notifications::TEST_IRQ_MASK, false); // the interrupt should not be pending - let status = sys_irq_status(notifications::TEST_IRQ_MASK); + let status = userlib::sys_irq_status(notifications::TEST_IRQ_MASK); assert_eq!(status, IrqStatus::empty()); // trigger an interrupt *without* setting the enabled flag. now, the // interrupt should be pending but not posted. trigger_test_irq(); - let status = sys_irq_status(notifications::TEST_IRQ_MASK); + let status = userlib::sys_irq_status(notifications::TEST_IRQ_MASK); let expected_status = IrqStatus::PENDING; assert_eq!(status, expected_status); // enable the interrupt - sys_irq_control(notifications::TEST_IRQ_MASK, true); + userlib::sys_irq_control(notifications::TEST_IRQ_MASK, true); // now, the pending IRQ should be posted to this task. - let status = sys_irq_status(notifications::TEST_IRQ_MASK); + let status = userlib::sys_irq_status(notifications::TEST_IRQ_MASK); let expected_status = IrqStatus::POSTED; assert_eq!(status, expected_status); @@ -1464,7 +1482,7 @@ fn test_irq_status() { // does *not* include the notification mask, we will not consume the posted // notification. trigger_test_irq(); - let status = sys_irq_status(notifications::TEST_IRQ_MASK); + let status = userlib::sys_irq_status(notifications::TEST_IRQ_MASK); let expected_status = IrqStatus::POSTED | IrqStatus::PENDING; assert_eq!(status, expected_status); @@ -1473,10 +1491,14 @@ fn test_irq_status() { // // Deliberately not using the sys_recv_notification convenience operation so // that we can examine more of the results. - sys_recv_closed(&mut [], notifications::TEST_IRQ_MASK, TaskId::KERNEL) - .unwrap(); - - let status = sys_irq_status(notifications::TEST_IRQ_MASK); + userlib::sys_recv_closed( + &mut [], + notifications::TEST_IRQ_MASK, + TaskId::KERNEL, + ) + .unwrap(); + + let status = userlib::sys_irq_status(notifications::TEST_IRQ_MASK); let expected_status = IrqStatus::PENDING; assert_eq!(status, expected_status); } @@ -1489,8 +1511,13 @@ fn trigger_test_irq() { let mut response = 0u32; let op = RunnerOp::SoftIrq as u16; let arg = notifications::TEST_IRQ_MASK; - let (rc, len) = - sys_send(runner, op, arg.as_bytes(), response.as_bytes_mut(), &[]); + let (rc, len) = userlib::sys_send( + runner, + op, + arg.as_bytes(), + response.as_bytes_mut(), + &[], + ); assert_eq!(rc, 0); assert_eq!(len, 0); } @@ -1527,7 +1554,8 @@ fn read_runner_notifications() -> u32 { let runner = RUNNER.get_task_id(); let mut response = 0u32; let op = RunnerOp::ReadAndClearNotes as u16; - let (rc, len) = sys_send(runner, op, &[], response.as_bytes_mut(), &[]); + let (rc, len) = + userlib::sys_send(runner, op, &[], response.as_bytes_mut(), &[]); assert_eq!(rc, 0); assert_eq!(len, 4); response @@ -1544,7 +1572,7 @@ fn main() -> ! { let assist = assist_task_id(); let challenge = 0xDEADBEEF_u32; let mut response = 0_u32; - let (rc, _) = sys_send( + let (rc, _) = userlib::sys_send( assist, 0, &challenge.to_le_bytes(), @@ -1574,7 +1602,7 @@ fn main() -> ! { ringbuf_entry!(Trace::TestFinish); // Report back to the runner (aka our monitor) - let (rc, len) = sys_send( + let (rc, len) = userlib::sys_send( RUNNER.get_task_id(), op, &[],