This repository was archived by the owner on May 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
RISC-V support #3
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
116a79d
abstracted `async-cortex-m` over specifics of `WFE/SEV` across ISAs. …
ilya-epifanov f539683
renamed `async-cortex-m` to `async-embedded` as it's now generic over…
ilya-epifanov 30762d2
removed `isa-...` `feature`s in favour of `target_arch`
ilya-epifanov 26c3058
added `target_arch = "riscv64"`
ilya-epifanov 73edbac
s/wait-extern/riscv-wait-extern/
ilya-epifanov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[workspace] | ||
members = [ | ||
"async-cortex-m", | ||
"async-embedded", | ||
"cortex-m-udf", | ||
"nrf52", | ||
"panic-udf", | ||
|
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,25 @@ | |
authors = ["Jorge Aparicio <[email protected]>"] | ||
edition = "2018" | ||
license = "MIT OR Apache-2.0" | ||
name = "async-cortex-m" | ||
name = "async-embedded" | ||
publish = false | ||
version = "0.0.0-alpha.0" | ||
|
||
[dependencies] | ||
cortex-m = "0.6.2" | ||
cortex-m-udf = { path = "../cortex-m-udf" } | ||
generic-array = "0.13.2" | ||
heapless = { git = "https://github.com/japaric/heapless", branch = "slab" } | ||
pin-utils = "0.1.0-alpha.4" | ||
typenum = "1.11.2" | ||
|
||
[target.'cfg(target_arch = "arm")'.dependencies] | ||
cortex-m = "0.6.2" | ||
cortex-m-udf = { path = "../cortex-m-udf" } | ||
|
||
[target.'cfg(any(target_arch = "riscv32", target_arch = "riscv64"))'.dependencies] | ||
riscv = "0.5.6" | ||
|
||
[features] | ||
default = ["riscv-wait-nop"] | ||
riscv-wait-nop = [] | ||
riscv-wait-wfi-single-hart = [] | ||
riscv-wait-extern = [] |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
//! Proof of Concept async runtime for the Cortex-M architecture | ||
|
||
#![deny(missing_docs)] | ||
#![deny(rust_2018_idioms)] | ||
#![deny(warnings)] | ||
#![no_std] | ||
|
||
mod alloc; | ||
mod executor; | ||
pub mod task; | ||
pub mod unsync; | ||
|
||
#[cfg(target_arch = "arm")] | ||
use cortex_m::asm; | ||
|
||
|
||
#[cfg(target_arch = "arm")] | ||
pub use cortex_m_udf::udf as abort; | ||
|
||
#[cfg(target_arch = "arm")] | ||
#[inline] | ||
/// Prevent next `wait_for_interrupt` from sleeping, wake up other harts if needed. | ||
/// This particular implementation does nothing, since `wait_for_interrupt` never sleeps | ||
pub(crate) unsafe fn signal_event_ready() { | ||
asm::sev(); | ||
} | ||
|
||
#[cfg(target_arch = "arm")] | ||
#[inline] | ||
/// Wait for an interrupt or until notified by other hart via `signal_task_ready` | ||
/// This particular implementation does nothing | ||
pub(crate) unsafe fn wait_for_event() { | ||
asm::wfe(); | ||
} | ||
|
||
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] | ||
/// This keeps dropping into the debugger and never returns | ||
pub fn abort() -> ! { | ||
loop { | ||
unsafe { riscv::asm::ebreak() } | ||
} | ||
} | ||
|
||
#[cfg(all(any(target_arch = "riscv32", target_arch = "riscv64"), feature = "riscv-wait-nop"))] | ||
#[inline] | ||
/// Prevent next `wait_for_interrupt` from sleeping, wake up other harts if needed. | ||
/// This particular implementation does nothing, since `wait_for_interrupt` never sleeps | ||
pub(crate) unsafe fn signal_event_ready() {} | ||
|
||
#[cfg(all(any(target_arch = "riscv32", target_arch = "riscv64"), feature = "riscv-wait-nop"))] | ||
#[inline] | ||
/// Wait for an interrupt or until notified by other hart via `signal_task_ready` | ||
/// This particular implementation does nothing | ||
pub(crate) unsafe fn wait_for_event() {} | ||
|
||
#[cfg(all(any(target_arch = "riscv32", target_arch = "riscv64"), feature = "riscv-wait-extern"))] | ||
extern "C" { | ||
/// Prevent next `wait_for_interrupt` from sleeping, wake up other harts if needed. | ||
/// User is expected to provide an actual implementation, like the one shown below. | ||
/// | ||
/// #[no_mangle] | ||
/// pub extern "C" fn signal_event_ready() { | ||
/// unimplemented!(); | ||
/// } | ||
pub(crate) fn signal_event_ready(); | ||
|
||
/// Wait for an interrupt or until notified by other hart via `signal_task_ready` | ||
/// User is expected to provide an actual implementation, like the one shown below. | ||
/// | ||
/// #[no_mangle] | ||
/// pub extern "C" fn wait_for_event() { | ||
/// unimplemented!(); | ||
/// } | ||
pub(crate) fn wait_for_event(); | ||
} | ||
|
||
#[cfg(all(any(target_arch = "riscv32", target_arch = "riscv64"), feature = "riscv-wait-wfi-single-hart"))] | ||
static mut TASK_READY: bool = false; | ||
|
||
#[cfg(all(any(target_arch = "riscv32", target_arch = "riscv64"), feature = "riscv-wait-wfi-single-hart"))] | ||
#[inline] | ||
/// Prevent next `wait_for_interrupt` from sleeping, wake up other harts if needed. | ||
/// This particular implementation prevents `wait_for_interrupt` from sleeping by setting | ||
/// a global mutable flag | ||
pub(crate) unsafe fn signal_event_ready() { | ||
TASK_READY = true; | ||
} | ||
|
||
#[cfg(all(any(target_arch = "riscv32", target_arch = "riscv64"), feature = "riscv-wait-wfi-single-hart"))] | ||
#[inline] | ||
/// Wait for an interrupt or until notified by other hart via `signal_task_ready` | ||
/// This particular implementation decides whether to sleep or not by checking | ||
/// a global mutable flag that's set by `signal_task_ready` | ||
pub(crate) unsafe fn wait_for_event() { | ||
if !TASK_READY { | ||
riscv::asm::wfi(); | ||
TASK_READY = false; | ||
} | ||
} | ||
|
||
/// Maximum number of tasks (TODO this could be user configurable) | ||
type NTASKS = typenum::consts::U8; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is not required anymore after my fix: https://github.com/ferrous-systems/async-on-embedded/pull/2/files#diff-22ab3da1c5b4e44f95ba9b8000eda448R116
However,
sev
is required when task is woken from an interrupt context.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, your fix included the
sev
call so I kept it