|
CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
|
The Bitpack structure itself, templated on the underlying Storage type. More...
#include <bitpack.hh>
Classes | |
| struct | Numeric |
| Convenience wrapper for the types of numeric fields. More... | |
| struct | FieldInfo |
| Information about a field within a Bitpack. More... | |
| struct | Field |
| A particular Field within a Bitpack. More... | |
Public Types | |
| using | Storage = StorageParam |
| Expose the underlying storage type. | |
Public Member Functions | |
| constexpr | Bitpack () |
| Construct a Bitpack value with an underlying Storage of all zero bits. | |
| constexpr | Bitpack (Storage v) |
| Construct a Bitpack value from a value of its underlying Storage type. | |
| template<typename Self> | |
| constexpr Self && | operator= (this Self &&self, const std::remove_cvref_t< Self > &b) |
| Assign a whole Bitpack at once given a non-volatile Bitpack of the same (or convertible, including derived) type. | |
| template<typename Self> requires (!std::is_volatile_v<Self>) | |
| constexpr bool | operator== (this Self &&self, const std::remove_cvref_t< Self > &b) |
| Compare Bitpack-s for equality (reflecting that of Storage). | |
| template<typename Self> requires (!std::is_volatile_v<Self>) | |
| constexpr auto | operator<=> (this Self &&self, const std::remove_cvref_t< Self > &b) |
| Spaceship operator on Bitpack-s (reflecing that of Storage). | |
| constexpr | operator Storage () const |
| Extract the underlying Storage value. | |
| constexpr Storage | raw () const |
| A shorter way of spelling static_cast<Storage>(...). | |
| template<typename Self> | |
| const auto | read (this Self &&self) |
| Return a snapshot of the underlying Storage. | |
| template<typename FieldType, typename Self> requires std::is_convertible_v< decltype(std::remove_cvref_t<Self>::template field_info_for_type< FieldType>()), const FieldInfo> | |
| constexpr auto | member (this Self &&self) |
| Build a Field::Proxy proxy by asking the derived Self class for a FieldInfo structure computed from template expansion of Self::field_info_for_type<FieldType>(). | |
| template<typename FieldType, typename Self> | |
| constexpr FieldType | get (this Self &&self) |
| Fetch the value of a field in this Bitpack based on the field type. | |
| template<typename FieldType, typename Self> | |
| constexpr std::remove_cvref_t< Self > | with (this Self &&self, FieldType v) |
| Compute a new Bitpack value with an updated field of a given type. | |
| template<typename FieldType, typename Self> | |
| constexpr void | set (this Self &&self, FieldType v) |
| Compute a new Bitpack value with an updated field of a given type. | |
| template<typename Self> requires std::is_invocable_r_v<std::remove_cvref_t<Self>, decltype(f), std::remove_cvref_t<Self>> | |
| constexpr void | alter (this Self &&self, auto &&f) |
| Convenience function for unconditionally changing several sub-fields at once. | |
| template<typename Self> requires std::is_invocable_r_v<std::remove_cvref_t<Self>, decltype(f), std::remove_cvref_t<Self>> | |
| constexpr void | assign_from (this Self &&self, auto &&f) |
| Convenience function for unconditionally assigning an entire Bitpack from a computed value. | |
Protected Member Functions | |
| template<typename FieldType, FieldInfo Info, typename Self> | |
| constexpr auto | member (this Self &&self) |
| Build a Field::Proxy of an explicitly given type and info. | |
The Bitpack structure itself, templated on the underlying Storage type.
This should be the sole (non-empty) superclass of a type representing a bitfield-esque composite structure.
Definition at line 318 of file bitpack.hh.
| using Bitpack< StorageParam >::Storage = StorageParam |
Expose the underlying storage type.
Definition at line 322 of file bitpack.hh.
|
inlineconstexpr |
Construct a Bitpack value with an underlying Storage of all zero bits.
Definition at line 329 of file bitpack.hh.
Referenced by Bitpack< StorageParam >::Field< TypeParam, InfoParam >::raw_with().
|
inlineexplicitconstexpr |
Construct a Bitpack value from a value of its underlying Storage type.
This is marked explicit to make things like "device->register = 0x7;" slightly harder to spell, with the intent of encouraging use of named constants.
Definition at line 338 of file bitpack.hh.
|
inlineconstexpr |
Convenience function for unconditionally changing several sub-fields at once.
Intended particularly for use with volatile Bitpack-s, to help ensure only one read and one write takes place, as the callback operates on a non-volatile Bitpack.
Definition at line 879 of file bitpack.hh.
|
inlineconstexpr |
Convenience function for unconditionally assigning an entire Bitpack from a computed value.
The function receives a zero-valued instance of the Bitpack type.
Definition at line 894 of file bitpack.hh.
|
inlineconstexpr |
Fetch the value of a field in this Bitpack based on the field type.
For volatile Bitpacks, this will perform a load.
Definition at line 845 of file bitpack.hh.
References member().
|
inlineconstexpr |
Build a Field::Proxy proxy by asking the derived Self class for a FieldInfo structure computed from template expansion of Self::field_info_for_type<FieldType>().
Definition at line 827 of file bitpack.hh.
References member().
|
inlineconstexprprotected |
Build a Field::Proxy of an explicitly given type and info.
This is protected so that it is available to subclasses but not more generally.
Definition at line 811 of file bitpack.hh.
|
inlineexplicitconstexpr |
Extract the underlying Storage value.
The Bitpack must not be volatile. Use .read() first.
Definition at line 393 of file bitpack.hh.
|
inlineconstexpr |
Spaceship operator on Bitpack-s (reflecing that of Storage).
Neither side may be volatile; use explicit .read()-s first.
Definition at line 382 of file bitpack.hh.
References operator<=>().
Referenced by operator<=>().
|
inlineconstexpr |
Assign a whole Bitpack at once given a non-volatile Bitpack of the same (or convertible, including derived) type.
To assign from a volatile Bitpack, perform an explicit .read() first.
"Deducing this" gives us CRTP-esque behavior without, well, the CRTP, so this will not accept an unrelated derived Bitpack class. (But will accept types that can be converted, so assigning to a Bitpack, as opposed to a derived class, will accept any derived class, for example. Probably best avoid that.)
Definition at line 355 of file bitpack.hh.
|
inlineconstexpr |
Compare Bitpack-s for equality (reflecting that of Storage).
Neither side may be volatile; use explicit .read()-s first.
Definition at line 369 of file bitpack.hh.
|
inlinenodiscardconstexpr |
A shorter way of spelling static_cast<Storage>(...).
The Bitpack must not be volatile. Use .read() first.
Definition at line 403 of file bitpack.hh.
Referenced by OpenTitanUart::interrupt_enable().
|
inline |
Return a snapshot of the underlying Storage.
Notably, this can be used to get a const Bitpack from a volatile Bitpack (const or not).
Definition at line 415 of file bitpack.hh.
|
inlineconstexpr |
Compute a new Bitpack value with an updated field of a given type.
For volatile Bitpacks, this will perform a load and store.
Definition at line 867 of file bitpack.hh.
References member().
|
inlineconstexpr |
Compute a new Bitpack value with an updated field of a given type.
For volatile Bitpacks, this will perform a load.
Definition at line 856 of file bitpack.hh.
References member().