mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 12:12:50 +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::{analyze::Analysis, codegen::util};
|
||||
use crate::{
|
||||
analyze::Analysis,
|
||||
codegen::{
|
||||
bindings::{interrupt_entry, interrupt_exit},
|
||||
util,
|
||||
},
|
||||
};
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::quote;
|
||||
|
||||
|
@ -59,18 +65,25 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 {
|
|||
if level > 0 {
|
||||
let doc = format!("Interrupt handler to dispatch async tasks at priority {level}");
|
||||
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!(
|
||||
#[allow(non_snake_case)]
|
||||
#[doc = #doc]
|
||||
#[no_mangle]
|
||||
#(#attribute)*
|
||||
unsafe fn #dispatcher_name() {
|
||||
#(#entry_stmts)*
|
||||
|
||||
/// The priority of this interrupt handler
|
||||
const PRIORITY: u8 = #level;
|
||||
|
||||
rtic::export::run(PRIORITY, || {
|
||||
#(#stmts)*
|
||||
});
|
||||
|
||||
#(#exit_stmts)*
|
||||
}
|
||||
));
|
||||
} else {
|
||||
|
|
|
@ -312,3 +312,11 @@ pub fn architecture_specific_analysis(app: &App, _: &SyntaxAnalysis) -> parse::R
|
|||
|
||||
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::{
|
||||
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 quote::quote;
|
||||
|
@ -17,6 +20,8 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 {
|
|||
let priority = task.args.priority;
|
||||
let cfgs = &task.cfgs;
|
||||
let attrs = &task.attrs;
|
||||
let entry_stmts = interrupt_entry(app, analysis);
|
||||
let exit_stmts = interrupt_exit(app, analysis);
|
||||
|
||||
mod_app.push(quote!(
|
||||
#[allow(non_snake_case)]
|
||||
|
@ -24,6 +29,8 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 {
|
|||
#(#attrs)*
|
||||
#(#cfgs)*
|
||||
unsafe fn #symbol() {
|
||||
#(#entry_stmts)*
|
||||
|
||||
const PRIORITY: u8 = #priority;
|
||||
|
||||
rtic::export::run(PRIORITY, || {
|
||||
|
@ -31,6 +38,8 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 {
|
|||
#name::Context::new()
|
||||
)
|
||||
});
|
||||
|
||||
#(#exit_stmts)*
|
||||
}
|
||||
));
|
||||
|
||||
|
|
Loading…
Reference in a new issue