Commit graph

182 commits

Author SHA1 Message Date
Jorge Aparicio
98596554b3 split macro parser into its own crate and improve error handling / reporting 2017-07-14 18:57:02 -05:00
Jorge Aparicio
59afbf02aa compiler plugin -> proc macro 2017-07-11 23:44:54 -05:00
Jorge Aparicio
3cebf49a2f syntax tweaks, relax check, add set_pending(), deal with imported types
- allow trailing commas in list of resources

- make task.resources optional

- add rtfm::set_pending function which can be used to force an interrupt into
  the pending state. This is a replacement of the old rtfm::request.
  rtfm::set_pending takes the Interrupt enum provided by the device crate as
  argument. (The old rtfm::request took a task function as argument)

- the user may want to use types they imported into the root of the crate. These
  types are not available in e.g. `mod idle` so `idle::Resources` *can't* be
  defined in that module. To workaround this problem `idle::Resources` will be
  defined in the root, with some other name, and then be re-exported in the
  `idle` module.

- remove the "a resource only used by one task should be local data" check. In
  some cases you do want a resource owned by a single task instead of local
  data since `init` can access resources but not a task local data.
2017-07-06 23:25:29 -05:00
Jorge Aparicio
86a360a396 rtfm! macro take 2 2017-07-04 11:26:11 -05:00
Jorge Aparicio
984171edf6 fix unused macro error 2017-06-05 20:57:17 -05:00
Jorge Aparicio
b1e54883ac make the register_block field optional in the peripherals! macro
with svd2rust 0.8.x peripheral types are written in UPPERCASE and match their
names so specifying the type in the register_block field is no longer necessary.
2017-05-25 16:39:26 -05:00
Jorge Aparicio
c1465b2117 fix links in the references section 2017-05-15 22:16:59 -05:00
Jorge Aparicio
5cecc12d4c v0.1.0 2017-05-09 09:04:35 -05:00
Jorge Aparicio
acdfa6f09d drop the Ceiling newtype
it's not required as the user never deal with Ceiling tokens
2017-05-08 13:27:29 -05:00
Jorge Aparicio
c1a0f8173a require Resource protected data to be Send, make tokens !Send 2017-05-08 13:25:20 -05:00
Jorge Aparicio
fc4cb7d472 replace the ceiling token with a preemption threshold token 2017-05-08 12:05:42 -05:00
Jorge Aparicio
2063697c62 update examples 2017-04-28 09:23:30 -05:00
Jorge Aparicio
e2bde8d21a make the ceiling part of the task signature
remove the P.as_ceiling method
2017-04-27 19:28:27 -05:00
Jorge Aparicio
ec2df608ca make as_ceiling a general method of P<N> 2017-04-27 18:34:21 -05:00
Jorge Aparicio
25f959d329 add categories 2017-04-27 15:37:27 -05:00
Jorge Aparicio
731dd54b5f tweak attribution 2017-04-26 13:01:16 -05:00
Jorge Aparicio
404dde6f2a rename rtfm::critical to rtfm::atomic, touch up the documentation 2017-04-25 21:51:07 -05:00
Jorge Aparicio
840c32060b hide the unsafe Peripheral::new constructor
`peripherals!` is the safe way to declare `Peripheral`s
2017-04-25 19:46:33 -05:00
Jorge Aparicio
f9ada3f7f4 ignore no_mangle related warning 2017-04-25 17:42:34 -05:00
Jorge Aparicio
8659ecea72 add a peripherals! macro
for safe declaration of `Peripheral`s

