Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
EEPROMStoredBitSet< HW > Class Template Reference
Inheritance diagram for EEPROMStoredBitSet< HW >:
ShadowedStoredBitSet StoredBitSet Atomic

Public Member Functions

template<typename... Args>
 EEPROMStoredBitSet (Args... args)
 
void flush () override
 Writes the current values to persistent storage.
 
- Public Member Functions inherited from ShadowedStoredBitSet
StoredBitSetset_bit (unsigned offset, bool value) override
 Sets an individual bit to a specific value.
 
bool get_bit (unsigned offset) override
 Retrieves an individual bit.
 
StoredBitSetset_multi (unsigned offset, unsigned size, unsigned value) override
 Sets a block of consecutive bits.
 
unsigned get_multi (unsigned offset, unsigned size) override
 Returns a block of consecutive bits as an integer value.
 
unsigned size () override
 
void lock_and_flush () override
 Grabs a lock and writes the current values to persistent storage.
 

Private Types

using eeprom_t = typename HW::eeprom_t
 

Private Member Functions

void mount ()
 
void clear_all_dirty ()
 
void format ()
 
void write_header ()
 
void read_entry (eeprom_t v)
 
unsigned value_to_vcell_ofs (eeprom_t value)
 
unsigned value_to_vcell_value (eeprom_t value)
 
eeprom_t get_vcell (unsigned vcell)
 

Private Attributes

eeprom_t currentMarker_
 What is the current desired value of the marker bit.
 
unsigned writeOffset_
 

Static Private Attributes

static constexpr eeprom_t MARKER_MASK
 The MSB of each eeprom value is the marker.
 
static constexpr eeprom_t EEPROM_MASK = eeprom_t(-1)
 
static constexpr eeprom_t MAGIC
 Magic value in the zero offset certifies that we are correctly formatted.
 
static constexpr eeprom_t ERASED = 0xFFFFFFFFU & EEPROM_MASK
 
static constexpr unsigned FIRST_MAGIC_OFS = 0
 
static constexpr unsigned SECOND_MAGIC_OFS = 1
 
static constexpr unsigned HEADER_OFS = 2
 
static constexpr unsigned JOURNAL_OFS
 

Additional Inherited Members

- Protected Types inherited from ShadowedStoredBitSet
typedef uint8_t cell_offs_t
 Type indexing cells. Must be an unsigned type.
 
typedef unsigned bit_offs_t
 Type indexing all bits.
 
- Protected Member Functions inherited from ShadowedStoredBitSet
 ShadowedStoredBitSet (unsigned size, uint8_t granularity)
 
cell_offs_t next_dirty ()
 
void clear_dirty (cell_offs_t cell)
 Clears the dirty bit for a given cell.
 
bool is_dirty (cell_offs_t cell)
 
cell_offs_t num_cells ()
 
- Protected Member Functions inherited from Atomic
void lock ()
 
void unlock ()
 
- Static Protected Attributes inherited from ShadowedStoredBitSet
static constexpr cell_offs_t NO_CELL = static_cast<cell_offs_t>(-1)
 

Detailed Description

template<class HW>
class EEPROMStoredBitSet< HW >

Definition at line 83 of file EEPROMStoredBitSet.hxx.

Member Typedef Documentation

◆ eeprom_t

template<class HW >
using EEPROMStoredBitSet< HW >::eeprom_t = typename HW::eeprom_t
private

Definition at line 126 of file EEPROMStoredBitSet.hxx.

Constructor & Destructor Documentation

◆ EEPROMStoredBitSet()

template<class HW >
template<typename... Args>
EEPROMStoredBitSet< HW >::EEPROMStoredBitSet ( Args...  args)
inline

Definition at line 87 of file EEPROMStoredBitSet.hxx.

Member Function Documentation

◆ clear_all_dirty()

template<class HW >
void EEPROMStoredBitSet< HW >::clear_all_dirty ( )
inlineprivate

Definition at line 181 of file EEPROMStoredBitSet.hxx.

◆ flush()

template<class HW >
void EEPROMStoredBitSet< HW >::flush ( )
inlineoverridevirtual

Writes the current values to persistent storage.

The caller is responsible for locking.

Implements StoredBitSet.

Definition at line 95 of file EEPROMStoredBitSet.hxx.

◆ format()

template<class HW >
void EEPROMStoredBitSet< HW >::format ( )
inlineprivate

Definition at line 190 of file EEPROMStoredBitSet.hxx.

◆ get_vcell()

template<class HW >
eeprom_t EEPROMStoredBitSet< HW >::get_vcell ( unsigned  vcell)
inlineprivate

Definition at line 246 of file EEPROMStoredBitSet.hxx.

◆ mount()

template<class HW >
void EEPROMStoredBitSet< HW >::mount ( )
inlineprivate

Definition at line 128 of file EEPROMStoredBitSet.hxx.

◆ read_entry()

template<class HW >
void EEPROMStoredBitSet< HW >::read_entry ( eeprom_t  v)
inlineprivate

Definition at line 229 of file EEPROMStoredBitSet.hxx.

◆ value_to_vcell_ofs()

template<class HW >
unsigned EEPROMStoredBitSet< HW >::value_to_vcell_ofs ( eeprom_t  value)
inlineprivate

Definition at line 236 of file EEPROMStoredBitSet.hxx.

◆ value_to_vcell_value()

template<class HW >
unsigned EEPROMStoredBitSet< HW >::value_to_vcell_value ( eeprom_t  value)
inlineprivate

Definition at line 241 of file EEPROMStoredBitSet.hxx.

◆ write_header()

template<class HW >
void EEPROMStoredBitSet< HW >::write_header ( )
inlineprivate

Definition at line 204 of file EEPROMStoredBitSet.hxx.

Member Data Documentation

◆ currentMarker_

template<class HW >
eeprom_t EEPROMStoredBitSet< HW >::currentMarker_
private

What is the current desired value of the marker bit.

Definition at line 276 of file EEPROMStoredBitSet.hxx.

◆ EEPROM_MASK

template<class HW >
constexpr eeprom_t EEPROMStoredBitSet< HW >::EEPROM_MASK = eeprom_t(-1)
staticconstexprprivate

Definition at line 260 of file EEPROMStoredBitSet.hxx.

◆ ERASED

template<class HW >
constexpr eeprom_t EEPROMStoredBitSet< HW >::ERASED = 0xFFFFFFFFU & EEPROM_MASK
staticconstexprprivate

Definition at line 267 of file EEPROMStoredBitSet.hxx.

◆ FIRST_MAGIC_OFS

template<class HW >
constexpr unsigned EEPROMStoredBitSet< HW >::FIRST_MAGIC_OFS = 0
staticconstexprprivate

Definition at line 269 of file EEPROMStoredBitSet.hxx.

◆ HEADER_OFS

template<class HW >
constexpr unsigned EEPROMStoredBitSet< HW >::HEADER_OFS = 2
staticconstexprprivate

Definition at line 271 of file EEPROMStoredBitSet.hxx.

◆ JOURNAL_OFS

template<class HW >
constexpr unsigned EEPROMStoredBitSet< HW >::JOURNAL_OFS
staticconstexprprivate
Initial value:
=
HW::virtual_cell_count() + HEADER_OFS

Definition at line 272 of file EEPROMStoredBitSet.hxx.

◆ MAGIC

template<class HW >
constexpr eeprom_t EEPROMStoredBitSet< HW >::MAGIC
staticconstexprprivate
Initial value:
=
0x02b26758U & EEPROM_MASK & (~MARKER_MASK)

Magic value in the zero offset certifies that we are correctly formatted.

Definition at line 264 of file EEPROMStoredBitSet.hxx.

◆ MARKER_MASK

template<class HW >
constexpr eeprom_t EEPROMStoredBitSet< HW >::MARKER_MASK
staticconstexprprivate
Initial value:
= eeprom_t(1)
<< ((sizeof(eeprom_t) * 8) - 1)

The MSB of each eeprom value is the marker.

This alternates between zero and one every time we wrap around.

Definition at line 257 of file EEPROMStoredBitSet.hxx.

◆ SECOND_MAGIC_OFS

template<class HW >
constexpr unsigned EEPROMStoredBitSet< HW >::SECOND_MAGIC_OFS = 1
staticconstexprprivate

Definition at line 270 of file EEPROMStoredBitSet.hxx.

◆ writeOffset_

template<class HW >
unsigned EEPROMStoredBitSet< HW >::writeOffset_
private

Definition at line 277 of file EEPROMStoredBitSet.hxx.


The documentation for this class was generated from the following file: