mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
Added support for adding codegen to intrrupt entry and exit (needed for RISC-V)
This commit is contained in:
parent
b9e0f36aff
commit
e8cebff69e
3 changed files with 32 additions and 2 deletions
|
@ -1,5 +1,11 @@
|
||||||
use crate::syntax::ast::App;
|
use crate::syntax::ast::App;
|
||||||
use crate::{analyze::Analysis, codegen::util};
|
use crate::{
|
||||||
|
analyze::Analysis,
|
||||||
|
codegen::{
|
||||||
|
bindings::{interrupt_entry, interrupt_exit},
|
||||||
|
util,
|
||||||
|
},
|
||||||
|
};
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
|
|
||||||
|
@ -59,18 +65,25 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 {
|
||||||
if level > 0 {
|
if level > 0 {
|
||||||
let doc = format!("Interrupt handler to dispatch async tasks at priority {level}");
|
let doc = format!("Interrupt handler to dispatch async tasks at priority {level}");
|
||||||
let attribute = &interrupts.get(&level).expect("UNREACHABLE").1.attrs;
|
let attribute = &interrupts.get(&level).expect("UNREACHABLE").1.attrs;
|
||||||
|
let entry_stmts = interrupt_entry(app, analysis);
|
||||||
|
let exit_stmts = interrupt_exit(app, analysis);
|
||||||
|
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[doc = #doc]
|
#[doc = #doc]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#(#attribute)*
|
#(#attribute)*
|
||||||
unsafe fn #dispatcher_name() {
|
unsafe fn #dispatcher_name() {
|
||||||
|
#(#entry_stmts)*
|
||||||
|
|
||||||
/// The priority of this interrupt handler
|
/// The priority of this interrupt handler
|
||||||
const PRIORITY: u8 = #level;
|
const PRIORITY: u8 = #level;
|
||||||
|
|
||||||
rtic::export::run(PRIORITY, || {
|
rtic::export::run(PRIORITY, || {
|
||||||
#(#stmts)*
|
#(#stmts)*
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#(#exit_stmts)*
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -312,3 +312,11 @@ pub fn architecture_specific_analysis(app: &App, _: &SyntaxAnalysis) -> parse::R
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn interrupt_entry(_app: &App, _analysis: &CodegenAnalysis) -> Vec<TokenStream2> {
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn interrupt_exit(_app: &App, _analysis: &CodegenAnalysis) -> Vec<TokenStream2> {
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
use crate::syntax::{ast::App, Context};
|
use crate::syntax::{ast::App, Context};
|
||||||
use crate::{
|
use crate::{
|
||||||
analyze::Analysis,
|
analyze::Analysis,
|
||||||
codegen::{local_resources_struct, module, shared_resources_struct},
|
codegen::{
|
||||||
|
bindings::{interrupt_entry, interrupt_exit},
|
||||||
|
local_resources_struct, module, shared_resources_struct,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
|
@ -17,6 +20,8 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 {
|
||||||
let priority = task.args.priority;
|
let priority = task.args.priority;
|
||||||
let cfgs = &task.cfgs;
|
let cfgs = &task.cfgs;
|
||||||
let attrs = &task.attrs;
|
let attrs = &task.attrs;
|
||||||
|
let entry_stmts = interrupt_entry(app, analysis);
|
||||||
|
let exit_stmts = interrupt_exit(app, analysis);
|
||||||
|
|
||||||
mod_app.push(quote!(
|
mod_app.push(quote!(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
@ -24,6 +29,8 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 {
|
||||||
#(#attrs)*
|
#(#attrs)*
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
unsafe fn #symbol() {
|
unsafe fn #symbol() {
|
||||||
|
#(#entry_stmts)*
|
||||||
|
|
||||||
const PRIORITY: u8 = #priority;
|
const PRIORITY: u8 = #priority;
|
||||||
|
|
||||||
rtic::export::run(PRIORITY, || {
|
rtic::export::run(PRIORITY, || {
|
||||||
|
@ -31,6 +38,8 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 {
|
||||||
#name::Context::new()
|
#name::Context::new()
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#(#exit_stmts)*
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue