mmio: provide bits method for bitsets

ref #1006
This commit is contained in:
Martin Stein
2013-12-19 17:31:56 +01:00
committed by Norman Feske
parent e142d0d2e8
commit ff70ca6427
2 changed files with 35 additions and 0 deletions

View File

@ -235,6 +235,18 @@ namespace Genode
};
typedef typename Trait::Uint_width<ACCESS_WIDTH>::Type access_t;
typedef Bitset_2<Bits_0, Bits_1> Bitset_2_base;
/**
* Get register with the bitset set to a given value and rest left 0
*
* \param T access type of register
* \param v bitset value
*/
template <typename T>
static inline T bits(T const v)
{
return Bits_0::bits(v) | Bits_1::bits(v >> Bits_0::WIDTH);
}
};
/**
@ -260,6 +272,19 @@ namespace Genode
};
typedef typename Trait::Uint_width<ACCESS_WIDTH>::Type access_t;
typedef Bitset_3<Bits_0, Bits_1, Bits_2> Bitset_3_base;
/**
* Get register with the bitset set to a given value and rest left 0
*
* \param T access type of register
* \param v bitset value
*/
template <typename T>
static inline T bits(T const v)
{
typedef Bitset_2<Bits_0, Bits_1> Bits_0_1;
return Bits_0_1::bits(v) | Bits_2::bits(v >> Bits_0_1::WIDTH);
}
};
}