Skip to content
«interface»SolidSyslogBlockDeviceNorFlashBlockDeviceCore«interface»SolidSyslogNorFlash

File SolidSyslogNorFlashBlockDevice.h

FileList > Core > Interface > SolidSyslogNorFlashBlockDevice.h

  • #include <stddef.h>
  • #include "SolidSyslogExternC.h"

Classes

Type Name
struct SolidSyslogNorFlashBlockDeviceConfig

Detailed Description

A BlockDevice that keeps each block in one erase block of a NOR flash, with no filesystem between them.

It takes a run of the flash's blocks, and leaves the rest of the part to its owner.

The first bytes of each flash block hold a state word that is advanced only by clearing bits - in use, then disposed - and the block's data follows it. A block exists while its word reads exactly as in use. Any other value, a blank block's included, is a block that is not there. An erase of a disposed block that power cuts short could, rarely, stop with the in-use word restored over what the block held. The block then reads as in use: the store does not jam on it, and at worst reports a few errors for records it cannot read and delivers again records it had evicted unsent.

Acquire erases the block it takes, whatever the block reads as, and then marks it in use; Dispose only marks it disposed. No state claims a block is erased, because an erase cut short by power can leave cells that read as erased and are not, and an erase repeated is what clears them. So Acquire takes as long as an erase, and Dispose as long as one short program.

The flash does not say whether a program took, so every Append, WriteAt and state change is read back, and one that did not take fails the operation and is reported as SOLIDSYSLOG_CAT_NOR_FLASH_IO_FAILED.

Size finds the end of a block's data as its last byte that is not 0xFF, so whatever is appended must end on a byte that is not 0xFF. A BlockStore ends every record on one. A program that power cut short can leave a record whose bytes all read as written and are not, which only a SecurityPolicy that checks the record detects.

Exists and Size read the block's state. Read, Append and WriteAt do not: they go to the flash block whatever its state, so a Read of a block that is not there answers with what the cells hold. A BlockStore addresses only blocks it has acquired or found. A state that cannot be read is a block that is not there, as the BlockDevice role has no third answer to give.

Public Types Documentation

enum

How many bytes of each flash block the device keeps for the block's state, ahead of its data.

enum {
    SOLIDSYSLOG_NOR_FLASH_BLOCK_DEVICE_STATE_SIZE = 4
};


Public Functions Documentation

SolidSyslogNorFlashBlockDevice_Create

Keep a BlockDevice's blocks in config's run of flash blocks.

struct SolidSyslogBlockDevice * SolidSyslogNorFlashBlockDevice_Create (
    const struct SolidSyslogNorFlashBlockDeviceConfig * config
) 

Nothing is read or written until the device is used. A NULL config or Flash, a run that is not all within the flash, a flash block too small to hold any data and a BlockSize more than a flash block holds are each reported as SOLIDSYSLOG_CAT_BAD_CONFIG, and Create returns the shared NullBlockDevice. So does an exhausted pool, reported as SOLIDSYSLOG_CAT_POOL_EXHAUSTED.


SolidSyslogNorFlashBlockDevice_Destroy

Release the pool slot.

void SolidSyslogNorFlashBlockDevice_Destroy (
    struct SolidSyslogBlockDevice * base
) 

The flash is not touched: the blocks stay as they are for the next device created over them.



The documentation for this class was generated from the following file Core/Interface/SolidSyslogNorFlashBlockDevice.h