mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
mmio: fix type inaccuracy in bitset reads
We must ensure that the type in use fits the shift value that gets applied while combining the bitset sub-values. ref #1095
This commit is contained in:
parent
76668f0774
commit
6476cb3bbd
@ -520,8 +520,11 @@ namespace Genode
|
||||
{
|
||||
typedef typename T::Bitset_2_base::Bits_0 Bits_0;
|
||||
typedef typename T::Bitset_2_base::Bits_1 Bits_1;
|
||||
return read<Bits_0>() |
|
||||
(read<Bits_1>() << Bits_0::BITFIELD_WIDTH);
|
||||
typedef typename T::Bitset_2_base::access_t access_t;
|
||||
enum { V1_SHIFT = Bits_0::BITFIELD_WIDTH };
|
||||
access_t const v0 = read<Bits_0>();
|
||||
access_t const v1 = read<Bits_1>();
|
||||
return v0 | (v1 << V1_SHIFT);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -547,9 +550,15 @@ namespace Genode
|
||||
typedef typename T::Bitset_3_base::Bits_0 Bits_0;
|
||||
typedef typename T::Bitset_3_base::Bits_1 Bits_1;
|
||||
typedef typename T::Bitset_3_base::Bits_2 Bits_2;
|
||||
return read<Bitset_2<Bits_0, Bits_1> >() |
|
||||
(read<Bits_2>() << (Bits_0::BITFIELD_WIDTH +
|
||||
Bits_1::BITFIELD_WIDTH));
|
||||
typedef typename T::Bitset_3_base::access_t access_t;
|
||||
enum {
|
||||
BITS_0_WIDTH = Bits_0::BITFIELD_WIDTH,
|
||||
BITS_1_WIDTH = Bits_1::BITFIELD_WIDTH,
|
||||
V1_SHIFT = BITS_0_WIDTH + BITS_1_WIDTH,
|
||||
};
|
||||
access_t const v0 = read<Bitset_2<Bits_0, Bits_1> >();
|
||||
access_t const v1 = read<Bits_2>();
|
||||
return v0 | (v1 << V1_SHIFT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user