template <class DerivedType, class IntType, class PrinterState = void>
class RegisterBase
Defined at line 145 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
An instance of RegisterBase represents a staging copy of a register,
which can be written to the register itself. It knows the register's
address and stores a value for the register.
Normal usage is to create classes that derive from RegisterBase and
provide methods for accessing bitfields of the register. RegisterBase
does not provide a constructor because constructors are not inherited by
derived classes by default, and we don't want the derived classes to
have to declare constructors.
Any bits not declared using DEF_FIELD/DEF_BIT/DEF_RSVDZ_FIELD/DEF_RSVDZ_BIT
will be automatically preserved across RMW operations.
Public Methods
uint32_t reg_addr ()
Defined at line 155 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
void set_reg_addr (uint32_t addr)
Defined at line 156 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
ValueType reg_value ()
Defined at line 158 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
ValueType * reg_value_ptr ()
Defined at line 159 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
const ValueType * reg_value_ptr ()
Defined at line 160 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
SelfType & set_reg_value (IntType value)
Defined at line 161 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
template <typename T>
SelfType & ReadFrom (T * reg_io)
Defined at line 167 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
template <typename T>
SelfType & WriteTo (T * reg_io)
Defined at line 174 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
template <typename F>
void Print (F print_fn)
Invokes print_fn(const char* buf) once for each field, including each
RsvdZ field, and one extra time if there are any undefined bits set.
The callback argument must not be accessed after the callback
returns. The callback will be called once for each field with a
null-terminated string describing the name and contents of the field.
Printed fields will look like: "field_name[26:8]: 0x00123 (291)"
The undefined bits message will look like: "unknown set bits: 0x00301000"
WARNING: This will substantially increase code size and stack usage at the
call site. https://fxbug.dev/42147424 tracks investigation to improve this.
Example use:
reg.Print([](const char* arg) { printf("%s\n", arg); });
Defined at line 198 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
void Print ()
Equivalent to Print([](const char* arg) { printf("%s\n", arg); });
Defined at line 205 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
template <typename FieldCallback>
void ForEachField (FieldCallback && callback)
Defined at line 212 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
IntType fields_mask ()
Defined at line 225 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
IntType rsvdz_mask ()
Defined at line 226 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h
Protected Methods
internal::FieldParameters<PrinterEnabled::value, ValueType> & params ()
Defined at line 229 of file ../../zircon/system/ulib/hwreg/include/hwreg/bitfields.h