Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cortex-m-rtfm-klee
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Samuel Karlsson
cortex-m-rtfm-klee
Commits
edb318be
Commit
edb318be
authored
7 years ago
by
Per
Browse files
Options
Downloads
Patches
Plain Diff
step towards automation
parent
1dd67ca2
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/resource.rs
+67
-0
67 additions, 0 deletions
examples/resource.rs
macros/src/trans.rs
+23
-0
23 additions, 0 deletions
macros/src/trans.rs
with
90 additions
and
0 deletions
examples/resource.rs
0 → 100644
+
67
−
0
View file @
edb318be
//! Minimal example with zero tasks
//#![deny(unsafe_code)]
// IMPORTANT always include this feature gate
#![feature(proc_macro)]
#![no_std]
extern
crate
cortex_m_rtfm
as
rtfm
;
// IMPORTANT always do this rename
extern
crate
stm32f103xx
;
#[macro_use]
extern
crate
klee
;
use
klee
::{
k_abort
,
k_read
};
// import the procedural macro
use
rtfm
::{
app
,
Resource
,
Threshold
};
app!
{
// this is the path to the device crate
device
:
stm32f103xx
,
resources
:
{
static
X
:
u32
=
0
;
static
Y
:
u32
=
0
;
},
tasks
:
{
EXTI1
:
{
path
:
exti1
,
resources
:
[
X
],
},
EXTI2
:
{
path
:
exti2
,
resources
:
[
X
,
Y
],
},
},
}
fn
exti1
(
t
:
&
mut
Threshold
,
r
:
EXTI1
::
Resources
)
{
let
mut
y
=
0
;
r
.X
.claim
(
t
,
|
x
,
_
|
{
if
*
x
<
10
{
for
_
in
0
..*
x
{
y
+=
1
;
k_visit!
();
}
}
});
k_read
(
&
y
);
}
fn
exti2
(
_t
:
&
mut
Threshold
,
_r
:
EXTI2
::
Resources
)
{}
#[inline(never)]
fn
init
(
_p
:
init
::
Peripherals
,
_r
:
init
::
Resources
)
{}
// The idle loop.
//
// This runs after `init` and has a priority of 0. All tasks can preempt this
// function. This function can never return so it must contain some sort of
// endless loop.
#[inline(never)]
fn
idle
()
->
!
{
k_abort
()
}
This diff is collapsed.
Click to expand it.
macros/src/trans.rs
+
23
−
0
View file @
edb318be
...
@@ -220,6 +220,8 @@ fn idle(
...
@@ -220,6 +220,8 @@ fn idle(
}
}
if
!
cfg!
(
feature
=
"klee_mode"
)
{
if
!
cfg!
(
feature
=
"klee_mode"
)
{
// in non klee mode we will call idle from init
let
idle
=
&
app
.idle.path
;
let
idle
=
&
app
.idle.path
;
main
.push
(
quote!
{
main
.push
(
quote!
{
// type check
// type check
...
@@ -227,6 +229,8 @@ fn idle(
...
@@ -227,6 +229,8 @@ fn idle(
idle
(
#
(
#
exprs
),
*
);
idle
(
#
(
#
exprs
),
*
);
});
});
}
else
{
// in klee mode we do NOT call idle its treated as a task
}
}
}
}
...
@@ -473,6 +477,25 @@ fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
...
@@ -473,6 +477,25 @@ fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
},
},
});
});
}
}
if
cfg!
(
feature
=
"klee_mode"
)
{
// collect the identifiers for our resources
let
mut
names
=
Vec
::
new
();
for
name
in
ownerships
.keys
()
{
let
_name
=
Ident
::
new
(
format!
(
"_{}"
,
name
.as_ref
()));
names
.push
(
quote!
{
k_symbol!
(
&
mut
#
_name
,
"#_name"
);
});
}
// generate a function setting all resources to symbolic
root
.push
(
quote!
{
pub
unsafe
fn
make_resources_symbolic
()
{
#
(
#
names
)
*
}
});
}
}
}
fn
tasks
(
app
:
&
App
,
ownerships
:
&
Ownerships
,
root
:
&
mut
Vec
<
Tokens
>
)
{
fn
tasks
(
app
:
&
App
,
ownerships
:
&
Ownerships
,
root
:
&
mut
Vec
<
Tokens
>
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment