RISC-V support over CLINT (#815)

* Rebase to master

* using interrupt_mod

* bug fixes

* fix other backends

* Add changelog

* forgot about rtic-macros

* backend-specific configuration

* core peripherals optional over macro argument

* pre_init_preprocessing binding

* CI for RISC-V (WIP)

* separation of concerns

* add targets for RISC-V examples

* remove qemu feature

* prepare examples folder

* move examples all together

* move ci out of examples

* minor changes

* add cortex-m

* new xtask: proof of concept

* fix build.yml

* feature typo

* clean rtic examples

* reproduce weird issue

* remove unsafe code in user app

* update dependencies

* allow builds on riscv32imc

* let's fix QEMU

* Update .github/workflows/build.yml

Co-authored-by: Henrik Tjäder <henrik@tjaders.com>

* New build.rs

* removing test features

* adapt ui test to new version of clippy

* add more examples to RISC-V backend

* proper configuration of heapless for riscv32imc

* opt-out examples for riscv32imc

* point to new version of riscv-slic

* adapt new macro bindings

* adapt examples and CI to stable

* fix cortex-m CI

* Review

---------

Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
This commit is contained in:
Román Cárdenas Rodríguez 2024-03-20 21:06:47 +01:00 committed by GitHub
parent 22ac33a826
commit 4060c3def8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
166 changed files with 2322 additions and 315 deletions

View file

@ -2,7 +2,7 @@
use syn::{Attribute, Expr, Ident, Item, ItemUse, Pat, PatType, Path, Stmt, Type};
use crate::syntax::Map;
use crate::syntax::{backend::BackendArgs, Map};
/// The `#[app]` attribute
#[derive(Debug)]
@ -60,11 +60,17 @@ pub struct AppArgs {
/// Device
pub device: Path,
/// Peripherals
/// Core peripherals
pub core: bool,
/// Device peripherals
pub peripherals: bool,
/// Interrupts used to dispatch software tasks
pub dispatchers: Dispatchers,
/// Backend-specific arguments
pub backend: Option<BackendArgs>,
}
/// The `init`-ialization function

View file

@ -0,0 +1,32 @@
#[cfg(not(any(
feature = "cortex-m-source-masking",
feature = "cortex-m-basepri",
feature = "test-template",
feature = "riscv-esp32c3",
feature = "riscv-slic",
)))]
compile_error!("No backend selected");
#[cfg(any(feature = "cortex-m-source-masking", feature = "cortex-m-basepri"))]
pub use cortex::*;
#[cfg(feature = "test-template")]
pub use template::*;
#[cfg(feature = "riscv-esp32c3")]
pub use esp32c3::*;
#[cfg(feature = "riscv-slic")]
pub use riscv_slic::*;
#[cfg(any(feature = "cortex-m-source-masking", feature = "cortex-m-basepri"))]
mod cortex;
#[cfg(feature = "test-template")]
mod template;
#[cfg(feature = "riscv-esp32c3")]
mod esp32c3;
#[cfg(feature = "riscv-slic")]
mod riscv_slic;

View file

@ -0,0 +1,16 @@
use syn::{
parse::{Parse, ParseStream},
Error, Result,
};
#[derive(Debug)]
pub struct BackendArgs();
impl Parse for BackendArgs {
fn parse(input: ParseStream) -> Result<Self> {
Err(Error::new(
input.span(),
"cortex backend does not accept any arguments",
))
}
}

View file

@ -0,0 +1,16 @@
use syn::{
parse::{Parse, ParseStream},
Error, Result,
};
#[derive(Debug)]
pub struct BackendArgs();
impl Parse for BackendArgs {
fn parse(input: ParseStream) -> Result<Self> {
Err(Error::new(
input.span(),
"esp32c3 backend does not accept any arguments",
))
}
}

View file

@ -0,0 +1,16 @@
use syn::{
parse::{Parse, ParseStream},
Ident, Result,
};
#[derive(Debug)]
pub struct BackendArgs {
pub hart_id: Ident,
}
impl Parse for BackendArgs {
fn parse(input: ParseStream) -> Result<Self> {
let hart_id = input.parse()?;
Ok(BackendArgs { hart_id })
}
}

View file

@ -0,0 +1,15 @@
use syn::{
parse::{Parse, ParseStream},
Result,
};
#[derive(Debug)]
pub struct BackendArgs {
// Define your backend-specific input here
}
impl Parse for BackendArgs {
fn parse(input: ParseStream) -> Result<Self> {
todo!("define how to parse your backend-specific arguments")
}
}

View file

@ -13,6 +13,7 @@ use crate::syntax::{
App, AppArgs, Dispatcher, Dispatchers, HardwareTask, Idle, IdleArgs, Init, InitArgs,
LocalResource, SharedResource, SoftwareTask,
},
backend::BackendArgs,
parse::{self as syntax_parse, util},
Either, Map, Set,
};
@ -24,8 +25,10 @@ impl AppArgs {
(|input: ParseStream<'_>| -> parse::Result<Self> {
let mut custom = Set::new();
let mut device = None;
let mut core = true;
let mut peripherals = true;
let mut dispatchers = Dispatchers::new();
let mut backend = None;
loop {
if input.is_empty() {
@ -59,6 +62,17 @@ impl AppArgs {
}
}
"core" => {
if let Ok(p) = input.parse::<LitBool>() {
core = p.value;
} else {
return Err(parse::Error::new(
ident.span(),
"unexpected argument value; this should be a boolean",
));
}
}
"peripherals" => {
if let Ok(p) = input.parse::<LitBool>() {
peripherals = p.value;
@ -113,6 +127,18 @@ impl AppArgs {
));
}
}
"backend" => {
if let Ok(p) = input.parse::<BackendArgs>() {
backend = Some(p);
} else {
return Err(parse::Error::new(
ident.span(),
"unable to parse backend configuration",
));
}
}
_ => {
return Err(parse::Error::new(ident.span(), "unexpected argument"));
}
@ -134,8 +160,10 @@ impl AppArgs {
Ok(AppArgs {
device,
core,
peripherals,
dispatchers,
backend,
})
})
.parse2(tokens)