closes #12
2017-04-25 14:13:46 -05:00
Jorge Aparicio
e72687a366 fix build for thumbv6m 2017-04-25 11:09:51 -05:00
Jorge Aparicio
59cff5815b update examples in doc comments 2017-04-25 10:24:17 -05:00
Jorge Aparicio
39c111a59a change tasks! syntax to resemble struct initialization 2017-04-25 09:29:29 -05:00
Jorge Aparicio
62356da0be update examples 2017-04-25 09:23:27 -05:00
Jorge Aparicio
3713959b3d update the examples in the crate documentation 2017-04-21 22:45:23 -05:00
Jorge Aparicio
d2008e783d add enable / disable functions, add $enabled parameter to tasks! 2017-04-21 22:02:49 -05:00
Jorge Aparicio
d0ddc322e3 rename borrow to access 2017-04-21 21:38:39 -05:00
Jorge Aparicio
296c88c49c add borrow_mut to Local 2017-04-21 21:25:10 -05:00
Jorge Aparicio
1c82f1b119 raise_to -> Ceiling.raise 2017-04-21 15:41:03 -05:00
Jorge Aparicio
3e165f2a42 drop lock methods, add raise_to function 2017-04-21 15:31:02 -05:00
Jorge Aparicio
854939fc6b rename "system ceiling" to "current ceiling" 2017-04-21 08:38:30 -05:00
Jorge Aparicio
4992db7877 more docs, remove Ceiling / Priority / Level traits 2017-04-21 00:24:54 -05:00
Jorge Aparicio
0a6583ddc6 fix warning on thumbv6m-none-eabi 2017-04-20 10:56:33 -05:00
Jorge Aparicio
4e6818eb2c remove claim, add Priority.as_ceiling 2017-04-19 17:21:13 -05:00
Jorge Aparicio
0827c40a26 remove the _mut methods
they are too limited
2017-04-19 16:35:07 -05:00
Jorge Aparicio
914e19d6a5 tasks! macro: update the signature of idle 2017-04-19 15:26:50 -05:00
Jorge Aparicio
aee3c2b29b critical: don't let the ceiling token escape the critical section 2017-04-19 15:03:49 -05:00
Jorge Aparicio
aee1d785a9 don't let the ceiling token escape the critical section 2017-04-19 14:15:18 -05:00
pln
70f573a6c4 with new formatting (perhaps) 2017-04-17 18:59:56 +02:00
pln
dad3a1f520 pub interface to logical2hw and hw2logical 2017-04-17 18:40:56 +02:00
Jorge Aparicio
a94de6bafc wrap references to resources in static-ref's Ref/RefMut
to assert that they point to `static` data
2017-04-14 10:19:08 -05:00
Jorge Aparicio
3d88f6c6bf re-export bkpt 2017-04-14 10:05:24 -05:00
Jorge Aparicio
be72ff5719 change signature of idle to ! 2017-04-14 00:39:12 -05:00
Jorge Aparicio
c6bf89a318 remove unnecessary trait bounds 2017-04-14 00:33:07 -05:00
Jorge Aparicio
bf17ee7422 pass P0 to init, derive GreaterThanOrEqual for U0 2017-04-14 00:15:49 -05:00
Jorge Aparicio
398a5ebc5c add critical, a global critical section 2017-04-13 23:52:02 -05:00
Jorge Aparicio
fdc060c273 remove system ceiling from lock_mut closure
now it's impossible to do a `borrow` within that critical section as a borrow of
the task priority is required (and that's already mutably borrowed by the
`lock_mut` closure)
2017-04-13 23:00:39 -05:00
Jorge Aparicio
2fb00c7d85 fix memory safety hole around borrow 2017-04-13 22:58:29 -05:00
Jorge Aparicio
692ad81ad8 re-export Local and wfi from cortex-m
make Context private
2017-04-13 19:01:46 -05:00
Jorge Aparicio
1ed5696f76 fix warning 2017-04-12 16:26:42 -05:00
Jorge Aparicio
2d334e76dd no lock_mut on thumbv6m 2017-04-12 16:14:29 -05:00
Jorge Aparicio
f62af15cfd implement lock_mut 2017-04-12 15:27:48 -05:00
Jorge Aparicio
fb20b51528 add claim_mut 2017-04-12 10:43:36 -05:00
Jorge Aparicio
d9300f01f8 fix the tasks! macro
NVIC.set_priority now requires unsafe
2017-04-12 10:16:56 -05:00
Jorge Aparicio
5d6847ab7b partial thumv6m-none-eabi support 2017-04-11 23:19:18 -05:00
Jorge Aparicio
5ae7d5f6e0 simplify the tasks! macro, make the request function more straightforward
in its meaning
2017-04-09 23:18:00 -05:00
Jorge Aparicio
595404c5ff compile time verified ceilings 2017-04-09 22:42:17 -05:00
Jorge Aparicio
6ac2625a75 drop global critical sections in checked::Resource 2017-04-07 19:33:08 -05:00
Jorge Aparicio
185f368d63 use volatile read/writes for checked::Resource.locked 2017-04-07 18:57:13 -05:00
Jorge Aparicio
22bb0d8eae removed global critical section from checked::release 2017-04-07 18:48:33 -05:00
Jorge Aparicio
f875cfcb5c use hw ceilings in checked::Resource.lock{,mut} 2017-04-07 18:18:37 -05:00
Jorge Aparicio
f2bab47aa4 allow returns from checked::Resource.lock{,mut}
also add compiler barriers
2017-04-07 18:14:48 -05:00
Jorge Aparicio
8e1c72057c impl Sync for checked::Resource 2017-04-07 17:54:36 -05:00
Jorge Aparicio
2ae638995c initial version of checked resources 2017-04-07 17:34:06 -05:00
Jorge Aparicio
759ac160db remove the borrow_mut method from resources
it can be used to break references rules within nested locks

