Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
bbram.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Google Inc
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DRIVERS_BBRAM_H
8#define ZEPHYR_INCLUDE_DRIVERS_BBRAM_H
9
10#include <device.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
21typedef int (*bbram_api_check_invalid)(const struct device *dev);
22
28typedef int (*bbram_api_check_standby_power)(const struct device *dev);
29
35typedef int (*bbram_api_check_power)(const struct device *dev);
36
42typedef int (*bbram_api_get_size)(const struct device *dev, size_t *size);
43
49typedef int (*bbram_api_read)(const struct device *dev, size_t offset, size_t size,
50 uint8_t *data);
51
57typedef int (*bbram_api_write)(const struct device *dev, size_t offset, size_t size,
58 const uint8_t *data);
59
60__subsystem struct bbram_driver_api {
67};
68
78__syscall int bbram_check_invalid(const struct device *dev);
79
80static inline int z_impl_bbram_check_invalid(const struct device *dev)
81{
82 const struct bbram_driver_api *api =
83 (const struct bbram_driver_api *)dev->api;
84
85 if (!api->check_invalid) {
86 return -ENOTSUP;
87 }
88
89 return api->check_invalid(dev);
90}
91
101__syscall int bbram_check_standby_power(const struct device *dev);
102
103static inline int z_impl_bbram_check_standby_power(const struct device *dev)
104{
105 const struct bbram_driver_api *api =
106 (const struct bbram_driver_api *)dev->api;
107
108 if (!api->check_standby_power) {
109 return -ENOTSUP;
110 }
111
112 return api->check_standby_power(dev);
113}
114
125__syscall int bbram_check_power(const struct device *dev);
126
127static inline int z_impl_bbram_check_power(const struct device *dev)
128{
129 const struct bbram_driver_api *api =
130 (const struct bbram_driver_api *)dev->api;
131
132 if (!api->check_power) {
133 return -ENOTSUP;
134 }
135
136 return api->check_power(dev);
137}
138
146__syscall int bbram_get_size(const struct device *dev, size_t *size);
147
148static inline int z_impl_bbram_get_size(const struct device *dev, size_t *size)
149{
150 const struct bbram_driver_api *api =
151 (const struct bbram_driver_api *)dev->api;
152
153 if (!api->get_size) {
154 return -ENOTSUP;
155 }
156
157 return api->get_size(dev, size);
158}
159
169__syscall int bbram_read(const struct device *dev, size_t offset, size_t size,
170 uint8_t *data);
171
172static inline int z_impl_bbram_read(const struct device *dev, size_t offset,
173 size_t size, uint8_t *data)
174{
175 const struct bbram_driver_api *api =
176 (const struct bbram_driver_api *)dev->api;
177
178 if (!api->read) {
179 return -ENOTSUP;
180 }
181
182 return api->read(dev, offset, size, data);
183}
184
194__syscall int bbram_write(const struct device *dev, size_t offset, size_t size,
195 const uint8_t *data);
196
197static inline int z_impl_bbram_write(const struct device *dev, size_t offset,
198 size_t size, const uint8_t *data)
199{
200 const struct bbram_driver_api *api =
201 (const struct bbram_driver_api *)dev->api;
202
203 if (!api->write) {
204 return -ENOTSUP;
205 }
206
207 return api->write(dev, offset, size, data);
208}
209
216int bbram_emul_set_invalid(const struct device *dev, bool is_invalid);
217
218int bbram_emul_set_standby_power_state(const struct device *dev, bool failure);
219
220int bbram_emul_set_power_state(const struct device *dev, bool failure);
221
222#ifdef __cplusplus
223}
224#endif
225
226#include <syscalls/bbram.h>
227
228#endif /* ZEPHYR_INCLUDE_DRIVERS_BBRAM_H */
int(* bbram_api_get_size)(const struct device *dev, size_t *size)
Definition: bbram.h:42
int bbram_emul_set_standby_power_state(const struct device *dev, bool failure)
int(* bbram_api_check_power)(const struct device *dev)
Definition: bbram.h:35
int(* bbram_api_read)(const struct device *dev, size_t offset, size_t size, uint8_t *data)
Definition: bbram.h:49
int(* bbram_api_write)(const struct device *dev, size_t offset, size_t size, const uint8_t *data)
Definition: bbram.h:57
int bbram_write(const struct device *dev, size_t offset, size_t size, const uint8_t *data)
int bbram_check_invalid(const struct device *dev)
Check if BBRAM is invalid.
int bbram_check_power(const struct device *dev)
Check for V CC1 power failure.
int bbram_check_standby_power(const struct device *dev)
Check for standby (Volt SBY) power failure.
int bbram_read(const struct device *dev, size_t offset, size_t size, uint8_t *data)
int bbram_get_size(const struct device *dev, size_t *size)
int bbram_emul_set_power_state(const struct device *dev, bool failure)
int bbram_emul_set_invalid(const struct device *dev, bool is_invalid)
int(* bbram_api_check_invalid)(const struct device *dev)
Definition: bbram.h:21
int(* bbram_api_check_standby_power)(const struct device *dev)
Definition: bbram.h:28
#define ENOTSUP
Definition: errno.h:115
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
Definition: bbram.h:60
bbram_api_get_size get_size
Definition: bbram.h:64
bbram_api_write write
Definition: bbram.h:66
bbram_api_read read
Definition: bbram.h:65
bbram_api_check_standby_power check_standby_power
Definition: bbram.h:62
bbram_api_check_invalid check_invalid
Definition: bbram.h:61
bbram_api_check_power check_power
Definition: bbram.h:63
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
const void * api
Definition: device.h:373
static fdata_t data[2]
Definition: test_fifo_contexts.c:15