Non-Volatile Memory Storage adapter.
More...
|
|
void | ad_nvms_init (void) |
| | Initialize NVMS adapter.
|
| |
| nvms_t | ad_nvms_open (nvms_partition_id_t id) |
| | Open partition to read/write access. More...
|
| |
| size_t | ad_nvms_get_size (nvms_t handle) |
| | Get partition size. More...
|
| |
| int | ad_nvms_read (nvms_t handle, uint32_t addr, uint8_t *buf, uint32_t len) |
| | Read partition data. More...
|
| |
| int | ad_nvms_write (nvms_t handle, uint32_t addr, const uint8_t *buf, uint32_t size) |
| | Writes data to partition. More...
|
| |
| bool | ad_nvms_erase_region (nvms_t handle, uint32_t addr, size_t size) |
| | Erase partition region. More...
|
| |
| size_t | ad_nvms_get_pointer (nvms_t handle, uint32_t addr, size_t size, const void **ptr) |
| | Get direct read buffer pointer. More...
|
| |
| size_t | ad_nvms_erase_size (nvms_t handle) |
| | Get partition erase size. More...
|
| |
| size_t | ad_nvms_get_partition_count (void) |
| | Get partition count. More...
|
| |
| bool | ad_nvms_get_partition_info (size_t index, partition_entry_t *info) |
| | Get partition info. More...
|
| |
| bool | ad_nvms_no_cache_flushing (nvms_t handle, uint32_t base, uint32_t size) |
| | Control cache flushing on modifications (writes or erases) to a partition. More...
|
| |
| __STATIC_INLINE void | ad_nvms_mandatory_cache_flushing (void) |
| |
| void | ad_nvms_flush (nvms_t handle, bool free_mem) |
| | Flush all data buffered in RAM to partition. More...
|
| |
Non-Volatile Memory Storage adapter.
◆ ad_nvms_erase_region()
| bool ad_nvms_erase_region |
( |
nvms_t |
handle, |
|
|
uint32_t |
addr, |
|
|
size_t |
size |
|
) |
| |
Erase partition region.
- Note
- : All sectors that have offset in range of <addr, add + size) will be erased.
- Parameters
-
| [in] | handle | partition handle |
| [in] | addr | starting offset of sector |
| [in] | size | number of bytes to erase |
- Returns
- true on success
◆ ad_nvms_erase_size()
| size_t ad_nvms_erase_size |
( |
nvms_t |
handle | ) |
|
Get partition erase size.
- Parameters
-
| [in] | handle | partition handle |
- Returns
- minimum size that can be erased
◆ ad_nvms_flush()
| void ad_nvms_flush |
( |
nvms_t |
handle, |
|
|
bool |
free_mem |
|
) |
| |
Flush all data buffered in RAM to partition.
In order to improve erase/write performance, data may not be written to storage device immediately. Call this function to make sure all data is written.
- Parameters
-
| [in] | handle | partition handle |
| [in] | free_mem | true - free allocated memory for cached data, false - flush without freeing memory for cached data. Copy of data still exists in RAM cache |
◆ ad_nvms_get_partition_count()
| size_t ad_nvms_get_partition_count |
( |
void |
| ) |
|
Get partition count.
- Returns
- Number of partitions
◆ ad_nvms_get_partition_info()
Get partition info.
- Returns
- true if partition exists, false otherwise
◆ ad_nvms_get_pointer()
| size_t ad_nvms_get_pointer |
( |
nvms_t |
handle, |
|
|
uint32_t |
addr, |
|
|
size_t |
size, |
|
|
const void ** |
ptr |
|
) |
| |
Get direct read buffer pointer.
Function will fill ptr with CPU address that can be used to directly access partition data. Parameter size specifies how many bytes caller wants to access. Note however that returned size can be smaller if addr + size exceeds partition size. This value can also be smaller if partition uses wear leveling that results in non linear data storage. If partition driver does not support direct mapping function will return 0 and no valid ptr will be returned.
- Parameters
-
| [in] | handle | partition handle |
| [in] | addr | requested address |
| [in] | size | number of bytes |
| [out] | ptr | pointer to store direct address |
- Returns
- number of bytes that can be accessed with this pointer
◆ ad_nvms_get_size()
| size_t ad_nvms_get_size |
( |
nvms_t |
handle | ) |
|
Get partition size.
- Returns
- size in bytes of partition
◆ ad_nvms_mandatory_cache_flushing()
| __STATIC_INLINE void ad_nvms_mandatory_cache_flushing |
( |
void |
| ) |
|
◆ ad_nvms_no_cache_flushing()
| bool ad_nvms_no_cache_flushing |
( |
nvms_t |
handle, |
|
|
uint32_t |
base, |
|
|
uint32_t |
size |
|
) |
| |
Control cache flushing on modifications (writes or erases) to a partition.
This function can be used to define a partition region that will not trigger cache flushing when writes or erases occur in that region. Only one such partition region can be active at any time, in total.
This feature is useful when the programmer knows in advance that a partition region is going to be updated (e.g. firmware update). However, reads from that region should be avoided, as they might lead to cache incoherency.
- Note
- The effect of this function is at ad_flash_* layer and higher. For example, direct use of the hw_qspi_* API will not be affected by the use of this function.
- Parameters
-
| [in] | handle | Partition handle. |
| [in] | base | Starting offset of the partition region that should not trigger cache flushes. |
| [in] | size | The size of the partition region that should not trigger cache flushes. If size is such that it would extend beyond the end of the partition, the region size is truncated to match the end of the partition. If size is 0, selective cache flushing is disabled. |
- Returns
- true if partition exists and base , false otherwise
- See also
- ad_nvms_mandatory_cache_flushing()
◆ ad_nvms_open()
Open partition to read/write access.
There can be only one partition with given id.
- Parameters
-
| [in] | id | partition to get access to |
- Returns
- handle to use for partition access, NULL if partition does not exists
◆ ad_nvms_read()
| int ad_nvms_read |
( |
nvms_t |
handle, |
|
|
uint32_t |
addr, |
|
|
uint8_t * |
buf, |
|
|
uint32_t |
len |
|
) |
| |
Read partition data.
- Parameters
-
| [in] | handle | partition handle |
| [in] | addr | starting offset |
| [out] | buf | buffer to read data to |
| [in] | len | number of bytes to read |
- Returns
- number of bytes read, < 0 in case of error
◆ ad_nvms_write()
| int ad_nvms_write |
( |
nvms_t |
handle, |
|
|
uint32_t |
addr, |
|
|
const uint8_t * |
buf, |
|
|
uint32_t |
size |
|
) |
| |
Writes data to partition.
This function allows to write any number of bytes to partition.
- Parameters
-
| [in] | handle | partition handle |
| [in] | addr | offset in partition to write data to |
| [in] | buf | pointer to data to write |
| [in] | size | number of bytes to write |
return number of bytes written, < 0 if case of error