[coreboot] patch: fix USB ports on DBE62, and other cs5536-based platforms

Stefan Reinauer stepan at coresystems.de
Wed Jun 4 20:10:59 CEST 2008

ron minnich wrote:
> On Wed, Jun 4, 2008 at 10:32 AM, Stefan Reinauer <stepan at coresystems.de> wrote:
>> #define MCHBAR8(x) *((volatile u8 *)(DEFAULT_MCHBAR + x))
>> #define MCHBAR16(x) *((volatile u16 *)(DEFAULT_MCHBAR + x))
>> #define MCHBAR32(x) *((volatile u32 *)(DEFAULT_MCHBAR + x))
>> so you can write
>> MCHBAR8(DCC) |= (1<<1);
>> for maximum readablility
> yes but as I mentioned .... one of the very earliest uses of struct,
> from the guy who designed C, was to avoid this kind of construct.
> Register structures accessed via mmio? set up a struct.
The one disadvantage of structs for this kind of thing is that you have
no way to cleanly describe offsets except through padding bytes.
So you end up recalculating offsets of registers and numbers of bytes of
reserved1 - reserved100 arrays within your struct, one for every hole.
And when you add a register, you do the work again, and it's error
prone, a single byte off, and all your registers are wrong.

I'm not against using structs, in fact maybe we should just do it, but
they're not the optimal solution either. The guy who invented struct was
not a firmware developer.

coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br.
      Tel.: +49 761 7668825 • Fax: +49 761 7664613
Email: info at coresystems.dehttp://www.coresystems.de/
Registergericht: Amtsgericht Freiburg • HRB 7656
Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866

More information about the coreboot mailing list