2 * (c) 2014 Alexander Warg <alexander.warg@kernkonzept.com>
4 * This file is part of TUD:OS and distributed under the terms of the
5 * GNU General Public License 2.
6 * Please see the COPYING-GPL-2 file for details.
10 #include "hw_register_block.h"
14 class Mmio_register_block_base
21 explicit Mmio_register_block_base(l4_addr_t base = 0, l4_addr_t shift = 0)
22 : _base(base), _shift(shift) {}
24 template< typename T >
25 T read(l4_addr_t reg) const
26 { return *reinterpret_cast<volatile const T *>(_base + (reg << _shift)); }
28 template< typename T >
29 void write(T value, l4_addr_t reg) const
30 { *reinterpret_cast<volatile T *>(_base + (reg << _shift)) = value; }
32 void set_base(l4_addr_t base) { _base = base; }
33 void set_shift(l4_addr_t shift) { _shift = shift; }
36 template< unsigned MAX_BITS = 32 >
37 struct Mmio_register_block :
38 Register_block_impl<Mmio_register_block<MAX_BITS>, MAX_BITS>,
39 Mmio_register_block_base
41 explicit Mmio_register_block(l4_addr_t base = 0, l4_addr_t shift = 0)
42 : Mmio_register_block_base(base, shift) {}