Update 'Persistent storage'
parent
741416b06b
commit
81278ce44e
|
@ -30,7 +30,7 @@ After this data, the "mode data table" follows, consisting of 16 entries of 12 b
|
|||
struct mode_data {
|
||||
uint16_t version;
|
||||
uint16_t datasize;
|
||||
uint28_t flashoffset; // from beginning of flash
|
||||
uint28_t flashoffset;
|
||||
uint4_t modeid;
|
||||
uint32_t data_djb2;
|
||||
};
|
||||
|
@ -41,3 +41,11 @@ The `flashoffset` is relative to the beginning of flash. `version` is the versio
|
|||
Mode data blocks are allocated from the start of the last flash page (which is implementation defined), filling it up, and then continuing to the block before. First, smaller mode data blocks are allocated, ending with the larger ones.
|
||||
|
||||
### Storage API
|
||||
|
||||
Each mode has a `storage` field, which is a structure describing the following items (one constant and three callback functions, used by the storage subsystem):
|
||||
* "storage class": maximum size of the mode's data block
|
||||
* "get size" function: gets the current size of the data as it is now
|
||||
* "get data": copies the mode data into a block
|
||||
* "is dirty": return true to indicate the data has been changed and should be saved on the next 'flush'
|
||||
|
||||
Additionally, modes can use the `storage_mode_get_info(int mode) and `storage_mode_read(int mode, void* dest, size_t offset, size_t maxlen)` functions to query and read their saved data. `storage_mode_get_info` returns a struct containing the size of the saved data, as well as the version of the mode that saved it.
|
Loading…
Reference in New Issue