diff options
Diffstat (limited to 'embassy-executor/src/raw')
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 7 | ||||
| -rw-r--r-- | embassy-executor/src/raw/state_atomics.rs | 4 | ||||
| -rw-r--r-- | embassy-executor/src/raw/state_atomics_arm.rs | 4 | ||||
| -rw-r--r-- | embassy-executor/src/raw/state_critical_section.rs | 4 | ||||
| -rw-r--r-- | embassy-executor/src/raw/trace.rs | 22 |
5 files changed, 8 insertions, 33 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 14d689900..2feaab155 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -16,7 +16,6 @@ mod run_queue; | |||
| 16 | #[cfg_attr(not(target_has_atomic = "8"), path = "state_critical_section.rs")] | 16 | #[cfg_attr(not(target_has_atomic = "8"), path = "state_critical_section.rs")] |
| 17 | mod state; | 17 | mod state; |
| 18 | 18 | ||
| 19 | #[cfg(feature = "integrated-timers")] | ||
| 20 | pub mod timer_queue; | 19 | pub mod timer_queue; |
| 21 | #[cfg(feature = "trace")] | 20 | #[cfg(feature = "trace")] |
| 22 | mod trace; | 21 | mod trace; |
| @@ -45,7 +44,6 @@ pub(crate) struct TaskHeader { | |||
| 45 | poll_fn: SyncUnsafeCell<Option<unsafe fn(TaskRef)>>, | 44 | poll_fn: SyncUnsafeCell<Option<unsafe fn(TaskRef)>>, |
| 46 | 45 | ||
| 47 | /// Integrated timer queue storage. This field should not be accessed outside of the timer queue. | 46 | /// Integrated timer queue storage. This field should not be accessed outside of the timer queue. |
| 48 | #[cfg(feature = "integrated-timers")] | ||
| 49 | pub(crate) timer_queue_item: timer_queue::TimerQueueItem, | 47 | pub(crate) timer_queue_item: timer_queue::TimerQueueItem, |
| 50 | } | 48 | } |
| 51 | 49 | ||
| @@ -87,13 +85,11 @@ impl TaskRef { | |||
| 87 | } | 85 | } |
| 88 | 86 | ||
| 89 | /// Returns a reference to the executor that the task is currently running on. | 87 | /// Returns a reference to the executor that the task is currently running on. |
| 90 | #[cfg(feature = "integrated-timers")] | ||
| 91 | pub unsafe fn executor(self) -> Option<&'static Executor> { | 88 | pub unsafe fn executor(self) -> Option<&'static Executor> { |
| 92 | self.header().executor.get().map(|e| Executor::wrap(e)) | 89 | self.header().executor.get().map(|e| Executor::wrap(e)) |
| 93 | } | 90 | } |
| 94 | 91 | ||
| 95 | /// Returns a reference to the timer queue item. | 92 | /// Returns a reference to the timer queue item. |
| 96 | #[cfg(feature = "integrated-timers")] | ||
| 97 | pub fn timer_queue_item(&self) -> &'static timer_queue::TimerQueueItem { | 93 | pub fn timer_queue_item(&self) -> &'static timer_queue::TimerQueueItem { |
| 98 | &self.header().timer_queue_item | 94 | &self.header().timer_queue_item |
| 99 | } | 95 | } |
| @@ -106,7 +102,6 @@ impl TaskRef { | |||
| 106 | /// | 102 | /// |
| 107 | /// This functions should only be called by the timer queue implementation, before | 103 | /// This functions should only be called by the timer queue implementation, before |
| 108 | /// enqueueing the timer item. | 104 | /// enqueueing the timer item. |
| 109 | #[cfg(feature = "integrated-timers")] | ||
| 110 | pub unsafe fn timer_enqueue(&self) -> timer_queue::TimerEnqueueOperation { | 105 | pub unsafe fn timer_enqueue(&self) -> timer_queue::TimerEnqueueOperation { |
| 111 | self.header().state.timer_enqueue() | 106 | self.header().state.timer_enqueue() |
| 112 | } | 107 | } |
| @@ -117,7 +112,6 @@ impl TaskRef { | |||
| 117 | /// | 112 | /// |
| 118 | /// This functions should only be called by the timer queue implementation, after the task has | 113 | /// This functions should only be called by the timer queue implementation, after the task has |
| 119 | /// been removed from the timer queue. | 114 | /// been removed from the timer queue. |
| 120 | #[cfg(feature = "integrated-timers")] | ||
| 121 | pub unsafe fn timer_dequeue(&self) { | 115 | pub unsafe fn timer_dequeue(&self) { |
| 122 | self.header().state.timer_dequeue() | 116 | self.header().state.timer_dequeue() |
| 123 | } | 117 | } |
| @@ -162,7 +156,6 @@ impl<F: Future + 'static> TaskStorage<F> { | |||
| 162 | // Note: this is lazily initialized so that a static `TaskStorage` will go in `.bss` | 156 | // Note: this is lazily initialized so that a static `TaskStorage` will go in `.bss` |
| 163 | poll_fn: SyncUnsafeCell::new(None), | 157 | poll_fn: SyncUnsafeCell::new(None), |
| 164 | 158 | ||
| 165 | #[cfg(feature = "integrated-timers")] | ||
| 166 | timer_queue_item: timer_queue::TimerQueueItem::new(), | 159 | timer_queue_item: timer_queue::TimerQueueItem::new(), |
| 167 | }, | 160 | }, |
| 168 | future: UninitCell::uninit(), | 161 | future: UninitCell::uninit(), |
diff --git a/embassy-executor/src/raw/state_atomics.rs b/embassy-executor/src/raw/state_atomics.rs index d03c61ade..15eb9a368 100644 --- a/embassy-executor/src/raw/state_atomics.rs +++ b/embassy-executor/src/raw/state_atomics.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | use core::sync::atomic::{AtomicU32, Ordering}; | 1 | use core::sync::atomic::{AtomicU32, Ordering}; |
| 2 | 2 | ||
| 3 | #[cfg(feature = "integrated-timers")] | ||
| 4 | use super::timer_queue::TimerEnqueueOperation; | 3 | use super::timer_queue::TimerEnqueueOperation; |
| 5 | 4 | ||
| 6 | /// Task is spawned (has a future) | 5 | /// Task is spawned (has a future) |
| @@ -8,7 +7,6 @@ pub(crate) const STATE_SPAWNED: u32 = 1 << 0; | |||
| 8 | /// Task is in the executor run queue | 7 | /// Task is in the executor run queue |
| 9 | pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1; | 8 | pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1; |
| 10 | /// Task is in the executor timer queue | 9 | /// Task is in the executor timer queue |
| 11 | #[cfg(feature = "integrated-timers")] | ||
| 12 | pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2; | 10 | pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2; |
| 13 | 11 | ||
| 14 | pub(crate) struct State { | 12 | pub(crate) struct State { |
| @@ -60,7 +58,6 @@ impl State { | |||
| 60 | } | 58 | } |
| 61 | 59 | ||
| 62 | /// Mark the task as timer-queued. Return whether it can be enqueued. | 60 | /// Mark the task as timer-queued. Return whether it can be enqueued. |
| 63 | #[cfg(feature = "integrated-timers")] | ||
| 64 | #[inline(always)] | 61 | #[inline(always)] |
| 65 | pub fn timer_enqueue(&self) -> TimerEnqueueOperation { | 62 | pub fn timer_enqueue(&self) -> TimerEnqueueOperation { |
| 66 | if self | 63 | if self |
| @@ -83,7 +80,6 @@ impl State { | |||
| 83 | } | 80 | } |
| 84 | 81 | ||
| 85 | /// Unmark the task as timer-queued. | 82 | /// Unmark the task as timer-queued. |
| 86 | #[cfg(feature = "integrated-timers")] | ||
| 87 | #[inline(always)] | 83 | #[inline(always)] |
| 88 | pub fn timer_dequeue(&self) { | 84 | pub fn timer_dequeue(&self) { |
| 89 | self.state.fetch_and(!STATE_TIMER_QUEUED, Ordering::Relaxed); | 85 | self.state.fetch_and(!STATE_TIMER_QUEUED, Ordering::Relaxed); |
diff --git a/embassy-executor/src/raw/state_atomics_arm.rs b/embassy-executor/src/raw/state_atomics_arm.rs index f6f2e8f08..7a152e8c0 100644 --- a/embassy-executor/src/raw/state_atomics_arm.rs +++ b/embassy-executor/src/raw/state_atomics_arm.rs | |||
| @@ -1,13 +1,11 @@ | |||
| 1 | use core::arch::asm; | 1 | use core::arch::asm; |
| 2 | use core::sync::atomic::{compiler_fence, AtomicBool, AtomicU32, Ordering}; | 2 | use core::sync::atomic::{compiler_fence, AtomicBool, AtomicU32, Ordering}; |
| 3 | 3 | ||
| 4 | #[cfg(feature = "integrated-timers")] | ||
| 5 | use super::timer_queue::TimerEnqueueOperation; | 4 | use super::timer_queue::TimerEnqueueOperation; |
| 6 | 5 | ||
| 7 | // Must be kept in sync with the layout of `State`! | 6 | // Must be kept in sync with the layout of `State`! |
| 8 | pub(crate) const STATE_SPAWNED: u32 = 1 << 0; | 7 | pub(crate) const STATE_SPAWNED: u32 = 1 << 0; |
| 9 | pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 8; | 8 | pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 8; |
| 10 | #[cfg(feature = "integrated-timers")] | ||
| 11 | pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 16; | 9 | pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 16; |
| 12 | 10 | ||
| 13 | #[repr(C, align(4))] | 11 | #[repr(C, align(4))] |
| @@ -93,7 +91,6 @@ impl State { | |||
| 93 | } | 91 | } |
| 94 | 92 | ||
| 95 | /// Mark the task as timer-queued. Return whether it can be enqueued. | 93 | /// Mark the task as timer-queued. Return whether it can be enqueued. |
| 96 | #[cfg(feature = "integrated-timers")] | ||
| 97 | #[inline(always)] | 94 | #[inline(always)] |
| 98 | pub fn timer_enqueue(&self) -> TimerEnqueueOperation { | 95 | pub fn timer_enqueue(&self) -> TimerEnqueueOperation { |
| 99 | if self | 96 | if self |
| @@ -116,7 +113,6 @@ impl State { | |||
| 116 | } | 113 | } |
| 117 | 114 | ||
| 118 | /// Unmark the task as timer-queued. | 115 | /// Unmark the task as timer-queued. |
| 119 | #[cfg(feature = "integrated-timers")] | ||
| 120 | #[inline(always)] | 116 | #[inline(always)] |
| 121 | pub fn timer_dequeue(&self) { | 117 | pub fn timer_dequeue(&self) { |
| 122 | self.timer_queued.store(false, Ordering::Relaxed); | 118 | self.timer_queued.store(false, Ordering::Relaxed); |
diff --git a/embassy-executor/src/raw/state_critical_section.rs b/embassy-executor/src/raw/state_critical_section.rs index c0ec2f530..367162ba2 100644 --- a/embassy-executor/src/raw/state_critical_section.rs +++ b/embassy-executor/src/raw/state_critical_section.rs | |||
| @@ -2,7 +2,6 @@ use core::cell::Cell; | |||
| 2 | 2 | ||
| 3 | use critical_section::Mutex; | 3 | use critical_section::Mutex; |
| 4 | 4 | ||
| 5 | #[cfg(feature = "integrated-timers")] | ||
| 6 | use super::timer_queue::TimerEnqueueOperation; | 5 | use super::timer_queue::TimerEnqueueOperation; |
| 7 | 6 | ||
| 8 | /// Task is spawned (has a future) | 7 | /// Task is spawned (has a future) |
| @@ -10,7 +9,6 @@ pub(crate) const STATE_SPAWNED: u32 = 1 << 0; | |||
| 10 | /// Task is in the executor run queue | 9 | /// Task is in the executor run queue |
| 11 | pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1; | 10 | pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1; |
| 12 | /// Task is in the executor timer queue | 11 | /// Task is in the executor timer queue |
| 13 | #[cfg(feature = "integrated-timers")] | ||
| 14 | pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2; | 12 | pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2; |
| 15 | 13 | ||
| 16 | pub(crate) struct State { | 14 | pub(crate) struct State { |
| @@ -77,7 +75,6 @@ impl State { | |||
| 77 | } | 75 | } |
| 78 | 76 | ||
| 79 | /// Mark the task as timer-queued. Return whether it can be enqueued. | 77 | /// Mark the task as timer-queued. Return whether it can be enqueued. |
| 80 | #[cfg(feature = "integrated-timers")] | ||
| 81 | #[inline(always)] | 78 | #[inline(always)] |
| 82 | pub fn timer_enqueue(&self) -> TimerEnqueueOperation { | 79 | pub fn timer_enqueue(&self) -> TimerEnqueueOperation { |
| 83 | self.update(|s| { | 80 | self.update(|s| { |
| @@ -93,7 +90,6 @@ impl State { | |||
| 93 | } | 90 | } |
| 94 | 91 | ||
| 95 | /// Unmark the task as timer-queued. | 92 | /// Unmark the task as timer-queued. |
| 96 | #[cfg(feature = "integrated-timers")] | ||
| 97 | #[inline(always)] | 93 | #[inline(always)] |
| 98 | pub fn timer_dequeue(&self) { | 94 | pub fn timer_dequeue(&self) { |
| 99 | self.update(|s| *s &= !STATE_TIMER_QUEUED); | 95 | self.update(|s| *s &= !STATE_TIMER_QUEUED); |
diff --git a/embassy-executor/src/raw/trace.rs b/embassy-executor/src/raw/trace.rs index c7bcf9c11..b34387b58 100644 --- a/embassy-executor/src/raw/trace.rs +++ b/embassy-executor/src/raw/trace.rs | |||
| @@ -61,29 +61,23 @@ pub(crate) fn executor_idle(executor: &SyncExecutor) { | |||
| 61 | rtos_trace::trace::system_idle(); | 61 | rtos_trace::trace::system_idle(); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | #[cfg(all(feature = "rtos-trace", feature = "integrated-timers"))] | ||
| 65 | const fn gcd(a: u64, b: u64) -> u64 { | ||
| 66 | if b == 0 { | ||
| 67 | a | ||
| 68 | } else { | ||
| 69 | gcd(b, a % b) | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | #[cfg(feature = "rtos-trace")] | 64 | #[cfg(feature = "rtos-trace")] |
| 74 | impl rtos_trace::RtosTraceOSCallbacks for crate::raw::SyncExecutor { | 65 | impl rtos_trace::RtosTraceOSCallbacks for crate::raw::SyncExecutor { |
| 75 | fn task_list() { | 66 | fn task_list() { |
| 76 | // We don't know what tasks exist, so we can't send them. | 67 | // We don't know what tasks exist, so we can't send them. |
| 77 | } | 68 | } |
| 78 | #[cfg(feature = "integrated-timers")] | ||
| 79 | fn time() -> u64 { | 69 | fn time() -> u64 { |
| 70 | const fn gcd(a: u64, b: u64) -> u64 { | ||
| 71 | if b == 0 { | ||
| 72 | a | ||
| 73 | } else { | ||
| 74 | gcd(b, a % b) | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 80 | const GCD_1M: u64 = gcd(embassy_time_driver::TICK_HZ, 1_000_000); | 78 | const GCD_1M: u64 = gcd(embassy_time_driver::TICK_HZ, 1_000_000); |
| 81 | embassy_time_driver::now() * (1_000_000 / GCD_1M) / (embassy_time_driver::TICK_HZ / GCD_1M) | 79 | embassy_time_driver::now() * (1_000_000 / GCD_1M) / (embassy_time_driver::TICK_HZ / GCD_1M) |
| 82 | } | 80 | } |
| 83 | #[cfg(not(feature = "integrated-timers"))] | ||
| 84 | fn time() -> u64 { | ||
| 85 | 0 | ||
| 86 | } | ||
| 87 | } | 81 | } |
| 88 | 82 | ||
| 89 | #[cfg(feature = "rtos-trace")] | 83 | #[cfg(feature = "rtos-trace")] |
