Skip to content
This repository was archived by the owner on Jul 6, 2019. It is now read-only.

ioreg syntax extension #108

Merged
merged 9 commits into from
Aug 7, 2014
Merged

ioreg syntax extension #108

merged 9 commits into from
Aug 7, 2014

Conversation

bgamari
Copy link
Contributor

@bgamari bgamari commented Jul 17, 2014

I'll need to write something more coherent here but here is the continuation of the ioreg work originally discussed in #90. I've restructured and cleaned up the builder code substantially and getter and setter objects have been implemented. Note that this currently requires some compiler bits that have yet to be merged to compile. You can find rustdoc output for the code generated by a simple example here. More on this later when it's not as late.

I would apply the proper label to indicate this is work in progress but it seems I don't have permission to do so.

Remaining work

  • Examine options for reducing documentation clutter

@bgamari
Copy link
Contributor Author

bgamari commented Jul 17, 2014

@bharrisau I've updated the rustdoc upload, feel free to have a look. The FTM_STATUS register has set_to_clear flags.

use super::super::node;

/// A visitor to build accessor functions for each register struct
pub struct BuildAccessors<'a, 'b, 'c> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to unify lifetimes here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vladimir Pouzanov [email protected] writes:

+/// A visitor to build accessor functions for each register struct
+pub struct BuildAccessors<'a, 'b, 'c> {

Any reason not to unify lifetimes here?

I played around with these for quite a while to make the borrow checker
happy. That being said, things have changed substantially since then, so
perhaps they can now be unified. I'll have a look later.

@farcaller
Copy link
Member

I've added a few notes on the code. I will have some more on the style later on when this settles a bit, but overall it's very nice, great job!

@bgamari
Copy link
Contributor Author

bgamari commented Jul 30, 2014

@farcaller, @bharrisau what do we think about peripheral instantiation? I'm tempted to punt on bit-banding support for now as I don't have a lot of time recently and I'd like to get this merged eventually.

@bharrisau
Copy link
Contributor

I'll throw bit-banding in later. The easiest is to use weak linkage of the bitband memory address (and I'll be able to do a memory map macro when I get a chance that will generate that).

What do you mean by peripheral instantiation? As in, generating the #[link_name="armmem_SYSTICK"] pub static SYSTICK: SYSTICKReg line? I'd leave that out, and we can do it in platformtree or a memory map macro. (I'd like to shift the device specific stuff one level higher than HAL - memory map and pin map. Leave HAL to handle the vendor/architecture specific stuff)

@bgamari
Copy link
Contributor Author

bgamari commented Jul 30, 2014

@bharrisau That sounds reasonable enough.

Unfortunately it seems like something has broken with the recent rustc/zinc changes. After rebasing I'm seeing the following unhelpful build failure,

rustc --opt-level 2 -Z no-landing-pads --cfg cfg_mcu_has_spi --cfg mcu_lpc17xx --cfg arch_cortex_m3 --target thumbv7m-linux-eabi -Ctarget-cpu=cortex-m3 -C relocation_model=static      -L /opt/exp/zinc/build  --out-dir /opt/exp/zinc/build  /opt/exp/zinc/src/main.rs 
/opt/exp/zinc/src/main.rs:1:1: 1:1 error: expected ident, found `=`
/opt/exp/zinc/src/main.rs:1 // Zinc, the bare metal stack for rust.

@bharrisau
Copy link
Contributor

If I had to guess - there is an '=' used incorrectly in a macro.

@bharrisau
Copy link
Contributor

Maybe somewhere you are calling .expect_ident?

@farcaller
Copy link
Member

No, this is rust-lang/rust#15972. Build with -O0.

@farcaller
Copy link
Member

(I've seen the same problem in #116)

@bgamari
Copy link
Contributor Author

bgamari commented Jul 30, 2014

@farcaller it seems like the fix has made it upstream. I'm building a new rustc as we speak. Well done tracking this one down, by the way.

@bgamari
Copy link
Contributor Author

bgamari commented Aug 6, 2014

This morning I brushed off these patches, rebased them, and did a bit more porting of K20. I found a few bugs and cleaned up the documentation a bit further in the process. At this point I feel pretty good about merging so folks can finally start using this in anger.

What do people think?

// limitations under the License.

use syntax::ast;
use syntax::ast::{P};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove {/} here and on next line.

@farcaller
Copy link
Member

Thanks for all the work, looks nice.

I've left a few comments in for you. Also, can you split the macro part and the new ioreg implementations to separate PRs?

@bgamari
Copy link
Contributor Author

bgamari commented Aug 6, 2014

I almost forgot: My tree currently has deny(missing_doc) commented out as many of the register definitions don't have documentation. In general, I think we should accept a slightly lower standard of documentation for the register interfaces than the high-level library interfaces. The register interfaces have fewer users and frankly I think it's reasonable to expect that you'll need to datasheet by your side when you are poking at registers.

Would there be any objection to my adding allow(missing_doc) annotations to items produced by ioregs!?

@farcaller
Copy link
Member

Would there be any objection to my adding allow(missing_doc) annotations to items produced by ioregs!?

I'm fine with that. It might be useful to add a reference to where in the datasheet you can find the register description, but those fluctuate quite as well. Maybe chapter number / name would be fine?

@bgamari
Copy link
Contributor Author

bgamari commented Aug 6, 2014

@farcaller as far as I can tell things look good for merge.

@errordeveloper
Copy link
Member

@bgamari great stuff! I don't seem to see any unit tests here, so I suppose you are intending to add them in a separate pull request...

@bgamari
Copy link
Contributor Author

bgamari commented Aug 6, 2014

@errordeveloper there is still a bit of work to be done on the documentation and testing side of things but I'd like to get this merged to get people using it and lessen the maintenance burden.

let clear_mask: $unpacked_ty = $clear as $unpacked_ty;
if self.mask != 0 {
let v: $unpacked_ty = self.reg.value.get() & ! clear_mask & ! self.mask;
self.reg.value.set(self.value | v);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As some future work, will just double check how the generated ASM for this looks.

@bharrisau
Copy link
Contributor

Wow, awesome work. I haven't had a chance to have a thorough look (and I probably wont until my contract finishes at the end of this month).

Can someone land a PR that renames all the current ioreg! to ioreg_old! to make room for this one?

@farcaller
Copy link
Member

Ok, let's land this.

hacknbot added a commit that referenced this pull request Aug 7, 2014
ioreg syntax extension

Reviewed-by: farcaller
hacknbot added a commit that referenced this pull request Aug 7, 2014
ioreg syntax extension

Reviewed-by: farcaller
hacknbot added a commit that referenced this pull request Aug 7, 2014
ioreg syntax extension

Reviewed-by: farcaller
hacknbot added a commit that referenced this pull request Aug 7, 2014
ioreg syntax extension

Reviewed-by: farcaller
farcaller added a commit that referenced this pull request Aug 7, 2014
Added new ioreg syntax extension
@farcaller farcaller merged commit 51e2abc into hackndev:master Aug 7, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants