aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-12-03 22:25:51 +0100
committerDario Nieuwenhuis <[email protected]>2023-12-03 22:33:27 +0100
commitca3891bb8cece2c24aa229248e71d41dd0b224f1 (patch)
tree6f1156f59e3617876991505ead9be7530d9589de
parent9ba3aeada40afd3cafd64e73fee91896c15d7c8d (diff)
executor: remove arch-xtensa.
It's been broken for months and nobody has noticed. The `esp*-hal` crates have much better support. Fixes #2234 Closes #1912
-rw-r--r--embassy-executor/CHANGELOG.md4
-rw-r--r--embassy-executor/Cargo.toml1
-rw-r--r--embassy-executor/src/arch/xtensa.rs89
-rw-r--r--embassy-executor/src/lib.rs4
4 files changed, 5 insertions, 93 deletions
diff --git a/embassy-executor/CHANGELOG.md b/embassy-executor/CHANGELOG.md
index 559717da6..c839981d6 100644
--- a/embassy-executor/CHANGELOG.md
+++ b/embassy-executor/CHANGELOG.md
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7 7
8## Unreleased
9
10- Removed `arch-xtensa`. Use the executor provided by the HAL crate (`esp-hal`, `esp32s3-hal`, etc...) instead.
11
8## 0.3.3 - 2023-11-15 12## 0.3.3 - 2023-11-15
9 13
10- Add `main` macro reexport for Xtensa arch. 14- Add `main` macro reexport for Xtensa arch.
diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml
index ae46b17c6..bf58a2e1b 100644
--- a/embassy-executor/Cargo.toml
+++ b/embassy-executor/Cargo.toml
@@ -57,7 +57,6 @@ critical-section = { version = "1.1", features = ["std"] }
57_arch = [] # some arch was picked 57_arch = [] # some arch was picked
58arch-std = ["_arch", "critical-section/std"] 58arch-std = ["_arch", "critical-section/std"]
59arch-cortex-m = ["_arch", "dep:cortex-m"] 59arch-cortex-m = ["_arch", "dep:cortex-m"]
60arch-xtensa = ["_arch"]
61arch-riscv32 = ["_arch", "dep:portable-atomic"] 60arch-riscv32 = ["_arch", "dep:portable-atomic"]
62arch-wasm = ["_arch", "dep:wasm-bindgen", "dep:js-sys"] 61arch-wasm = ["_arch", "dep:wasm-bindgen", "dep:js-sys"]
63 62
diff --git a/embassy-executor/src/arch/xtensa.rs b/embassy-executor/src/arch/xtensa.rs
deleted file mode 100644
index 6ed9f9e72..000000000
--- a/embassy-executor/src/arch/xtensa.rs
+++ /dev/null
@@ -1,89 +0,0 @@
1#[cfg(feature = "executor-interrupt")]
2compile_error!("`executor-interrupt` is not supported with `arch-xtensa`.");
3
4#[cfg(feature = "executor-thread")]
5pub use thread::*;
6#[cfg(feature = "executor-thread")]
7mod thread {
8 use core::marker::PhantomData;
9 use core::sync::atomic::{AtomicBool, Ordering};
10
11 pub use embassy_macros::main_riscv as main;
12
13 use crate::{raw, Spawner};
14
15 /// global atomic used to keep track of whether there is work to do since sev() is not available on Xtensa
16 static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false);
17
18 #[export_name = "__pender"]
19 fn __pender(_context: *mut ()) {
20 SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst);
21 }
22
23 /// Xtensa Executor
24 pub struct Executor {
25 inner: raw::Executor,
26 not_send: PhantomData<*mut ()>,
27 }
28
29 impl Executor {
30 /// Create a new Executor.
31 pub fn new() -> Self {
32 Self {
33 inner: raw::Executor::new(core::ptr::null_mut()),
34 not_send: PhantomData,
35 }
36 }
37
38 /// Run the executor.
39 ///
40 /// The `init` closure is called with a [`Spawner`] that spawns tasks on
41 /// this executor. Use it to spawn the initial task(s). After `init` returns,
42 /// the executor starts running the tasks.
43 ///
44 /// To spawn more tasks later, you may keep copies of the [`Spawner`] (it is `Copy`),
45 /// for example by passing it as an argument to the initial tasks.
46 ///
47 /// This function requires `&'static mut self`. This means you have to store the
48 /// Executor instance in a place where it'll live forever and grants you mutable
49 /// access. There's a few ways to do this:
50 ///
51 /// - a [StaticCell](https://docs.rs/static_cell/latest/static_cell/) (safe)
52 /// - a `static mut` (unsafe)
53 /// - a local variable in a function you know never returns (like `fn main() -> !`), upgrading its lifetime with `transmute`. (unsafe)
54 ///
55 /// This function never returns.
56 pub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> ! {
57 init(self.inner.spawner());
58
59 loop {
60 unsafe {
61 self.inner.poll();
62
63 // Manual critical section implementation that only masks interrupts handlers.
64 // We must not acquire the cross-core on dual-core systems because that would
65 // prevent the other core from doing useful work while this core is sleeping.
66 let token: critical_section::RawRestoreState;
67 core::arch::asm!("rsil {0}, 5", out(reg) token);
68
69 // we do not care about race conditions between the load and store operations, interrupts
70 // will only set this value to true.
71 // if there is work to do, loop back to polling
72 if SIGNAL_WORK_THREAD_MODE.load(Ordering::SeqCst) {
73 SIGNAL_WORK_THREAD_MODE.store(false, Ordering::SeqCst);
74
75 core::arch::asm!(
76 "wsr.ps {0}",
77 "rsync", in(reg) token)
78 } else {
79 // waiti sets the PS.INTLEVEL when slipping into sleep
80 // because critical sections in Xtensa are implemented via increasing
81 // PS.INTLEVEL the critical section ends here
82 // take care not add code after `waiti` if it needs to be inside the CS
83 core::arch::asm!("waiti 0"); // critical section ends here
84 }
85 }
86 }
87 }
88 }
89}
diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs
index d8ac4893b..897696150 100644
--- a/embassy-executor/src/lib.rs
+++ b/embassy-executor/src/lib.rs
@@ -1,5 +1,4 @@
1#![cfg_attr(not(any(feature = "arch-std", feature = "arch-wasm")), no_std)] 1#![cfg_attr(not(any(feature = "arch-std", feature = "arch-wasm")), no_std)]
2#![cfg_attr(feature = "arch-xtensa", feature(asm_experimental_arch))]
3#![allow(clippy::new_without_default)] 2#![allow(clippy::new_without_default)]
4#![doc = include_str!("../README.md")] 3#![doc = include_str!("../README.md")]
5#![warn(missing_docs)] 4#![warn(missing_docs)]
@@ -21,12 +20,11 @@ macro_rules! check_at_most_one {
21 check_at_most_one!(@amo [$($f)*] [$($f)*] []); 20 check_at_most_one!(@amo [$($f)*] [$($f)*] []);
22 }; 21 };
23} 22}
24check_at_most_one!("arch-cortex-m", "arch-riscv32", "arch-xtensa", "arch-std", "arch-wasm",); 23check_at_most_one!("arch-cortex-m", "arch-riscv32", "arch-std", "arch-wasm",);
25 24
26#[cfg(feature = "_arch")] 25#[cfg(feature = "_arch")]
27#[cfg_attr(feature = "arch-cortex-m", path = "arch/cortex_m.rs")] 26#[cfg_attr(feature = "arch-cortex-m", path = "arch/cortex_m.rs")]
28#[cfg_attr(feature = "arch-riscv32", path = "arch/riscv32.rs")] 27#[cfg_attr(feature = "arch-riscv32", path = "arch/riscv32.rs")]
29#[cfg_attr(feature = "arch-xtensa", path = "arch/xtensa.rs")]
30#[cfg_attr(feature = "arch-std", path = "arch/std.rs")] 28#[cfg_attr(feature = "arch-std", path = "arch/std.rs")]
31#[cfg_attr(feature = "arch-wasm", path = "arch/wasm.rs")] 29#[cfg_attr(feature = "arch-wasm", path = "arch/wasm.rs")]
32mod arch; 30mod arch;