``` rust
static R1: Resource<bool, C1> = unsafe { Resource::new(false) };
static R2: Resource<bool, C2> = unsafe { Resource::new(false) };
static R3: Resource<bool, C3> = unsafe { Resource::new(false) };

// Priority = 1
extern "C" fn j1(task: interrupt::Exti0Irq) {
    R1.lock(&task, |r1, c1| {
        R2.lock(&task, |r2, c2| {
            R3.lock(&task, |r3, mut c3| {
                // BAD &- and &mut - that point to the same data
                let r1_ref: &bool = R1.borrow(&c2);
                let r1_ref_mut: &mut bool = R1.borrow_mut(&mut c3);
            });
        });
    });
}
```
2017-04-07 16:38:39 -05:00
Jorge Aparicio
e631d8513a partial thumbv6m-none-eabi support 2017-04-06 14:06:33 -05:00
Jorge Aparicio
01c8c3312d split get in get / get_mut 2017-04-04 16:37:01 -05:00
Jorge Aparicio
00ef129f87 add a queue function 2017-04-04 15:36:23 -05:00
Jorge Aparicio
4c1b6c8293 add debug assertions to lock and get 2017-04-03 16:18:26 -05:00
Jorge Aparicio
f3b73bcc12 add a get method to get a raw pointer to the resource data 2017-04-02 20:42:38 -05:00
Jorge Aparicio
0ef71d29a8 rustfmt 2017-04-02 20:38:45 -05:00
Jorge Aparicio
85c628c2af add methods to borrow resources within interrupt::free 2017-03-22 14:33:52 -05:00
Jorge Aparicio
2d6af9b5df make logical non-const, check input using assertions 2017-03-11 18:02:11 -05:00
Jorge Aparicio
fd858a1994 make borrows of non-cooperative resources safe 2017-03-11 16:12:58 -05:00
Jorge Aparicio
4cfbf57799 add mutable variants of borrow and claim 2017-03-10 23:58:17 -05:00
Jorge Aparicio
7604400fd0 Token was renamed to Context 2017-03-10 20:11:36 -05:00
Jorge Aparicio
4da1963c8b rename priority to logical 2017-03-10 10:56:08 -05:00
Jorge Aparicio
288b01ea07 turn ceilings into types 2017-03-09 23:59:50 -05:00
Jorge Aparicio
388c34cc9f Resource::new is also unsafe 2017-03-08 08:22:31 -05:00
Jorge Aparicio
d88a15fb25 adapt to changes in cortex-m, verify the input of the priority function 2017-03-08 08:10:58 -05:00
Jorge Aparicio
e56f8156bc make priority a const fn 2017-03-05 11:36:05 -05:00
Jorge Aparicio
aba9333799 initial commit 2017-03-05 00:29:08 -05:00