mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-25 21:19:35 +01:00
WIP
This commit is contained in:
parent
df4a7fd3e5
commit
be92041a59
13 changed files with 115 additions and 23 deletions
5
build.rs
5
build.rs
|
@ -7,7 +7,10 @@ fn main() {
|
||||||
println!("cargo:rustc-cfg=armv6m")
|
println!("cargo:rustc-cfg=armv6m")
|
||||||
}
|
}
|
||||||
|
|
||||||
if target.starts_with("thumbv7m") | target.starts_with("thumbv7em") {
|
if target.starts_with("thumbv7m")
|
||||||
|
| target.starts_with("thumbv7em")
|
||||||
|
| target.starts_with("thumbv8m")
|
||||||
|
{
|
||||||
println!("cargo:rustc-cfg=armv7m")
|
println!("cargo:rustc-cfg=armv7m")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,10 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||||
|
|
||||||
let cfg_core = util::cfg_core(core, app.args.cores);
|
let cfg_core = util::cfg_core(core, app.args.cores);
|
||||||
let main = util::suffixed("main", core);
|
let main = util::suffixed("main", core);
|
||||||
|
let section = util::link_section("text", core);
|
||||||
mains.push(quote!(
|
mains.push(quote!(
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
#section
|
||||||
#cfg_core
|
#cfg_core
|
||||||
unsafe extern "C" fn #main() -> ! {
|
unsafe extern "C" fn #main() -> ! {
|
||||||
#(#assertion_stmts)*
|
#(#assertion_stmts)*
|
||||||
|
|
|
@ -46,13 +46,14 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
|
|
||||||
let n = util::capacity_typenum(channel.capacity, true);
|
let n = util::capacity_typenum(channel.capacity, true);
|
||||||
let rq = util::rq_ident(receiver, level, sender);
|
let rq = util::rq_ident(receiver, level, sender);
|
||||||
let (rq_attr, rq_ty, rq_expr) = if sender == receiver {
|
let (rq_attr, rq_ty, rq_expr, section) = if sender == receiver {
|
||||||
(
|
(
|
||||||
cfg_sender.clone(),
|
cfg_sender.clone(),
|
||||||
quote!(rtfm::export::SCRQ<#t, #n>),
|
quote!(rtfm::export::SCRQ<#t, #n>),
|
||||||
quote!(rtfm::export::Queue(unsafe {
|
quote!(rtfm::export::Queue(unsafe {
|
||||||
rtfm::export::iQueue::u8_sc()
|
rtfm::export::iQueue::u8_sc()
|
||||||
})),
|
})),
|
||||||
|
util::link_section("bss", sender),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let shared = if cfg!(feature = "heterogeneous") {
|
let shared = if cfg!(feature = "heterogeneous") {
|
||||||
|
@ -65,6 +66,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
shared,
|
shared,
|
||||||
quote!(rtfm::export::MCRQ<#t, #n>),
|
quote!(rtfm::export::MCRQ<#t, #n>),
|
||||||
quote!(rtfm::export::Queue(rtfm::export::iQueue::u8())),
|
quote!(rtfm::export::Queue(rtfm::export::iQueue::u8())),
|
||||||
|
None,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,6 +79,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#[doc = #doc]
|
#[doc = #doc]
|
||||||
#rq_attr
|
#rq_attr
|
||||||
|
#section
|
||||||
static mut #rq: #rq_ty = #rq_expr;
|
static mut #rq: #rq_ty = #rq_expr;
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -162,12 +165,14 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
receiver, level
|
receiver, level
|
||||||
);
|
);
|
||||||
let cfg_receiver = util::cfg_core(receiver, app.args.cores);
|
let cfg_receiver = util::cfg_core(receiver, app.args.cores);
|
||||||
|
let section = util::link_section("text", receiver);
|
||||||
let interrupt = util::suffixed(&interrupts[&level].to_string(), receiver);
|
let interrupt = util::suffixed(&interrupts[&level].to_string(), receiver);
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[doc = #doc]
|
#[doc = #doc]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#cfg_receiver
|
#cfg_receiver
|
||||||
|
#section
|
||||||
unsafe fn #interrupt() {
|
unsafe fn #interrupt() {
|
||||||
/// The priority of this interrupt handler
|
/// The priority of this interrupt handler
|
||||||
const PRIORITY: u8 = #level;
|
const PRIORITY: u8 = #level;
|
||||||
|
|
|
@ -56,9 +56,11 @@ pub fn codegen(
|
||||||
};
|
};
|
||||||
let priority = task.args.priority;
|
let priority = task.args.priority;
|
||||||
|
|
||||||
|
let section = util::link_section("text", core);
|
||||||
const_app.push(quote!(
|
const_app.push(quote!(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
#section
|
||||||
#cfg_core
|
#cfg_core
|
||||||
unsafe fn #symbol() {
|
unsafe fn #symbol() {
|
||||||
const PRIORITY: u8 = #priority;
|
const PRIORITY: u8 = #priority;
|
||||||
|
@ -101,7 +103,8 @@ pub fn codegen(
|
||||||
// `${task}Locals`
|
// `${task}Locals`
|
||||||
let mut locals_pat = None;
|
let mut locals_pat = None;
|
||||||
if !task.locals.is_empty() {
|
if !task.locals.is_empty() {
|
||||||
let (struct_, pat) = locals::codegen(Context::HardwareTask(name), &task.locals, app);
|
let (struct_, pat) =
|
||||||
|
locals::codegen(Context::HardwareTask(name), &task.locals, core, app);
|
||||||
|
|
||||||
root.push(struct_);
|
root.push(struct_);
|
||||||
locals_pat = Some(pat);
|
locals_pat = Some(pat);
|
||||||
|
@ -110,9 +113,12 @@ pub fn codegen(
|
||||||
let attrs = &task.attrs;
|
let attrs = &task.attrs;
|
||||||
let context = &task.context;
|
let context = &task.context;
|
||||||
let stmts = &task.stmts;
|
let stmts = &task.stmts;
|
||||||
|
let section = util::link_section("text", core);
|
||||||
|
// XXX shouldn't this have a cfg_core?
|
||||||
user_tasks.push(quote!(
|
user_tasks.push(quote!(
|
||||||
#(#attrs)*
|
#(#attrs)*
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
#section
|
||||||
fn #name(#(#locals_pat,)* #context: #name::Context) {
|
fn #name(#(#locals_pat,)* #context: #name::Context) {
|
||||||
use rtfm::Mutex as _;
|
use rtfm::Mutex as _;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ pub fn codegen(
|
||||||
|
|
||||||
let name = &idle.name;
|
let name = &idle.name;
|
||||||
if !idle.locals.is_empty() {
|
if !idle.locals.is_empty() {
|
||||||
let (locals, pat) = locals::codegen(Context::Idle(core), &idle.locals, app);
|
let (locals, pat) = locals::codegen(Context::Idle(core), &idle.locals, core, app);
|
||||||
|
|
||||||
locals_new = Some(quote!(#name::Locals::new()));
|
locals_new = Some(quote!(#name::Locals::new()));
|
||||||
locals_pat = Some(pat);
|
locals_pat = Some(pat);
|
||||||
|
@ -57,10 +57,12 @@ pub fn codegen(
|
||||||
let attrs = &idle.attrs;
|
let attrs = &idle.attrs;
|
||||||
let context = &idle.context;
|
let context = &idle.context;
|
||||||
let stmts = &idle.stmts;
|
let stmts = &idle.stmts;
|
||||||
|
let section = util::link_section("text", core);
|
||||||
let user_idle = Some(quote!(
|
let user_idle = Some(quote!(
|
||||||
#cfg_core
|
|
||||||
#(#attrs)*
|
#(#attrs)*
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
#cfg_core
|
||||||
|
#section
|
||||||
fn #name(#(#locals_pat,)* #context: #name::Context) -> ! {
|
fn #name(#(#locals_pat,)* #context: #name::Context) -> ! {
|
||||||
use rtfm::Mutex as _;
|
use rtfm::Mutex as _;
|
||||||
|
|
||||||
|
@ -73,12 +75,7 @@ pub fn codegen(
|
||||||
#name::Context::new(&rtfm::export::Priority::new(0))
|
#name::Context::new(&rtfm::export::Priority::new(0))
|
||||||
));
|
));
|
||||||
|
|
||||||
(
|
(const_app, root_idle, user_idle, call_idle)
|
||||||
const_app,
|
|
||||||
root_idle,
|
|
||||||
user_idle,
|
|
||||||
call_idle,
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -72,7 +72,7 @@ pub fn codegen(
|
||||||
let mut locals_pat = None;
|
let mut locals_pat = None;
|
||||||
let mut locals_new = None;
|
let mut locals_new = None;
|
||||||
if !init.locals.is_empty() {
|
if !init.locals.is_empty() {
|
||||||
let (struct_, pat) = locals::codegen(Context::Init(core), &init.locals, app);
|
let (struct_, pat) = locals::codegen(Context::Init(core), &init.locals, core, app);
|
||||||
|
|
||||||
locals_new = Some(quote!(#name::Locals::new()));
|
locals_new = Some(quote!(#name::Locals::new()));
|
||||||
locals_pat = Some(pat);
|
locals_pat = Some(pat);
|
||||||
|
@ -82,10 +82,12 @@ pub fn codegen(
|
||||||
let context = &init.context;
|
let context = &init.context;
|
||||||
let attrs = &init.attrs;
|
let attrs = &init.attrs;
|
||||||
let stmts = &init.stmts;
|
let stmts = &init.stmts;
|
||||||
|
let section = util::link_section("text", core);
|
||||||
let user_init = Some(quote!(
|
let user_init = Some(quote!(
|
||||||
#(#attrs)*
|
#(#attrs)*
|
||||||
#cfg_core
|
#cfg_core
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
#section
|
||||||
fn #name(#(#locals_pat,)* #context: #name::Context) #ret {
|
fn #name(#(#locals_pat,)* #context: #name::Context) #ret {
|
||||||
#(#stmts)*
|
#(#stmts)*
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use rtfm_syntax::{
|
use rtfm_syntax::{
|
||||||
ast::{App, Local},
|
ast::{App, Local},
|
||||||
Context, Map,
|
Context, Core, Map,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::codegen::util;
|
use crate::codegen::util;
|
||||||
|
@ -10,6 +10,7 @@ use crate::codegen::util;
|
||||||
pub fn codegen(
|
pub fn codegen(
|
||||||
ctxt: Context,
|
ctxt: Context,
|
||||||
locals: &Map<Local>,
|
locals: &Map<Local>,
|
||||||
|
core: Core,
|
||||||
app: &App,
|
app: &App,
|
||||||
) -> (
|
) -> (
|
||||||
// locals
|
// locals
|
||||||
|
@ -41,6 +42,7 @@ pub fn codegen(
|
||||||
let cfgs = &local.cfgs;
|
let cfgs = &local.cfgs;
|
||||||
has_cfgs |= !cfgs.is_empty();
|
has_cfgs |= !cfgs.is_empty();
|
||||||
|
|
||||||
|
let section = util::link_section("data", core);
|
||||||
let expr = &local.expr;
|
let expr = &local.expr;
|
||||||
let ty = &local.ty;
|
let ty = &local.ty;
|
||||||
fields.push(quote!(
|
fields.push(quote!(
|
||||||
|
@ -49,6 +51,7 @@ pub fn codegen(
|
||||||
));
|
));
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
|
#section
|
||||||
static mut #name: #ty = #expr
|
static mut #name: #ty = #expr
|
||||||
));
|
));
|
||||||
values.push(quote!(
|
values.push(quote!(
|
||||||
|
|
|
@ -26,20 +26,24 @@ pub fn codegen(
|
||||||
let ty = &res.ty;
|
let ty = &res.ty;
|
||||||
|
|
||||||
{
|
{
|
||||||
let loc_attr = match loc {
|
let (loc_attr, section) = match loc {
|
||||||
Location::Owned {
|
Location::Owned {
|
||||||
core,
|
core,
|
||||||
cross_initialized: false,
|
cross_initialized: false,
|
||||||
} => util::cfg_core(*core, app.args.cores),
|
} => (
|
||||||
|
util::cfg_core(*core, app.args.cores),
|
||||||
|
util::link_section("data", *core),
|
||||||
|
),
|
||||||
|
|
||||||
// shared `static`s and cross-initialized resources need to be in `.shared` memory
|
// shared `static`s and cross-initialized resources need to be in `.shared` memory
|
||||||
_ => {
|
_ => (
|
||||||
if cfg!(feature = "heterogeneous") {
|
if cfg!(feature = "heterogeneous") {
|
||||||
Some(quote!(#[rtfm::export::shared]))
|
Some(quote!(#[rtfm::export::shared]))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
},
|
||||||
}
|
None,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (ty, expr) = if let Some(expr) = expr {
|
let (ty, expr) = if let Some(expr) = expr {
|
||||||
|
@ -53,9 +57,10 @@ pub fn codegen(
|
||||||
|
|
||||||
let attrs = &res.attrs;
|
let attrs = &res.attrs;
|
||||||
const_app.push(quote!(
|
const_app.push(quote!(
|
||||||
#loc_attr
|
|
||||||
#(#attrs)*
|
#(#attrs)*
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
|
#loc_attr
|
||||||
|
#section
|
||||||
static mut #name: #ty = #expr;
|
static mut #name: #ty = #expr;
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,10 @@ pub fn codegen(app: &App, extra: &Extra) -> Vec<TokenStream2> {
|
||||||
|
|
||||||
let body = schedule_body::codegen(scheduler, &name, app);
|
let body = schedule_body::codegen(scheduler, &name, app);
|
||||||
|
|
||||||
|
let section = util::link_section("text", sender);
|
||||||
methods.push(quote!(
|
methods.push(quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
|
#section
|
||||||
fn #name(&self, instant: #instant #(,#args)*) -> Result<(), #ty> {
|
fn #name(&self, instant: #instant #(,#args)*) -> Result<(), #ty> {
|
||||||
#body
|
#body
|
||||||
}
|
}
|
||||||
|
@ -50,9 +52,11 @@ pub fn codegen(app: &App, extra: &Extra) -> Vec<TokenStream2> {
|
||||||
|
|
||||||
let body = schedule_body::codegen(scheduler, &name, app);
|
let body = schedule_body::codegen(scheduler, &name, app);
|
||||||
|
|
||||||
|
let section = util::link_section("text", sender);
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#cfg_sender
|
#cfg_sender
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
|
#section
|
||||||
unsafe fn #schedule(
|
unsafe fn #schedule(
|
||||||
priority: &rtfm::export::Priority,
|
priority: &rtfm::export::Priority,
|
||||||
instant: #instant
|
instant: #instant
|
||||||
|
|
|
@ -43,13 +43,21 @@ pub fn codegen(
|
||||||
let cfg_sender = util::cfg_core(sender, app.args.cores);
|
let cfg_sender = util::cfg_core(sender, app.args.cores);
|
||||||
let fq = util::fq_ident(name, sender);
|
let fq = util::fq_ident(name, sender);
|
||||||
|
|
||||||
let (loc, fq_ty, fq_expr) = if receiver == sender {
|
let (loc, fq_ty, fq_expr, bss, mk_uninit): (
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
Box<dyn Fn() -> Option<_>>,
|
||||||
|
) = if receiver == sender {
|
||||||
(
|
(
|
||||||
cfg_sender.clone(),
|
cfg_sender.clone(),
|
||||||
quote!(rtfm::export::SCFQ<#cap_ty>),
|
quote!(rtfm::export::SCFQ<#cap_ty>),
|
||||||
quote!(rtfm::export::Queue(unsafe {
|
quote!(rtfm::export::Queue(unsafe {
|
||||||
rtfm::export::iQueue::u8_sc()
|
rtfm::export::iQueue::u8_sc()
|
||||||
})),
|
})),
|
||||||
|
util::link_section("bss", sender),
|
||||||
|
Box::new(|| util::link_section_uninit(Some(sender))),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let shared = if cfg!(feature = "heterogeneous") {
|
let shared = if cfg!(feature = "heterogeneous") {
|
||||||
|
@ -62,6 +70,8 @@ pub fn codegen(
|
||||||
shared,
|
shared,
|
||||||
quote!(rtfm::export::MCFQ<#cap_ty>),
|
quote!(rtfm::export::MCFQ<#cap_ty>),
|
||||||
quote!(rtfm::export::Queue(rtfm::export::iQueue::u8())),
|
quote!(rtfm::export::Queue(rtfm::export::iQueue::u8())),
|
||||||
|
None,
|
||||||
|
Box::new(|| util::link_section_uninit(None)),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
let loc = &loc;
|
let loc = &loc;
|
||||||
|
@ -70,6 +80,7 @@ pub fn codegen(
|
||||||
/// Queue version of a free-list that keeps track of empty slots in
|
/// Queue version of a free-list that keeps track of empty slots in
|
||||||
/// the following buffers
|
/// the following buffers
|
||||||
#loc
|
#loc
|
||||||
|
#bss
|
||||||
static mut #fq: #fq_ty = #fq_expr;
|
static mut #fq: #fq_ty = #fq_expr;
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -102,8 +113,10 @@ pub fn codegen(
|
||||||
let m = extra.monotonic();
|
let m = extra.monotonic();
|
||||||
let instants = util::instants_ident(name, sender);
|
let instants = util::instants_ident(name, sender);
|
||||||
|
|
||||||
|
let uninit = mk_uninit();
|
||||||
const_app.push(quote!(
|
const_app.push(quote!(
|
||||||
#loc
|
#loc
|
||||||
|
#uninit
|
||||||
/// Buffer that holds the instants associated to the inputs of a task
|
/// Buffer that holds the instants associated to the inputs of a task
|
||||||
static mut #instants:
|
static mut #instants:
|
||||||
[core::mem::MaybeUninit<<#m as rtfm::Monotonic>::Instant>; #cap_lit] =
|
[core::mem::MaybeUninit<<#m as rtfm::Monotonic>::Instant>; #cap_lit] =
|
||||||
|
@ -111,9 +124,11 @@ pub fn codegen(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let uninit = mk_uninit();
|
||||||
let inputs = util::inputs_ident(name, sender);
|
let inputs = util::inputs_ident(name, sender);
|
||||||
const_app.push(quote!(
|
const_app.push(quote!(
|
||||||
#loc
|
#loc
|
||||||
|
#uninit
|
||||||
/// Buffer that holds the inputs of a task
|
/// Buffer that holds the inputs of a task
|
||||||
static mut #inputs: [core::mem::MaybeUninit<#input_ty>; #cap_lit] =
|
static mut #inputs: [core::mem::MaybeUninit<#input_ty>; #cap_lit] =
|
||||||
[#(#elems,)*];
|
[#(#elems,)*];
|
||||||
|
@ -140,13 +155,15 @@ pub fn codegen(
|
||||||
// `${task}Locals`
|
// `${task}Locals`
|
||||||
let mut locals_pat = None;
|
let mut locals_pat = None;
|
||||||
if !task.locals.is_empty() {
|
if !task.locals.is_empty() {
|
||||||
let (struct_, pat) = locals::codegen(Context::SoftwareTask(name), &task.locals, app);
|
let (struct_, pat) =
|
||||||
|
locals::codegen(Context::SoftwareTask(name), &task.locals, receiver, app);
|
||||||
|
|
||||||
locals_pat = Some(pat);
|
locals_pat = Some(pat);
|
||||||
root.push(struct_);
|
root.push(struct_);
|
||||||
}
|
}
|
||||||
|
|
||||||
let cfg_receiver = util::cfg_core(receiver, app.args.cores);
|
let cfg_receiver = util::cfg_core(receiver, app.args.cores);
|
||||||
|
let section = util::link_section("text", receiver);
|
||||||
let context = &task.context;
|
let context = &task.context;
|
||||||
let attrs = &task.attrs;
|
let attrs = &task.attrs;
|
||||||
let cfgs = &task.cfgs;
|
let cfgs = &task.cfgs;
|
||||||
|
@ -154,8 +171,9 @@ pub fn codegen(
|
||||||
user_tasks.push(quote!(
|
user_tasks.push(quote!(
|
||||||
#(#attrs)*
|
#(#attrs)*
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
#cfg_receiver
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
#cfg_receiver
|
||||||
|
#section
|
||||||
fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) {
|
fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) {
|
||||||
use rtfm::Mutex as _;
|
use rtfm::Mutex as _;
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,10 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let section = util::link_section("text", sender);
|
||||||
methods.push(quote!(
|
methods.push(quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
|
#section
|
||||||
fn #name(&self #(,#args)*) -> Result<(), #ty> {
|
fn #name(&self #(,#args)*) -> Result<(), #ty> {
|
||||||
#let_instant
|
#let_instant
|
||||||
#body
|
#body
|
||||||
|
@ -66,9 +68,11 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
|
|
||||||
let body = spawn_body::codegen(spawner, &name, app, analysis, extra);
|
let body = spawn_body::codegen(spawner, &name, app, analysis, extra);
|
||||||
|
|
||||||
|
let section = util::link_section("text", sender);
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#cfg_sender
|
#cfg_sender
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
|
#section
|
||||||
unsafe fn #spawn(
|
unsafe fn #spawn(
|
||||||
priority: &rtfm::export::Priority
|
priority: &rtfm::export::Priority
|
||||||
#instant
|
#instant
|
||||||
|
|
|
@ -48,9 +48,11 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
let n = util::capacity_typenum(timer_queue.capacity, false);
|
let n = util::capacity_typenum(timer_queue.capacity, false);
|
||||||
let tq_ty = quote!(rtfm::export::TimerQueue<#m, #t, #n>);
|
let tq_ty = quote!(rtfm::export::TimerQueue<#m, #t, #n>);
|
||||||
|
|
||||||
|
let section = util::link_section("bss", sender);
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#cfg_sender
|
#cfg_sender
|
||||||
#[doc = #doc]
|
#[doc = #doc]
|
||||||
|
#section
|
||||||
static mut #tq: #tq_ty = rtfm::export::TimerQueue(
|
static mut #tq: #tq_ty = rtfm::export::TimerQueue(
|
||||||
rtfm::export::BinaryHeap(
|
rtfm::export::BinaryHeap(
|
||||||
rtfm::export::iBinaryHeap::new()
|
rtfm::export::iBinaryHeap::new()
|
||||||
|
@ -117,9 +119,11 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
|
|
||||||
let priority = timer_queue.priority;
|
let priority = timer_queue.priority;
|
||||||
let sys_tick = util::suffixed("SysTick", sender);
|
let sys_tick = util::suffixed("SysTick", sender);
|
||||||
|
let section = util::link_section("text", sender);
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#cfg_sender
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
#cfg_sender
|
||||||
|
#section
|
||||||
unsafe fn #sys_tick() {
|
unsafe fn #sys_tick() {
|
||||||
use rtfm::Mutex as _;
|
use rtfm::Mutex as _;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
use proc_macro2::{Span, TokenStream as TokenStream2};
|
use proc_macro2::{Span, TokenStream as TokenStream2};
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use rtfm_syntax::{ast::App, Context, Core};
|
use rtfm_syntax::{ast::App, Context, Core};
|
||||||
|
@ -133,6 +135,43 @@ pub fn late_resources_ident(init: &Ident) -> Ident {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn link_section_index() -> usize {
|
||||||
|
static INDEX: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
|
INDEX.fetch_add(1, Ordering::Relaxed)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn link_section(section: &str, core: Core) -> Option<TokenStream2> {
|
||||||
|
if cfg!(feature = "homogeneous") {
|
||||||
|
let section = format!(".{}_{}.rtfm{}", section, core, link_section_index());
|
||||||
|
Some(quote!(#[link_section = #section]))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE `None` means in shared memory
|
||||||
|
pub fn link_section_uninit(core: Option<Core>) -> Option<TokenStream2> {
|
||||||
|
let section = if let Some(core) = core {
|
||||||
|
let index = link_section_index();
|
||||||
|
|
||||||
|
if cfg!(feature = "homogeneous") {
|
||||||
|
format!(".uninit_{}.rtfm{}", core, index)
|
||||||
|
} else {
|
||||||
|
format!(".uninit.rtfm{}", index)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if cfg!(feature = "heterogeneous") {
|
||||||
|
// `#[shared]` attribute sets the linker section
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
format!(".uninit.rtfm{}", link_section_index())
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(quote!(#[link_section = #section]))
|
||||||
|
}
|
||||||
|
|
||||||
/// Generates a pre-reexport identifier for the "locals" struct
|
/// Generates a pre-reexport identifier for the "locals" struct
|
||||||
pub fn locals_ident(ctxt: Context, app: &App) -> Ident {
|
pub fn locals_ident(ctxt: Context, app: &App) -> Ident {
|
||||||
let mut s = match ctxt {
|
let mut s = match ctxt {
|
||||||
|
|
Loading…
Reference in a new issue