21 #ifndef REGISTER_ACCESS_HPP_INCLUDED 22 #define REGISTER_ACCESS_HPP_INCLUDED 26 #include <arch/bitband.hpp> 28 #ifdef OPENMPTL_SIMULATION 34 #ifndef OPENMPTL_SIMULATION 44 static_assert(std::is_integral<Tp>::value,
"Tp is not an integral type");
45 static_assert(std::is_unsigned<Tp>::value,
"Tp is not an unsigned type");
46 static_assert(!std::is_volatile<Tp>::value,
"Tp is a volatile-qualified type (why would you want this?)");
58 static_assert(permission !=
wo,
"read access to a write-only register");
59 return *
reinterpret_cast<volatile Tp *
>(
addr);
64 static_assert(permission !=
ro,
"write access to a read-only register");
65 *
reinterpret_cast<volatile Tp *
>(
addr) = value;
69 template<
unsigned bit_no>
71 static_assert(permission !=
ro,
"write access to a read-only register");
72 bitband_periph::bitset<addr, bit_no>();
76 template<
unsigned bit_no>
78 static_assert(permission !=
ro,
"write access to a read-only register");
79 bitband_periph::bitclear<addr, bit_no>();
83 template<
unsigned bit_no>
85 static_assert(permission !=
wo,
"read access to a write-only register");
86 return bitband_periph::bittest<addr, bit_no>();
102 static void store_impl(Tp
const value) {
103 static_assert(
permission !=
ro,
"write access to a read-only register");
105 #ifdef CONFIG_REGISTER_REACTION 109 #ifdef CONFIG_REGISTER_REACTION 123 static constexpr
bool bitop_enabled = bitband_periph::covered(addr);
125 #ifdef CONFIG_DUMP_REGISTER_ACCESS 130 static_assert(permission !=
wo,
"read access to a write-only register");
131 #ifdef CONFIG_DUMP_REGISTER_ACCESS 132 dumper::dump_register_load(reg_value);
133 #endif // CONFIG_DUMP_REGISTER_ACCESS 137 static void store(Tp
const value) {
138 #ifdef CONFIG_DUMP_REGISTER_ACCESS 139 dumper::dump_register_store(reg_value, value);
144 template<
unsigned bit_no>
147 #ifdef CONFIG_DUMP_REGISTER_ACCESS 148 dumper::dump_register_bitset(reg_value, bit_no);
153 template<
unsigned bit_no>
155 value_type value = reg_value & ~(1 << bit_no);
156 #ifdef CONFIG_DUMP_REGISTER_ACCESS 157 dumper::dump_register_bitclear(reg_value, bit_no);
162 template<
unsigned bit_no>
164 static_assert(permission !=
wo,
"read access to a write-only register");
166 #ifdef CONFIG_DUMP_REGISTER_ACCESS 167 dumper::dump_register_bittest(reg_value, bit_no);
182 #endif // OPENMPTL_SIMULATION 186 #endif // REGISTER_ACCESS_HPP_INCLUDED static __always_inline void bitset()
Set a single bit using bitband_periph::bitset<>
Definition: register_access.hpp:70
Definition: register_type.hpp:29
static constexpr reg_addr_t addr
Definition: register_access.hpp:51
uintptr_t reg_addr_t
Register address type (uintptr_t: unsigned integer type capable of holding a pointer) ...
Definition: register_type.hpp:33
#define __always_inline
Definition: compiler.h:8
Definition: register_access.hpp:42
Tp value_type
Integral type used for register access.
Definition: register_access.hpp:49
Definition: register_type.hpp:29
thread_local int regdump_reaction_running
void react()
Reaction function, must be implemented per-project.
Definition: register_sim.hpp:57
static __always_inline Tp load(void)
Load (read) register value.
Definition: register_access.hpp:57
Definition: register_sim.hpp:95
static constexpr reg_perm permission
Definition: register_access.hpp:52
static constexpr bool bitop_enabled
Definition: register_access.hpp:54
reg_perm
Register access permission.
Definition: register_type.hpp:29
static __always_inline bool bittest()
Returns the value of a single bit using bitband_periph::bittest<>
Definition: register_access.hpp:84
static __always_inline void store(Tp const value)
Store (write) a register value.
Definition: register_access.hpp:63
static __always_inline void bitclear()
Clear a single bit using bitband_periph::bitclear<>
Definition: register_access.hpp:77