12#ifndef ZEPHYR_INCLUDE_DRIVERS_RETAINED_MEM_
13#define ZEPHYR_INCLUDE_DRIVERS_RETAINED_MEM_
27BUILD_ASSERT(!(
sizeof(
off_t) >
sizeof(
size_t)),
28 "Size of off_t must be equal or less than size of size_t");
60 const uint8_t *buffer,
size_t size);
97static inline ssize_t z_impl_retained_mem_size(
const struct device *dev)
101 return api->
size(dev);
117static inline int z_impl_retained_mem_read(
const struct device *dev,
off_t offset,
128 area_size = api->
size(dev);
130 if (offset < 0 || size > area_size || (area_size -
size) < (
size_t)offset) {
134 return api->
read(dev, offset, buffer,
size);
151static inline int z_impl_retained_mem_write(
const struct device *dev,
off_t offset,
162 area_size = api->
size(dev);
164 if (offset < 0 || size > area_size || (area_size -
size) < (
size_t)offset) {
168 return api->
write(dev, offset, buffer,
size);
180static inline int z_impl_retained_mem_clear(
const struct device *dev)
184 return api->
clear(dev);
195#include <syscalls/retained_mem.h>
int(* retained_mem_write_api)(const struct device *dev, off_t offset, const uint8_t *buffer, size_t size)
Callback API to write to retained memory area.
Definition: retained_mem.h:59
int retained_mem_write(const struct device *dev, off_t offset, const uint8_t *buffer, size_t size)
Writes data to the Retained memory area - underlying data does not need to be cleared prior to writin...
int(* retained_mem_clear_api)(const struct device *dev)
Callback API to clear retained memory area (reset all data to 0x00).
Definition: retained_mem.h:67
int retained_mem_read(const struct device *dev, off_t offset, uint8_t *buffer, size_t size)
Reads data from the Retained memory area.
ssize_t(* retained_mem_size_api)(const struct device *dev)
Callback API to get size of retained memory area.
Definition: retained_mem.h:44
int retained_mem_clear(const struct device *dev)
Clears data in the retained memory area by setting it to 0x00.
ssize_t retained_mem_size(const struct device *dev)
Returns the size of the retained memory area.
int(* retained_mem_read_api)(const struct device *dev, off_t offset, uint8_t *buffer, size_t size)
Callback API to read from retained memory area.
Definition: retained_mem.h:51
#define EINVAL
Invalid argument.
Definition: errno.h:61
__SIZE_TYPE__ ssize_t
Definition: types.h:28
__INTPTR_TYPE__ off_t
Definition: types.h:36
Size of off_t must be equal or less than size of size_t
Definition: retained_mem.h:28
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition: device.h:399
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:405
Retained memory driver API API which can be used by a device to store data in a retained memory area.
Definition: retained_mem.h:80
retained_mem_size_api size
Definition: retained_mem.h:81
retained_mem_clear_api clear
Definition: retained_mem.h:84
retained_mem_read_api read
Definition: retained_mem.h:82
retained_mem_write_api write
Definition: retained_mem.h:83