* union/struct representations for MAS Registers
@ 2011-08-10 17:21 Jimi Xenidis
2011-08-10 17:25 ` Kumar Gala
2011-08-10 17:25 ` David Laight
0 siblings, 2 replies; 7+ messages in thread
From: Jimi Xenidis @ 2011-08-10 17:21 UTC (permalink / raw)
To: Kumar Gala; +Cc: Linuxppc-dev list
I have some and use them in some code, they represent ISA 2.06 MAVN=3D1 =
(version 2)
Can I keep them?
if so, should I put them somewhere useful to others?
Examples:
union mas1 {
u32 _val;
struct {
u32 v:1;
u32 iprot:1;
u32 tid:14;
u32 _reserved_1:2;
u32 ind:1;
u32 ts:1;
u32 tsize:4;
u32 _reserved_2:8;
};
};
-jx
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: union/struct representations for MAS Registers
2011-08-10 17:21 union/struct representations for MAS Registers Jimi Xenidis
@ 2011-08-10 17:25 ` Kumar Gala
2011-08-10 17:31 ` Jimi Xenidis
2011-08-10 17:25 ` David Laight
1 sibling, 1 reply; 7+ messages in thread
From: Kumar Gala @ 2011-08-10 17:25 UTC (permalink / raw)
To: Jimi Xenidis; +Cc: Linuxppc-dev list
On Aug 10, 2011, at 12:21 PM, Jimi Xenidis wrote:
> I have some and use them in some code, they represent ISA 2.06 MAVN=3D1 =
(version 2)
> Can I keep them?
> if so, should I put them somewhere useful to others?
>=20
> Examples:
> union mas1 {
> u32 _val;
> struct {
> u32 v:1;
> u32 iprot:1;
> u32 tid:14;
> u32 _reserved_1:2;
> u32 ind:1;
> u32 ts:1;
> u32 tsize:4;
> u32 _reserved_2:8;
> };
> };
Uugh, we really have avoided unions for such things and it would be nice =
to keep it that way.
- k=
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: union/struct representations for MAS Registers
2011-08-10 17:25 ` Kumar Gala
@ 2011-08-10 17:31 ` Jimi Xenidis
0 siblings, 0 replies; 7+ messages in thread
From: Jimi Xenidis @ 2011-08-10 17:31 UTC (permalink / raw)
To: Kumar Gala; +Cc: Linuxppc-dev list
On Aug 10, 2011, at 12:25 PM, Kumar Gala wrote:
>=20
> On Aug 10, 2011, at 12:21 PM, Jimi Xenidis wrote:
>=20
>> I have some and use them in some code, they represent ISA 2.06 MAVN=3D1=
(version 2)
>> Can I keep them?
>> if so, should I put them somewhere useful to others?
>>=20
>> Examples:
>> union mas1 {
>> u32 _val;
>> struct {
>> u32 v:1;
>> u32 iprot:1;
>> u32 tid:14;
>> u32 _reserved_1:2;
>> u32 ind:1;
>> u32 ts:1;
>> u32 tsize:4;
>> u32 _reserved_2:8;
>> };
>> };
>=20
> Uugh, we really have avoided unions for such things and it would be =
nice to keep it that way.
I like "nice", I'll convert
-JX
>=20
> - k
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: union/struct representations for MAS Registers
2011-08-10 17:21 union/struct representations for MAS Registers Jimi Xenidis
2011-08-10 17:25 ` Kumar Gala
@ 2011-08-10 17:25 ` David Laight
2011-08-10 17:31 ` Jimi Xenidis
1 sibling, 1 reply; 7+ messages in thread
From: David Laight @ 2011-08-10 17:25 UTC (permalink / raw)
To: Jimi Xenidis, Kumar Gala; +Cc: Linuxppc-dev list
=20
> I have some and use them in some code, they represent ISA=20
> 2.06 MAVN=3D1 (version 2)
> Can I keep them?
> if so, should I put them somewhere useful to others?
>=20
> Examples:
> union mas1 {
> u32 _val;
> struct {
> u32 v:1;
> u32 iprot:1;
> u32 tid:14;
> u32 _reserved_1:2;
> u32 ind:1;
> u32 ts:1;
> u32 tsize:4;
> u32 _reserved_2:8;
> };
> };
Bitfields are rather non-portable, the compiler has a lot of choice
about how to align the bits in memory.
Their use to map anything physical is doomed to portabilily issues.
David
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: union/struct representations for MAS Registers
2011-08-10 17:25 ` David Laight
@ 2011-08-10 17:31 ` Jimi Xenidis
2011-08-10 17:38 ` David Laight
0 siblings, 1 reply; 7+ messages in thread
From: Jimi Xenidis @ 2011-08-10 17:31 UTC (permalink / raw)
To: David Laight; +Cc: Linuxppc-dev list
On Aug 10, 2011, at 12:25 PM, David Laight wrote:
>
>> I have some and use them in some code, they represent ISA
>> 2.06 MAVN=1 (version 2)
>> Can I keep them?
>> if so, should I put them somewhere useful to others?
>>
>> Examples:
>> union mas1 {
>> u32 _val;
>> struct {
>> u32 v:1;
>> u32 iprot:1;
>> u32 tid:14;
>> u32 _reserved_1:2;
>> u32 ind:1;
>> u32 ts:1;
>> u32 tsize:4;
>> u32 _reserved_2:8;
>> };
>> };
>
> Bitfields are rather non-portable, the compiler has a lot of choice
> about how to align the bits in memory.
I'm ok with the masking stuff.
However, I'm actually surprised this is true given the maturity of our ABIs.
-JX
> Their use to map anything physical is doomed to portabilily issues.
>
> David
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread* RE: union/struct representations for MAS Registers
2011-08-10 17:31 ` Jimi Xenidis
@ 2011-08-10 17:38 ` David Laight
2011-08-10 17:48 ` Kumar Gala
0 siblings, 1 reply; 7+ messages in thread
From: David Laight @ 2011-08-10 17:38 UTC (permalink / raw)
To: Jimi Xenidis; +Cc: Linuxppc-dev list
=20
> > Bitfields are rather non-portable, the compiler has a lot of choice
> > about how to align the bits in memory.
>=20
> I'm ok with the masking stuff.
> However, I'm actually surprised this is true given the=20
> maturity of our ABIs.
The C standard says nothing at all about how bitfields are implemented,
I think the first bit might be 0x1, 0x80, 0x1000000 or 0x80000000
when treated as a 32bit value, regardless of the endianness.
Different architectures can (and do) assign things in different ways.
So code that is ok on ppc might fail on arm or x86 (etc).
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: union/struct representations for MAS Registers
2011-08-10 17:38 ` David Laight
@ 2011-08-10 17:48 ` Kumar Gala
0 siblings, 0 replies; 7+ messages in thread
From: Kumar Gala @ 2011-08-10 17:48 UTC (permalink / raw)
To: David Laight; +Cc: Linuxppc-dev list
On Aug 10, 2011, at 12:38 PM, David Laight wrote:
>=20
>>> Bitfields are rather non-portable, the compiler has a lot of choice
>>> about how to align the bits in memory.
>>=20
>> I'm ok with the masking stuff.
>> However, I'm actually surprised this is true given the=20
>> maturity of our ABIs.
>=20
> The C standard says nothing at all about how bitfields are =
implemented,
> I think the first bit might be 0x1, 0x80, 0x1000000 or 0x80000000
> when treated as a 32bit value, regardless of the endianness.
>=20
> Different architectures can (and do) assign things in different ways.
> So code that is ok on ppc might fail on arm or x86 (etc).
>=20
> David
I think PPCs a bit sane and what Jimi was proposing the union for is =
something that would never need to be portable (as it a PPC specific =
register).
Still, prefer the shifts, masks & macros as that's what I've been =
reading & using in ppc land forever ;)
- k=
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-08-10 17:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-10 17:21 union/struct representations for MAS Registers Jimi Xenidis
2011-08-10 17:25 ` Kumar Gala
2011-08-10 17:31 ` Jimi Xenidis
2011-08-10 17:25 ` David Laight
2011-08-10 17:31 ` Jimi Xenidis
2011-08-10 17:38 ` David Laight
2011-08-10 17:48 ` Kumar Gala
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox