diff --git a/apps/system/components/TimerService/kata-timer-component/src/run.rs b/apps/system/components/TimerService/kata-timer-component/src/run.rs index 499e6c7..ec88611 100644 --- a/apps/system/components/TimerService/kata-timer-component/src/run.rs +++ b/apps/system/components/TimerService/kata-timer-component/src/run.rs @@ -1,5 +1,6 @@ //! The Timer Service provides multiplexed access to a hardware timer. #![no_std] +#![allow(clippy::missing_safety_doc)] use core::time::Duration; use kata_os_common::allocator; @@ -10,28 +11,24 @@ use kata_timer_service::TIMER_SRV; use log::trace; #[no_mangle] -pub extern "C" fn pre_init() { +pub unsafe extern "C" fn pre_init() { static KATA_LOGGER: KataLogger = KataLogger; log::set_logger(&KATA_LOGGER).unwrap(); log::set_max_level(log::LevelFilter::Trace); // TODO(jesionowski): temp until we integrate with seL4 static mut HEAP_MEMORY: [u8; 4 * 1024] = [0; 4 * 1024]; - unsafe { - 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() - ); - } + 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() + ); } #[no_mangle] -pub extern "C" fn timer__init() { - unsafe { - TIMER_SRV.lock().init(); - } +pub unsafe extern "C" fn timer__init() { + TIMER_SRV.lock().init(); } extern "C" { @@ -39,63 +36,61 @@ extern "C" { } #[no_mangle] -pub extern "C" fn timer_completed_timers() -> u32 { - unsafe { - let client_id = timer_get_sender_id(); - return TIMER_SRV.lock().completed_timers(client_id); - } +pub unsafe extern "C" fn timer_completed_timers() -> u32 { + let client_id = timer_get_sender_id(); + return TIMER_SRV.lock().completed_timers(client_id); } #[no_mangle] -pub extern "C" fn timer_oneshot(timer_id: TimerId, duration_ms: u32) -> TimerServiceError { +pub unsafe extern "C" fn timer_oneshot( + timer_id: TimerId, + duration_ms: u32 +) -> TimerServiceError { let duration = Duration::from_millis(duration_ms as u64); let is_periodic = false; - unsafe { - let client_id = timer_get_sender_id(); - match TIMER_SRV - .lock() - .add(client_id, timer_id, duration, is_periodic) - { - Err(e) => e, - Ok(()) => TimerServiceError::TimerOk, - } + let client_id = timer_get_sender_id(); + match TIMER_SRV + .lock() + .add(client_id, timer_id, duration, is_periodic) + { + Err(e) => e, + Ok(()) => TimerServiceError::TimerOk, } } #[no_mangle] -pub extern "C" fn timer_periodic(timer_id: TimerId, duration_ms: u32) -> TimerServiceError { +pub unsafe extern "C" fn timer_periodic( + timer_id: TimerId, + duration_ms: u32 +) -> TimerServiceError { let duration = Duration::from_millis(duration_ms as u64); let is_periodic = true; - unsafe { - let client_id = timer_get_sender_id(); - match TIMER_SRV - .lock() - .add(client_id, timer_id, duration, is_periodic) - { - Err(e) => e, - Ok(()) => TimerServiceError::TimerOk, - } + let client_id = timer_get_sender_id(); + match TIMER_SRV + .lock() + .add(client_id, timer_id, duration, is_periodic) + { + Err(e) => e, + Ok(()) => TimerServiceError::TimerOk, } } #[no_mangle] -pub extern "C" fn timer_cancel(timer_id: TimerId) -> TimerServiceError { - unsafe { - let client_id = timer_get_sender_id(); - match TIMER_SRV.lock().cancel(client_id, timer_id) { - Err(e) => e, - Ok(()) => TimerServiceError::TimerOk, - } +pub unsafe extern "C" fn timer_cancel( + timer_id: TimerId +) -> TimerServiceError { + let client_id = timer_get_sender_id(); + match TIMER_SRV.lock().cancel(client_id, timer_id) { + Err(e) => e, + Ok(()) => TimerServiceError::TimerOk, } } #[no_mangle] -pub extern "C" fn timer_interrupt_handle() { +pub unsafe extern "C" fn timer_interrupt_handle() { extern "C" { fn timer_interrupt_acknowledge() -> u32; } - unsafe { - TIMER_SRV.lock().service_interrupt(); - } - assert!(unsafe { timer_interrupt_acknowledge() == 0 }); + TIMER_SRV.lock().service_interrupt(); + assert!(timer_interrupt_acknowledge() == 0); } diff --git a/apps/system/components/TimerService/kata-timer-service/src/lib.rs b/apps/system/components/TimerService/kata-timer-service/src/lib.rs index 7479fe6..223b030 100644 --- a/apps/system/components/TimerService/kata-timer-service/src/lib.rs +++ b/apps/system/components/TimerService/kata-timer-service/src/lib.rs @@ -72,8 +72,7 @@ impl KataTimerService { if self .events .iter() - .find(|(_, ev)| ev.client_id == client_id && ev.timer_id == timer_id) - .is_some() + .any(|(_, ev)| ev.client_id == client_id && ev.timer_id == timer_id) { return Err(TimerServiceError::TimerAlreadyExists); }