![]() |
DVBCore
20.3.0
DVBCore Documentation
|
Non-volatile memory database functions. More...
#include <string.h>
#include <techtype.h>
#include <dbgfuncs.h>
#include "dba.h"
#include "dba_nvm.h"
#include "stbdbnvm.h"
#include "stbnvm.h"
#include "stbcsum.h"
#include "stbheap.h"
Go to the source code of this file.
Classes | |
struct | NVM_BLOCK_REC |
struct | NVM_RECOVER_REC |
struct | NVM_DB_STATUS_REC |
struct | NVM_CACHE_STATUS_REC |
Macros | |
#define | BLOCK_PAYLOAD_SIZE 20 |
#define | FIRST_BLOCK_MASK 0x80 |
#define | LINKED_BLOCK_MASK 0x40 |
#define | RECID_BLOCK_MASK 0x3f |
Functions | |
void | STB_InitNVMAccess (U16BIT offset) |
Initialises parameters needed for NVM block access. More... | |
void | STB_InitNVMMap (void) |
Initialises parameters needed for NVM block access (calcs num blocks if required) | |
BOOLEAN | STB_CheckNVMDatabaseIntegrity (void) |
Reads each database block from NVM and checks its checksum. If the data has already been read into the RAM cache then the data will be checked from here, but this data has been read from NVM and is an exact copy, so the check is still valid. Note: It's assumed that STB_InitNVMAccess has already been called. More... | |
void | STB_SetNVMAccessRAM (U8BIT *ram_ptr) |
Sets all DB NVM access to RAM block supplied instead of NVM (cancel if NULL). More... | |
U8BIT * | STB_GetNVMAccessRAM (void) |
Returns the current RAM pointer used for DB NVM access. More... | |
U16BIT | STB_GetNVMBlockCount (void) |
Returns total number of NVM database blocks. More... | |
U16BIT | STB_GetNVMBlocksUsed (void) |
Returns total number of NVM database blocks in use. More... | |
U16BIT | STB_GetNVMBlockSize (void) |
Returns the size of an NVM database block, in bytes. More... | |
U16BIT | STB_GetNVMBlocksNeeded (U16BIT size) |
Returns number of NVM database blocks needed for specified number of bytes. More... | |
U16BIT | STB_CreateNVMRecord (U8BIT rec_id, U16BIT size) |
Creates a record of the type given in NVM by overwriting invalid blocks. More... | |
void | STB_DestroyNVMRecord (U16BIT block_no) |
Destroys NVM record by marking all NVM blocks used by the record as invalid. More... | |
void | STB_SetNextNVMBlock (U16BIT block_no, U16BIT next_block) |
Repairs NVM linked list by pointing the NVM record starting at the specified block number to the record starting at the specified next block number. More... | |
U16BIT | STB_GetNextNVMBlock (U16BIT block_no) |
Returns the block number of the next NVM record pointed to by the NVM record starting at the specified block number. More... | |
U16BIT | STB_FindNVMRecordFromId (U8BIT rec_id, U16BIT last_blk) |
Finds next record of the type given in NVM. More... | |
void | STB_NVMChanged (BOOLEAN state) |
void | STB_NVMFlushCache (BOOLEAN clear) |
Flush cached changes. More... | |
void | STB_NVMSave (void) |
Saves the RAM cache data to NVM. | |
void | STB_SetNVMRecordString (U16BIT block_no, U16BIT offset, U16BIT size, U8BIT *string) |
Writes the specified value into a field of a NVM record. More... | |
void | STB_SetNVMRecordNumber (U16BIT block_no, U16BIT offset, U16BIT size, U32BIT value) |
Writes the specified value into a field of a NVM record. More... | |
U8BIT * | STB_GetNVMRecordString (U16BIT block_no, U16BIT offset, U16BIT size) |
Reads string of a field from a NVM record. More... | |
U32BIT | STB_GetNVMRecordNumber (U16BIT block_no, U16BIT offset, U16BIT size) |
Reads the specified value of a field from a NVM record. More... | |
void | STB_WriteNVMData (U16BIT offset, U16BIT size, U8BIT *data_ptr) |
Writes the given data to NVM. More... | |
BOOLEAN | STB_ReadNVMData (U16BIT offset, U16BIT size, U8BIT *data_ptr) |
Reads data from the NVM into the given buffer. More... | |
BOOLEAN STB_CheckNVMDatabaseIntegrity | ( | void | ) |
Reads each database block from NVM and checks its checksum. If the data has already been read into the RAM cache then the data will be checked from here, but this data has been read from NVM and is an exact copy, so the check is still valid. Note: It's assumed that STB_InitNVMAccess has already been called.
Definition at line 564 of file stbdbnvm.c.
U16BIT STB_CreateNVMRecord | ( | U8BIT | rec_id, |
U16BIT | size | ||
) |
Creates a record of the type given in NVM by overwriting invalid blocks.
U8BIT | rec_id - the ID of the record to be created |
U16BIT | size - the size the record to be created (in bytes) |
Definition at line 731 of file stbdbnvm.c.
void STB_DestroyNVMRecord | ( | U16BIT | block_no | ) |
Destroys NVM record by marking all NVM blocks used by the record as invalid.
U16BIT | block_no - the first NVM block number of the record |
Definition at line 805 of file stbdbnvm.c.
U16BIT STB_FindNVMRecordFromId | ( | U8BIT | rec_id, |
U16BIT | last_blk | ||
) |
Finds next record of the type given in NVM.
U8BIT | rec_id - the ID of the record |
U16BIT | last_blk - last block found (NVM_INVALID_BLOCK_ID if none) |
Definition at line 969 of file stbdbnvm.c.
U16BIT STB_GetNextNVMBlock | ( | U16BIT | block_no | ) |
Returns the block number of the next NVM record pointed to by the NVM record starting at the specified block number.
U16BIT | block_no - the NVM block number of the current record |
Definition at line 918 of file stbdbnvm.c.
U8BIT* STB_GetNVMAccessRAM | ( | void | ) |
Returns the current RAM pointer used for DB NVM access.
Definition at line 619 of file stbdbnvm.c.
U16BIT STB_GetNVMBlockCount | ( | void | ) |
Returns total number of NVM database blocks.
Definition at line 637 of file stbdbnvm.c.
U16BIT STB_GetNVMBlockSize | ( | void | ) |
Returns the size of an NVM database block, in bytes.
Definition at line 686 of file stbdbnvm.c.
U16BIT STB_GetNVMBlocksNeeded | ( | U16BIT | size | ) |
Returns number of NVM database blocks needed for specified number of bytes.
U16BIT | size - the size (in bytes) |
Definition at line 704 of file stbdbnvm.c.
U16BIT STB_GetNVMBlocksUsed | ( | void | ) |
Returns total number of NVM database blocks in use.
Definition at line 661 of file stbdbnvm.c.
U32BIT STB_GetNVMRecordNumber | ( | U16BIT | block_no, |
U16BIT | offset, | ||
U16BIT | size | ||
) |
Reads the specified value of a field from a NVM record.
U16BIT | block_no - the first NVM block number of the record |
U16BIT | offset - field byte offset into the record |
U16BIT | size - field byte size in the record |
Definition at line 1208 of file stbdbnvm.c.
U8BIT* STB_GetNVMRecordString | ( | U16BIT | block_no, |
U16BIT | offset, | ||
U16BIT | size | ||
) |
Reads string of a field from a NVM record.
U16BIT | block_no - the first NVM block number of the record |
U16BIT | offset - field byte offset into the record |
U16BIT | size - field byte size in the record |
Definition at line 1171 of file stbdbnvm.c.
void STB_InitNVMAccess | ( | U16BIT | offset | ) |
Initialises parameters needed for NVM block access.
U16BIT | offset - offset to NVM blocks in bytes |
Definition at line 472 of file stbdbnvm.c.
void STB_NVMFlushCache | ( | BOOLEAN | clear | ) |
Flush cached changes.
clear | TRUE clear the cache after flushing cached changes, FALSE do not clear the cache |
Definition at line 1017 of file stbdbnvm.c.
BOOLEAN STB_ReadNVMData | ( | U16BIT | offset, |
U16BIT | size, | ||
U8BIT * | data_ptr | ||
) |
Reads data from the NVM into the given buffer.
U16BIT | offset - byte offset from which to read the data |
U16BIT | size - number of bytes of data to read |
U8BIT* | data_ptr - address of buffer to read data into |
Definition at line 1297 of file stbdbnvm.c.
void STB_SetNextNVMBlock | ( | U16BIT | block_no, |
U16BIT | next_block | ||
) |
Repairs NVM linked list by pointing the NVM record starting at the specified block number to the record starting at the specified next block number.
U16BIT | block_no - the NVM block number of the current record |
U16BIT | next_block - the NVM block number of the next record |
Definition at line 865 of file stbdbnvm.c.
void STB_SetNVMAccessRAM | ( | U8BIT * | ram_ptr | ) |
Sets all DB NVM access to RAM block supplied instead of NVM (cancel if NULL).
U8BIT* | ram_ptr - pointer to RAM area |
Definition at line 599 of file stbdbnvm.c.
void STB_SetNVMRecordNumber | ( | U16BIT | block_no, |
U16BIT | offset, | ||
U16BIT | size, | ||
U32BIT | value | ||
) |
Writes the specified value into a field of a NVM record.
U16BIT | block_no - the first NVM block number of the record |
U16BIT | offset - field bit offset into the record |
U16BIT | size - field bit size in the record |
U32BIT | value - the numeric value of the field |
Definition at line 1120 of file stbdbnvm.c.
void STB_SetNVMRecordString | ( | U16BIT | block_no, |
U16BIT | offset, | ||
U16BIT | size, | ||
U8BIT * | string | ||
) |
Writes the specified value into a field of a NVM record.
U16BIT | block_no - the first NVM block number of the record |
U16BIT | offset - field bit offset into the record |
U16BIT | size - field bit size in the record |
U8BIT* | string - the string value of the field |
Definition at line 1074 of file stbdbnvm.c.
void STB_WriteNVMData | ( | U16BIT | offset, |
U16BIT | size, | ||
U8BIT * | data_ptr | ||
) |
Writes the given data to NVM.
U16BIT | offset - byte offset at which to write the data |
U16BIT | size - number of bytes of data to write |
U8BIT* | data_ptr - pointer to the data to be written |
Definition at line 1262 of file stbdbnvm.c.