mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-16 21:05:35 +01:00
Prepare for new riscv ecosystem
This commit is contained in:
parent
bac77de9bc
commit
183e73904a
14 changed files with 164 additions and 134 deletions
|
|
@ -40,6 +40,8 @@ riscv-esp32c3 = []
|
|||
# riscv-clic = []
|
||||
# riscv-ch32 = []
|
||||
riscv-slic = []
|
||||
riscv-clint = ["riscv-slic"]
|
||||
riscv-mecall= ["riscv-slic"]
|
||||
|
||||
# backend API test
|
||||
test-template = []
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use syn::{parse, Attribute, Ident};
|
|||
/// Utility function to get the SLIC interrupt module.
|
||||
pub fn interrupt_ident() -> Ident {
|
||||
let span = Span::call_site();
|
||||
Ident::new("Interrupt", span)
|
||||
Ident::new("SoftwareInterrupt", span)
|
||||
}
|
||||
|
||||
pub fn interrupt_mod(_app: &App) -> TokenStream2 {
|
||||
|
|
@ -119,7 +119,7 @@ pub fn pre_init_enable_interrupts(app: &App, analysis: &CodegenAnalysis) -> Vec<
|
|||
.map(|task| (&task.args.priority, &task.args.binds)),
|
||||
) {
|
||||
stmts.push(quote!(
|
||||
rtic::export::set_priority(slic::Interrupt::#name, #p);
|
||||
rtic::export::set_priority(slic::SoftwareInterrupt::#name, #p);
|
||||
));
|
||||
}
|
||||
// Finally, we activate the interrupts
|
||||
|
|
@ -153,11 +153,11 @@ pub fn architecture_specific_analysis(app: &App, _analysis: &SyntaxAnalysis) ->
|
|||
|
||||
return Err(parse::Error::new(first.unwrap().span(), s));
|
||||
}
|
||||
|
||||
#[cfg(feature = "riscv-clint")]
|
||||
if app.args.backend.is_none() {
|
||||
return Err(parse::Error::new(
|
||||
Span::call_site(),
|
||||
"SLIC requires backend-specific configuration",
|
||||
"CLINT requires backend-specific configuration",
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -247,9 +247,19 @@ pub fn extra_modules(app: &App, _analysis: &SyntaxAnalysis) -> Vec<TokenStream2>
|
|||
stmts.push(quote!(
|
||||
use rtic::export::riscv_slic;
|
||||
));
|
||||
let hart_id = &app.args.backend.as_ref().unwrap().hart_id;
|
||||
let slic = quote! {rtic::export::riscv_slic};
|
||||
|
||||
stmts.push(quote!(rtic::export::codegen!(pac = #device, swi = [#(#swi_slice,)*], backend = [hart_id = #hart_id]);));
|
||||
match () {
|
||||
#[cfg(feature = "riscv-clint")]
|
||||
() => {
|
||||
let hart_id = &app.args.backend.as_ref().unwrap().hart_id;
|
||||
stmts.push(quote!(rtic::export::codegen!(slic = #slic, pac = #device, swi = [#(#swi_slice,)*], backend = [hart_id = #hart_id]);));
|
||||
}
|
||||
#[cfg(feature = "riscv-mecall")]
|
||||
() => {
|
||||
stmts.push(quote!(rtic::export::codegen!(slic = #slic, pac = #device, swi = [#(#swi_slice,)*]);));
|
||||
}
|
||||
}
|
||||
|
||||
stmts
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,27 @@
|
|||
use syn::{
|
||||
parse::{Parse, ParseStream},
|
||||
Ident, Result,
|
||||
Result,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct BackendArgs {
|
||||
pub hart_id: Ident,
|
||||
#[cfg(feature = "riscv-clint")]
|
||||
pub hart_id: syn::Ident,
|
||||
}
|
||||
|
||||
impl Parse for BackendArgs {
|
||||
fn parse(input: ParseStream) -> Result<Self> {
|
||||
let hart_id = input.parse()?;
|
||||
Ok(BackendArgs { hart_id })
|
||||
match () {
|
||||
#[cfg(feature = "riscv-clint")]
|
||||
() => {
|
||||
let hart_id = input.parse()?;
|
||||
Ok(BackendArgs { hart_id })
|
||||
}
|
||||
#[cfg(feature = "riscv-mecall")]
|
||||
() => Err(syn::Error::new(
|
||||
input.span(),
|
||||
"riscv-mecall backend does not accept any arguments",
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue