34#ifndef _FREERTOS_DRIVERS_COMMON_EEPROMEMULATION_HXX_
35#define _FREERTOS_DRIVERS_COMMON_EEPROMEMULATION_HXX_
173 void write(
unsigned int offset,
const void *buf,
size_t len)
OVERRIDE;
180 void read(
unsigned int offset,
void *buf,
size_t len)
OVERRIDE;
187 #define EEPROMEMU_FLASH_SIZE ((uintptr_t)(&__eeprom_end - &__eeprom_start))
233 void write_fblock(
unsigned int index,
const uint8_t data[]);
241 bool read_fblock(
unsigned int index, uint8_t data[]);
292 virtual const uint32_t*
block(
unsigned sector,
unsigned offset) = 0;
309 virtual void flash_program(
unsigned sector,
unsigned start_block, uint32_t *data, uint32_t byte_count) = 0;
#define EEPROMEMU_FLASH_SIZE
Total FLASH memory size to use for EEPROM Emulation.
const char __eeprom_end
Linker-defined symbol where in the memory space (flash) the eeprom emulation data ends.
const char __eeprom_start
Linker-defined symbol where in the memory space (flash) the eeprom emulation data starts.
Emulates EEPROM in FLASH for the Tiva, LPC17xx and LPC40xx platforms.
uint8_t activeSector_
Index of the active sector.
bool read_fblock(unsigned int index, uint8_t data[])
Read from the EEPROM on a native block boundary.
static const size_t HEADER_BLOCK_COUNT
number of reserved header blocks
virtual const uint32_t * block(unsigned sector, unsigned offset)=0
Computes the pointer to load the data stored in a specific block from.
static const uint32_t MAGIC_ERASED
magic marker for an erased block
virtual void flash_program(unsigned sector, unsigned start_block, uint32_t *data, uint32_t byte_count)=0
Simple hardware abstraction for FLASH program API.
void write(unsigned int offset, const void *buf, size_t len) OVERRIDE
Write to the EEPROM.
static const uint32_t MAGIC_USED
magic marker for a used block
unsigned next_active()
Get the next active sector pointer.
static const bool SHADOW_IN_RAM
Shadow the EEPROM data in RAM.
void write_fblock(unsigned int index, const uint8_t data[])
Write to the EEPROM on a native block boundary.
static const size_t BLOCK_SIZE
block size in bytes
MagicBlockIndex
Raw block indexes within a sector to mark the state of the sector.
@ MAGIC_DIRTY_INDEX
dirty metadata block index: programmed when we start writing to the sector (i.e.
@ MAGIC_USED_INDEX
used metadata block index: programmed when the data has been copied to a new sector.
@ MAGIC_COUNT
total metadata block count
@ MAGIC_INTACT_INDEX
intact metadata block index: programmed when the data in this sector is authoritative.
@ MAGIC_FIRST_INDEX
first metadata block index
static constexpr unsigned MAX_BLOCK_SIZE
Maximum byte size of a single block.
const uint16_t rawBlockCount_
How many blocks are there in a sector.
static const uint32_t MAGIC_DIRTY
magic marker for a block that we are transitioning to intact
EEPROMEmulation()
Default constructor.
bool shadowInRam_
local copy of SHADOW_IN_RAM which we can manipulate at run time.
static const size_t SECTOR_SIZE
Sector size in bytes.
void read(unsigned int offset, void *buf, size_t len) OVERRIDE
Read from the EEPROM.
size_t availableSlots_
Number of available (writable) slots for new data in the active sector.
virtual void flash_erase(unsigned sector)=0
Simple hardware abstraction for FLASH erase API.
void mount()
Mount the EEPROM file.
static const size_t BYTES_PER_BLOCK
useful data bytes size in bytes
static const uint32_t MAGIC_INTACT
magic marker for an intact block
uint8_t * shadow_
pointer to RAM for shadowing EEPROM.
unsigned slot_count()
Total number of EEPROM slots in a FLASH sector.
const uint8_t sectorCount_
Total number of sectors available.
unsigned sector_count()
Total number of FLASH sectors being used for emulation.
void updated_notification()
This function will be called after every write.
~EEPROMEmulation()
Destructor.
Common base class for all EEPROM access.
size_t file_size()
Get the maximum file size of the EEPROM file.
const char * name
device name
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
Device * next
next device in linked list