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
KLEE
cortex-m-rtfm-klee
Commits
185f368d
Commit
185f368d
authored
Apr 7, 2017
by
Jorge Aparicio
Browse files
Options
Downloads
Patches
Plain Diff
use volatile read/writes for checked::Resource.locked
parent
22bb0d8e
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Cargo.toml
+4
-0
4 additions, 0 deletions
Cargo.toml
src/checked.rs
+8
-7
8 additions, 7 deletions
src/checked.rs
src/lib.rs
+1
-0
1 addition, 0 deletions
src/lib.rs
with
13 additions
and
7 deletions
Cargo.toml
+
4
−
0
View file @
185f368d
...
@@ -6,3 +6,7 @@ version = "0.1.0"
...
@@ -6,3 +6,7 @@ version = "0.1.0"
[dependencies]
[dependencies]
cortex-m
=
"0.2.0"
cortex-m
=
"0.2.0"
[dependencies.
vcell
]
features
=
[
"const-fn"
]
version
=
"0.1.0"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/checked.rs
+
8
−
7
View file @
185f368d
...
@@ -5,26 +5,27 @@ use core::cell::UnsafeCell;
...
@@ -5,26 +5,27 @@ use core::cell::UnsafeCell;
use
cortex_m
::
interrupt
;
use
cortex_m
::
interrupt
;
use
cortex_m
::
register
::{
basepri
,
basepri_max
};
use
cortex_m
::
register
::{
basepri
,
basepri_max
};
use
vcell
::
VolatileCell
;
use
Ceiling
;
use
Ceiling
;
unsafe
fn
acquire
(
locked
:
&
Unsaf
eCell
<
bool
>
,
ceiling
:
u8
)
->
u8
{
unsafe
fn
acquire
(
locked
:
&
Volatil
eCell
<
bool
>
,
ceiling
:
u8
)
->
u8
{
interrupt
::
free
(
interrupt
::
free
(
|
_
|
{
|
_
|
{
assert!
(
!
*
locked
.get
(),
"resource already locked"
);
assert!
(
!
locked
.get
(),
"resource already locked"
);
let
old_basepri
=
basepri
::
read
();
let
old_basepri
=
basepri
::
read
();
basepri_max
::
write
(
ceiling
);
basepri_max
::
write
(
ceiling
);
*
locked
.
g
et
(
)
=
true
;
locked
.
s
et
(
true
)
;
old_basepri
old_basepri
},
},
)
)
}
}
unsafe
fn
release
(
locked
:
&
Unsaf
eCell
<
bool
>
,
old_basepri
:
u8
)
{
unsafe
fn
release
(
locked
:
&
Volatil
eCell
<
bool
>
,
old_basepri
:
u8
)
{
// XXX Is it really memory safe to *not* use a global critical section here
// XXX Is it really memory safe to *not* use a global critical section here
// interrupt::free(
// interrupt::free(
// |_| {
// |_| {
*
locked
.
g
et
(
)
=
false
;
locked
.
s
et
(
false
)
;
basepri
::
write
(
old_basepri
);
basepri
::
write
(
old_basepri
);
// },
// },
// );
// );
...
@@ -34,7 +35,7 @@ unsafe fn release(locked: &UnsafeCell<bool>, old_basepri: u8) {
...
@@ -34,7 +35,7 @@ unsafe fn release(locked: &UnsafeCell<bool>, old_basepri: u8) {
pub
struct
Resource
<
T
,
C
>
{
pub
struct
Resource
<
T
,
C
>
{
_marker
:
PhantomData
<
C
>
,
_marker
:
PhantomData
<
C
>
,
data
:
UnsafeCell
<
T
>
,
data
:
UnsafeCell
<
T
>
,
locked
:
Unsaf
eCell
<
bool
>
,
locked
:
Volatil
eCell
<
bool
>
,
}
}
impl
<
T
,
C
>
Resource
<
T
,
C
>
impl
<
T
,
C
>
Resource
<
T
,
C
>
...
@@ -46,7 +47,7 @@ where
...
@@ -46,7 +47,7 @@ where
Resource
{
Resource
{
_marker
:
PhantomData
,
_marker
:
PhantomData
,
data
:
UnsafeCell
::
new
(
data
),
data
:
UnsafeCell
::
new
(
data
),
locked
:
Unsaf
eCell
::
new
(
false
),
locked
:
Volatil
eCell
::
new
(
false
),
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
1
−
0
View file @
185f368d
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
#![no_std]
#![no_std]
extern
crate
cortex_m
;
extern
crate
cortex_m
;
extern
crate
vcell
;
pub
mod
checked
;
pub
mod
checked
;
...
...
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