mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
bump rtfm-syntax
This commit is contained in:
parent
8e49af1cc0
commit
7b598c0749
31 changed files with 175 additions and 85 deletions
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ extern crate stm32f103xx;
|
||||||
|
|
||||||
use cortex_m::peripheral::{DWT, ITM};
|
use cortex_m::peripheral::{DWT, ITM};
|
||||||
use rt::ExceptionFrame;
|
use rt::ExceptionFrame;
|
||||||
use rtfm::{app, Resource};
|
use rtfm::app;
|
||||||
|
|
||||||
app! {
|
app! {
|
||||||
device: stm32f103xx,
|
device: stm32f103xx,
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,11 @@ version = "0.3.1"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
failure = "0.1.1"
|
failure = "0.1.1"
|
||||||
proc-macro2 = "0.3.6"
|
proc-macro2 = "0.4.4"
|
||||||
quote = "0.5.1"
|
quote = "0.6.3"
|
||||||
# rtfm-syntax = "0.4.0"
|
# rtfm-syntax = "0.4.0"
|
||||||
rtfm-syntax = { git = "https://github.com/japaric/rtfm-syntax", branch = "tq" }
|
rtfm-syntax = { git = "https://github.com/japaric/rtfm-syntax", branch = "tq" }
|
||||||
syn = "0.13.1"
|
syn = "0.14.1"
|
||||||
|
|
||||||
[dependencies.either]
|
[dependencies.either]
|
||||||
version = "1"
|
version = "1"
|
||||||
|
|
|
@ -13,14 +13,19 @@ pub fn app(app: &App) -> Context {
|
||||||
let mut tq = TimerQueue::new();
|
let mut tq = TimerQueue::new();
|
||||||
let mut free_interrupts = app.free_interrupts.iter().cloned().collect::<Vec<_>>();
|
let mut free_interrupts = app.free_interrupts.iter().cloned().collect::<Vec<_>>();
|
||||||
|
|
||||||
schedule_now.extend(&app.init.schedule_now);
|
schedule_now.extend(app.init.schedule_now.iter().cloned());
|
||||||
|
|
||||||
for task in &app.init.schedule_after {
|
for task in &app.init.schedule_after {
|
||||||
schedule_after.insert(*task);
|
schedule_after.insert(task.clone());
|
||||||
|
|
||||||
// Timer queue
|
// Timer queue
|
||||||
if let Entry::Vacant(entry) = tq.tasks.entry(*task) {
|
if let Entry::Vacant(entry) = tq.tasks.entry(task.clone()) {
|
||||||
tq.capacity += app.tasks[task].interrupt_or_instances.right().unwrap();
|
tq.capacity += app.tasks[task]
|
||||||
|
.interrupt_or_instances
|
||||||
|
.as_ref()
|
||||||
|
.right()
|
||||||
|
.clone()
|
||||||
|
.unwrap();
|
||||||
entry.insert(app.tasks[task].priority);
|
entry.insert(app.tasks[task].priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,28 +33,33 @@ pub fn app(app: &App) -> Context {
|
||||||
// compute dispatchers
|
// compute dispatchers
|
||||||
for (name, task) in &app.tasks {
|
for (name, task) in &app.tasks {
|
||||||
match task.interrupt_or_instances {
|
match task.interrupt_or_instances {
|
||||||
Either::Left(interrupt) => {
|
Either::Left(ref interrupt) => {
|
||||||
triggers.insert(interrupt, (*name, task.priority));
|
triggers.insert(interrupt.clone(), (name.clone(), task.priority));
|
||||||
}
|
}
|
||||||
Either::Right(instances) => {
|
Either::Right(instances) => {
|
||||||
let dispatcher = dispatchers.entry(task.priority).or_insert_with(|| {
|
let dispatcher = dispatchers.entry(task.priority).or_insert_with(|| {
|
||||||
Dispatcher::new(free_interrupts.pop().expect("not enough free interrupts"))
|
Dispatcher::new(free_interrupts.pop().expect("not enough free interrupts"))
|
||||||
});
|
});
|
||||||
dispatcher.tasks.push(*name);
|
dispatcher.tasks.push(name.clone());
|
||||||
dispatcher.capacity += instances;
|
dispatcher.capacity += instances;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for task in &task.schedule_now {
|
for task in &task.schedule_now {
|
||||||
schedule_now.insert(*task);
|
schedule_now.insert(task.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
for task in &task.schedule_after {
|
for task in &task.schedule_after {
|
||||||
schedule_after.insert(*task);
|
schedule_after.insert(task.clone());
|
||||||
|
|
||||||
// Timer queue
|
// Timer queue
|
||||||
if let Entry::Vacant(entry) = tq.tasks.entry(*task) {
|
if let Entry::Vacant(entry) = tq.tasks.entry(task.clone()) {
|
||||||
tq.capacity += app.tasks[task].interrupt_or_instances.right().unwrap();
|
tq.capacity += app.tasks[task]
|
||||||
|
.interrupt_or_instances
|
||||||
|
.as_ref()
|
||||||
|
.right()
|
||||||
|
.clone()
|
||||||
|
.unwrap();
|
||||||
entry.insert(app.tasks[task].priority);
|
entry.insert(app.tasks[task].priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +93,7 @@ pub fn app(app: &App) -> Context {
|
||||||
})) {
|
})) {
|
||||||
let ceiling = ceilings
|
let ceiling = ceilings
|
||||||
.resources
|
.resources
|
||||||
.entry(*resource)
|
.entry(resource.clone())
|
||||||
.or_insert(Ceiling::Owned(priority));
|
.or_insert(Ceiling::Owned(priority));
|
||||||
if priority > (*ceiling).into() {
|
if priority > (*ceiling).into() {
|
||||||
*ceiling = Ceiling::Shared(priority);
|
*ceiling = Ceiling::Shared(priority);
|
||||||
|
@ -101,7 +111,10 @@ pub fn app(app: &App) -> Context {
|
||||||
}) {
|
}) {
|
||||||
// schedule_now callers contend for the consumer end of the task slot queue (#task::SQ) and
|
// schedule_now callers contend for the consumer end of the task slot queue (#task::SQ) and
|
||||||
// ..
|
// ..
|
||||||
let ceiling = ceilings.slot_queues.entry(*task).or_insert(caller_priority);
|
let ceiling = ceilings
|
||||||
|
.slot_queues
|
||||||
|
.entry(task.clone())
|
||||||
|
.or_insert(caller_priority);
|
||||||
|
|
||||||
if caller_priority > *ceiling {
|
if caller_priority > *ceiling {
|
||||||
*ceiling = caller_priority;
|
*ceiling = caller_priority;
|
||||||
|
@ -128,7 +141,10 @@ pub fn app(app: &App) -> Context {
|
||||||
}) {
|
}) {
|
||||||
// schedule_after callers contend for the consumer end of the task slot queue (#task::SQ)
|
// schedule_after callers contend for the consumer end of the task slot queue (#task::SQ)
|
||||||
// and ..
|
// and ..
|
||||||
let ceiling = ceilings.slot_queues.entry(*task).or_insert(caller_priority);
|
let ceiling = ceilings
|
||||||
|
.slot_queues
|
||||||
|
.entry(task.clone())
|
||||||
|
.or_insert(caller_priority);
|
||||||
|
|
||||||
if caller_priority > *ceiling {
|
if caller_priority > *ceiling {
|
||||||
*ceiling = caller_priority;
|
*ceiling = caller_priority;
|
||||||
|
@ -209,7 +225,7 @@ impl Dispatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn interrupt(&self) -> Ident {
|
pub fn interrupt(&self) -> Ident {
|
||||||
self.interrupt
|
self.interrupt.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tasks(&self) -> &[Ident] {
|
pub fn tasks(&self) -> &[Ident] {
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
use quote::Tokens;
|
|
||||||
|
|
||||||
use either::Either;
|
use either::Either;
|
||||||
|
use proc_macro2::Span;
|
||||||
|
use proc_macro2::TokenStream;
|
||||||
use syn::Ident;
|
use syn::Ident;
|
||||||
use syntax::check::App;
|
use syntax::check::App;
|
||||||
|
|
||||||
use analyze::Context;
|
use analyze::Context;
|
||||||
|
|
||||||
pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
pub fn app(ctxt: &Context, app: &App) -> TokenStream {
|
||||||
let mut root = vec![];
|
let mut root = vec![];
|
||||||
let k = Ident::from("_rtfm");
|
let k = Ident::new("_rtfm", Span::call_site());
|
||||||
let device = &app.device;
|
let device = &app.device;
|
||||||
|
|
||||||
let needs_tq = !ctxt.schedule_after.is_empty();
|
let needs_tq = !ctxt.schedule_after.is_empty();
|
||||||
|
@ -34,7 +34,8 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
.map(|e| quote!(#e))
|
.map(|e| quote!(#e))
|
||||||
.unwrap_or_else(|| quote!(unsafe { ::#k::_impl::uninitialized() }));
|
.unwrap_or_else(|| quote!(unsafe { ::#k::_impl::uninitialized() }));
|
||||||
|
|
||||||
let ceiling = Ident::from(format!(
|
let ceiling = Ident::new(
|
||||||
|
&format!(
|
||||||
"U{}",
|
"U{}",
|
||||||
ctxt.ceilings
|
ctxt.ceilings
|
||||||
.resources()
|
.resources()
|
||||||
|
@ -42,7 +43,9 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
.cloned()
|
.cloned()
|
||||||
.map(u8::from)
|
.map(u8::from)
|
||||||
.unwrap_or(0) // 0 = resource owned by `init`
|
.unwrap_or(0) // 0 = resource owned by `init`
|
||||||
));
|
),
|
||||||
|
Span::call_site(),
|
||||||
|
);
|
||||||
root.push(quote! {
|
root.push(quote! {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe impl ::#k::Resource for _resource::#name {
|
unsafe impl ::#k::Resource for _resource::#name {
|
||||||
|
@ -183,7 +186,8 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
for (name, task) in &app.tasks {
|
for (name, task) in &app.tasks {
|
||||||
let path = &task.path;
|
let path = &task.path;
|
||||||
|
|
||||||
let lifetime = if task.resources
|
let lifetime = if task
|
||||||
|
.resources
|
||||||
.iter()
|
.iter()
|
||||||
.any(|res| ctxt.ceilings.resources()[res].is_owned())
|
.any(|res| ctxt.ceilings.resources()[res].is_owned())
|
||||||
{
|
{
|
||||||
|
@ -192,11 +196,10 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let _context = Ident::from(format!(
|
let _context = Ident::new(
|
||||||
"_ZN{}{}7ContextE",
|
&format!("_ZN{}{}7ContextE", name.to_string().as_bytes().len(), name),
|
||||||
name.as_ref().as_bytes().len(),
|
Span::call_site(),
|
||||||
name
|
);
|
||||||
));
|
|
||||||
|
|
||||||
let mut mod_ = vec![];
|
let mut mod_ = vec![];
|
||||||
|
|
||||||
|
@ -206,7 +209,8 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
quote!(scheduled_time)
|
quote!(scheduled_time)
|
||||||
};
|
};
|
||||||
|
|
||||||
let input_ = task.input
|
let input_ = task
|
||||||
|
.input
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|input| quote!(#input))
|
.map(|input| quote!(#input))
|
||||||
.unwrap_or(quote!(()));
|
.unwrap_or(quote!(()));
|
||||||
|
@ -261,7 +265,8 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let res_fields = task.resources
|
let res_fields = task
|
||||||
|
.resources
|
||||||
.iter()
|
.iter()
|
||||||
.map(|res| {
|
.map(|res| {
|
||||||
if ctxt.ceilings.resources()[res].is_owned() {
|
if ctxt.ceilings.resources()[res].is_owned() {
|
||||||
|
@ -281,7 +286,8 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let tasks_fields = task.schedule_now
|
let tasks_fields = task
|
||||||
|
.schedule_now
|
||||||
.iter()
|
.iter()
|
||||||
.map(|task| quote!(pub #task: ::_schedule_now::#task))
|
.map(|task| quote!(pub #task: ::_schedule_now::#task))
|
||||||
.chain(
|
.chain(
|
||||||
|
@ -291,7 +297,8 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
)
|
)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let tasks_exprs = task.schedule_now
|
let tasks_exprs = task
|
||||||
|
.schedule_now
|
||||||
.iter()
|
.iter()
|
||||||
.map(|task| {
|
.map(|task| {
|
||||||
if cfg!(feature = "timer-queue") {
|
if cfg!(feature = "timer-queue") {
|
||||||
|
@ -307,7 +314,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
)
|
)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let priority = Ident::from(format!("U{}", task.priority));
|
let priority = Ident::new(&format!("U{}", task.priority), Span::call_site());
|
||||||
mod_.push(quote! {
|
mod_.push(quote! {
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use ::#k::Resource;
|
use ::#k::Resource;
|
||||||
|
@ -363,9 +370,9 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
}
|
}
|
||||||
|
|
||||||
match task.interrupt_or_instances {
|
match task.interrupt_or_instances {
|
||||||
Either::Left(interrupt) => {
|
Either::Left(ref interrupt) => {
|
||||||
let export_name = interrupt.as_ref();
|
let export_name = interrupt.to_string();
|
||||||
let fn_name = Ident::from(format!("_{}", interrupt));
|
let fn_name = Ident::new(&format!("_{}", interrupt), Span::call_site());
|
||||||
|
|
||||||
let bl = if cfg!(feature = "timer-queue") {
|
let bl = if cfg!(feature = "timer-queue") {
|
||||||
Some(quote!(_now,))
|
Some(quote!(_now,))
|
||||||
|
@ -387,7 +394,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Either::Right(instances) => {
|
Either::Right(instances) => {
|
||||||
let ucapacity = Ident::from(format!("U{}", instances));
|
let ucapacity = Ident::new(&format!("U{}", instances), Span::call_site());
|
||||||
let capacity = instances as usize;
|
let capacity = instances as usize;
|
||||||
|
|
||||||
root.push(quote! {
|
root.push(quote! {
|
||||||
|
@ -408,13 +415,19 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let ceiling = Ident::from(format!(
|
let ceiling = Ident::new(
|
||||||
|
&format!(
|
||||||
"U{}",
|
"U{}",
|
||||||
ctxt.ceilings.slot_queues().get(name).cloned() // 0 = owned by init
|
ctxt.ceilings.slot_queues().get(name).cloned() // 0 = owned by init
|
||||||
.unwrap_or(0)
|
.unwrap_or(0)
|
||||||
));
|
),
|
||||||
|
Span::call_site(),
|
||||||
|
);
|
||||||
|
|
||||||
let mangled = Ident::from(format!("_ZN{}{}6PAYLOADSE", name.as_ref().len(), name));
|
let mangled = Ident::new(
|
||||||
|
&format!("_ZN{}{}6PAYLOADSE", name.to_string().len(), name),
|
||||||
|
Span::call_site(),
|
||||||
|
);
|
||||||
|
|
||||||
// NOTE must be in the root because of `#input`
|
// NOTE must be in the root because of `#input`
|
||||||
root.push(quote! {
|
root.push(quote! {
|
||||||
|
@ -459,15 +472,17 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* schedule_now */
|
/* schedule_now */
|
||||||
let schedule_now = ctxt.schedule_now
|
let schedule_now = ctxt
|
||||||
|
.schedule_now
|
||||||
.iter()
|
.iter()
|
||||||
.map(|name| {
|
.map(|name| {
|
||||||
let task = &app.tasks[name];
|
let task = &app.tasks[name];
|
||||||
let priority = task.priority;
|
let priority = task.priority;
|
||||||
let _priority = Ident::from(format!("_{}", priority));
|
let _priority = Ident::new(&format!("_{}", priority), Span::call_site());
|
||||||
let interrupt = ctxt.dispatchers[&priority].interrupt();
|
let interrupt = ctxt.dispatchers[&priority].interrupt();
|
||||||
|
|
||||||
let input_ = task.input
|
let input_ = task
|
||||||
|
.input
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|input| quote!(#input))
|
.map(|input| quote!(#input))
|
||||||
.unwrap_or(quote!(()));
|
.unwrap_or(quote!(()));
|
||||||
|
@ -477,12 +492,18 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
(quote!(), quote!(()))
|
(quote!(), quote!(()))
|
||||||
};
|
};
|
||||||
|
|
||||||
let sqc = Ident::from(format!(
|
let sqc = Ident::new(
|
||||||
|
&format!(
|
||||||
"U{}",
|
"U{}",
|
||||||
ctxt.ceilings.slot_queues().get(name).cloned() // 0 = owned by init
|
ctxt.ceilings.slot_queues().get(name).cloned() // 0 = owned by init
|
||||||
.unwrap_or(0)
|
.unwrap_or(0)
|
||||||
));
|
),
|
||||||
let qc = Ident::from(format!("U{}", ctxt.ceilings.dispatch_queues()[&priority]));
|
Span::call_site(),
|
||||||
|
);
|
||||||
|
let qc = Ident::new(
|
||||||
|
&format!("U{}", ctxt.ceilings.dispatch_queues()[&priority]),
|
||||||
|
Span::call_site(),
|
||||||
|
);
|
||||||
|
|
||||||
if cfg!(feature = "timer-queue") {
|
if cfg!(feature = "timer-queue") {
|
||||||
root.push(quote! {
|
root.push(quote! {
|
||||||
|
@ -620,18 +641,26 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
});
|
});
|
||||||
|
|
||||||
/* schedule_after */
|
/* schedule_after */
|
||||||
let schedule_after = ctxt.schedule_after
|
let schedule_after = ctxt
|
||||||
|
.schedule_after
|
||||||
.iter()
|
.iter()
|
||||||
.map(|name| {
|
.map(|name| {
|
||||||
let task = &app.tasks[name];
|
let task = &app.tasks[name];
|
||||||
|
|
||||||
let sqc = Ident::from(format!(
|
let sqc = Ident::new(
|
||||||
|
&format!(
|
||||||
"U{}",
|
"U{}",
|
||||||
ctxt.ceilings.slot_queues().get(name).unwrap_or(&0) // 0 = owned by init
|
ctxt.ceilings.slot_queues().get(name).unwrap_or(&0) // 0 = owned by init
|
||||||
));
|
),
|
||||||
let tqc = Ident::from(format!("U{}", ctxt.ceilings.timer_queue()));
|
Span::call_site(),
|
||||||
|
);
|
||||||
|
let tqc = Ident::new(
|
||||||
|
&format!("U{}", ctxt.ceilings.timer_queue()),
|
||||||
|
Span::call_site(),
|
||||||
|
);
|
||||||
|
|
||||||
let input_ = task.input
|
let input_ = task
|
||||||
|
.input
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|input| quote!(#input))
|
.map(|input| quote!(#input))
|
||||||
.unwrap_or(quote!(()));
|
.unwrap_or(quote!(()));
|
||||||
|
@ -649,7 +678,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn schedule_after<P>(
|
pub fn schedule_after<P>(
|
||||||
&self,
|
&self,
|
||||||
p: &::#k::Priority<P>,
|
_p: &::#k::Priority<P>,
|
||||||
after: u32,
|
after: u32,
|
||||||
#payload_in
|
#payload_in
|
||||||
) -> Result<(), #input_>
|
) -> Result<(), #input_>
|
||||||
|
@ -722,13 +751,17 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
|
|
||||||
/* Timer queue */
|
/* Timer queue */
|
||||||
if needs_tq {
|
if needs_tq {
|
||||||
let capacity = Ident::from(format!("U{}", ctxt.timer_queue.capacity()));
|
let capacity = Ident::new(
|
||||||
|
&format!("U{}", ctxt.timer_queue.capacity()),
|
||||||
|
Span::call_site(),
|
||||||
|
);
|
||||||
let tasks = ctxt.timer_queue.tasks().keys();
|
let tasks = ctxt.timer_queue.tasks().keys();
|
||||||
let arms = ctxt.timer_queue
|
let arms = ctxt
|
||||||
|
.timer_queue
|
||||||
.tasks()
|
.tasks()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(name, priority)| {
|
.map(|(name, priority)| {
|
||||||
let _priority = Ident::from(format!("_{}", priority));
|
let _priority = Ident::new(&format!("_{}", priority), Span::call_site());
|
||||||
let interrupt = ctxt.dispatchers[priority].interrupt();
|
let interrupt = ctxt.dispatchers[priority].interrupt();
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -743,8 +776,11 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let ceiling = Ident::from(format!("U{}", ctxt.ceilings.timer_queue()));
|
let ceiling = Ident::new(
|
||||||
let priority = Ident::from(format!("U{}", ctxt.sys_tick));
|
&format!("U{}", ctxt.ceilings.timer_queue()),
|
||||||
|
Span::call_site(),
|
||||||
|
);
|
||||||
|
let priority = Ident::new(&format!("U{}", ctxt.sys_tick), Span::call_site());
|
||||||
root.push(quote! {
|
root.push(quote! {
|
||||||
mod _tq {
|
mod _tq {
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
|
@ -800,10 +836,13 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
|
|
||||||
/* Dispatchers */
|
/* Dispatchers */
|
||||||
for (priority, dispatcher) in &ctxt.dispatchers {
|
for (priority, dispatcher) in &ctxt.dispatchers {
|
||||||
let _priority = Ident::from(format!("_{}", priority));
|
let _priority = Ident::new(&format!("_{}", priority), Span::call_site());
|
||||||
let capacity = Ident::from(format!("U{}", dispatcher.capacity()));
|
let capacity = Ident::new(&format!("U{}", dispatcher.capacity()), Span::call_site());
|
||||||
let tasks = dispatcher.tasks();
|
let tasks = dispatcher.tasks();
|
||||||
let ceiling = Ident::from(format!("U{}", ctxt.ceilings.dispatch_queues()[priority]));
|
let ceiling = Ident::new(
|
||||||
|
&format!("U{}", ctxt.ceilings.dispatch_queues()[priority]),
|
||||||
|
Span::call_site(),
|
||||||
|
);
|
||||||
|
|
||||||
root.push(quote! {
|
root.push(quote! {
|
||||||
mod #_priority {
|
mod #_priority {
|
||||||
|
@ -873,8 +912,8 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let interrupt = dispatcher.interrupt();
|
let interrupt = dispatcher.interrupt();
|
||||||
let export_name = interrupt.as_ref();
|
let export_name = interrupt.to_string();
|
||||||
let fn_name = Ident::from(format!("_{}", export_name));
|
let fn_name = Ident::new(&format!("_{}", export_name), Span::call_site());
|
||||||
root.push(quote! {
|
root.push(quote! {
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
@ -956,7 +995,8 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
let res_fields = app.init
|
let res_fields = app
|
||||||
|
.init
|
||||||
.resources
|
.resources
|
||||||
.iter()
|
.iter()
|
||||||
.map(|r| {
|
.map(|r| {
|
||||||
|
@ -968,13 +1008,15 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let res_exprs = app.init
|
let res_exprs = app
|
||||||
|
.init
|
||||||
.resources
|
.resources
|
||||||
.iter()
|
.iter()
|
||||||
.map(|r| quote!(#r: #r::_new()))
|
.map(|r| quote!(#r: #r::_new()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let tasks_fields = app.init
|
let tasks_fields = app
|
||||||
|
.init
|
||||||
.schedule_now
|
.schedule_now
|
||||||
.iter()
|
.iter()
|
||||||
.map(|task| quote!(pub #task: ::_schedule_now::#task))
|
.map(|task| quote!(pub #task: ::_schedule_now::#task))
|
||||||
|
@ -986,7 +1028,8 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
)
|
)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let tasks_exprs = app.init
|
let tasks_exprs = app
|
||||||
|
.init
|
||||||
.schedule_now
|
.schedule_now
|
||||||
.iter()
|
.iter()
|
||||||
.map(|task| {
|
.map(|task| {
|
||||||
|
@ -1004,7 +1047,8 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
)
|
)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let late_resources = app.resources
|
let late_resources = app
|
||||||
|
.resources
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(name, res)| {
|
.filter_map(|(name, res)| {
|
||||||
if res.expr.is_none() && !app.init.resources.contains(name) {
|
if res.expr.is_none() && !app.init.resources.contains(name) {
|
||||||
|
@ -1158,7 +1202,8 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
|
|
||||||
/* idle */
|
/* idle */
|
||||||
if let Some(idle) = app.idle.as_ref() {
|
if let Some(idle) = app.idle.as_ref() {
|
||||||
let res_fields = idle.resources
|
let res_fields = idle
|
||||||
|
.resources
|
||||||
.iter()
|
.iter()
|
||||||
.map(|res| {
|
.map(|res| {
|
||||||
if ctxt.ceilings.resources()[res].is_owned() {
|
if ctxt.ceilings.resources()[res].is_owned() {
|
||||||
|
@ -1171,7 +1216,8 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let res_exprs = idle.resources
|
let res_exprs = idle
|
||||||
|
.resources
|
||||||
.iter()
|
.iter()
|
||||||
.map(|res| {
|
.map(|res| {
|
||||||
if ctxt.ceilings.resources()[res].is_owned() {
|
if ctxt.ceilings.resources()[res].is_owned() {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
#![feature(proc_macro_gen)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue