From 183e73904a5d14e29f8a7edbb2d9553dddb736af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rom=C3=A1n=20C=C3=A1rdenas=20Rodr=C3=ADguez?= Date: Wed, 23 Oct 2024 18:50:12 +0200 Subject: Prepare for new riscv ecosystem --- rtic-macros/src/codegen/bindings/riscv_slic.rs | 22 ++++++++++++++++------ rtic-macros/src/syntax/backend/riscv_slic.rs | 19 +++++++++++++++---- 2 files changed, 31 insertions(+), 10 deletions(-) (limited to 'rtic-macros/src') diff --git a/rtic-macros/src/codegen/bindings/riscv_slic.rs b/rtic-macros/src/codegen/bindings/riscv_slic.rs index c9bf50a..f2dc9ed 100644 --- a/rtic-macros/src/codegen/bindings/riscv_slic.rs +++ b/rtic-macros/src/codegen/bindings/riscv_slic.rs @@ -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 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 } diff --git a/rtic-macros/src/syntax/backend/riscv_slic.rs b/rtic-macros/src/syntax/backend/riscv_slic.rs index 2ed8e77..b579b01 100644 --- a/rtic-macros/src/syntax/backend/riscv_slic.rs +++ b/rtic-macros/src/syntax/backend/riscv_slic.rs @@ -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 { - 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", + )), + } } } -- cgit v1.2.3