Re: [arm-gnu] Access to volatile bit-fields
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [arm-gnu] Access to volatile bit-fields
- To: arm-gnu@xxxxxxxxxxxxxxxx
- Subject: Re: [arm-gnu] Access to volatile bit-fields
- From: Charles Manning <manningc2@xxxxxxxxxxxxx>
- Date: Thu, 2 Sep 2010 14:41:27 +1200
I am 100% with 42Bastian on this.
"Looks cute" is not the same as "cleanest"
I've been an embedding with C for 26 years now and won't touch bitfields for
this purpose.
It is not the cleanest mapping because there is no definition of what bus
cycles should occur. Nor does any C spec define the actual bit layouts of
bitfields. The compiler is actually free to shift bits around in a structure
to improve alignment if it should so wish.
There are also other ways to support your debugging. For example gdb provides
extensive macro capabilities which allow you to read a register and format
the output way more flexibly than bitfields ever will.
I do, however, make extensive use of bitfields for other structures.
--Charles
On Wednesday 01 September 2010 02:19:01 zakharov@xxxxxxxxxxxx wrote:
> Many developers would agree with you since many of them did bite the
> bullet at some point. Yet bitfields is the most clean mapping from the
> hardware spec to the actual code. You have to remember one more
> important thing - debugging. If you will use all this or-ing and
> shifting then you will loose opportunity to see the register in the
> debugger. For example in my design I can always pop-up "live" register
> in TRACE32 or Eclipse and see absolute location address and all the
> fields. Very handy and very useful. In my previous project where we
> had around few hundred very complex registers it was a must. In any
> case, if compiler is declared ARM ABI compliant it has to be so. What
> confuses me is that issue goes back to 2007 and patch does exist and
> still not populated in current releases. I spent last 15 years
> writing firmware for all kinds of CPU and micro controllers and my
> opinion is - we want and we will use bitfields. I am sure any embedded
> designer will be on my side.
>
> Alex
>
> Quoting 42Bastian <list-bastian.schick@xxxxxxxxxxx>:
> > AmAm 31.08.2010 10:04, schrieb Ryan Lishman:
> >> Not pretty either way ... the best solution would be an ABI compliant
> >> compiler. Anxiously, we wait.
> >
> > Sorry to say this: The best solution would be to not use bit fields at
> > all.
> >
> > When it comes to hardware I strongly discourage the use of bit fields.
> >
> > --
> > 42Bastian
> > +
> >
> > | http://www.sciopta.com
> > | Fastest direct message passing kernel.
> > | IEC61508 certified.
> >
> > +