[bootwrapper PATCH v3 04/15] Add bit-field macros

Mark Rutland mark.rutland at arm.com
Thu Jan 27 08:11:52 PST 2022


On Wed, Jan 26, 2022 at 03:03:12PM +0000, Andre Przywara wrote:
> On Tue, 25 Jan 2022 15:00:46 +0000
> Mark Rutland <mark.rutland at arm.com> wrote:
> 
> > Arm architectural documentation typically defines bit-fields as
> > `[msb,lsb]` and single-bit fields as `[bit]`. For clarity it would be
> > helpful if we could define fields in the same way.
> > 
> > Add helpers so that we can do so, along with helper to extract/insert
> > bit-field values.
> > 
> > There should be no functional change as a result of this patch.
> > 
> > Signed-off-by: Mark Rutland <mark.rutland at arm.com>
> 
> I extracted the code and checked the examples, see below.

> > +/*
> > + * Define a contiguous mask of bits with `msb` as the most significant bit and
> > + * `lsb` as the least significant bit. The `msb` value must be greater than or
> > + * equal to `lsb`.
> > + *
> > + * For example:
> > + * - BITS(63, 63) is 0x8000000000000000
> > + * - BITS(63, 0)  is 0xFFFFFFFFFFFFFFFF
> > + * - BITS(0, 0)   is 0x0000000000000001
> > + * - BITS(49, 17) is 0x0001FFFFFFFE0000
> 
> This should be 0x0003fffffffe0000, in real life and with the below
> implementation. So just a comment fix.

Good spot; I'll fix that up.

> The rest of the examples checked out, so with that fixed:
> 
> Reviewed-by: Andre Przywara <andre.przywara at arm.com>

Thanks!

Mark.



More information about the linux-arm-kernel mailing list