Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
edac.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_DRIVERS_EDAC_H_
13#define ZEPHYR_INCLUDE_DRIVERS_EDAC_H_
14
15#include <sys/types.h>
16
17typedef void (*edac_notify_callback_f)(const struct device *dev, void *data);
18
33};
34
40__subsystem struct edac_driver_api {
41 /* Error Injection API is disabled by default */
42 int (*inject_set_param1)(const struct device *dev, uint64_t value);
43 int (*inject_get_param1)(const struct device *dev, uint64_t *value);
44 int (*inject_set_param2)(const struct device *dev, uint64_t value);
45 int (*inject_get_param2)(const struct device *dev, uint64_t *value);
46 int (*inject_set_error_type)(const struct device *dev, uint32_t value);
47 int (*inject_get_error_type)(const struct device *dev, uint32_t *value);
48 int (*inject_error_trigger)(const struct device *dev);
49
50 /* Error Logging API */
51 int (*ecc_error_log_get)(const struct device *dev, uint64_t *value);
52 int (*ecc_error_log_clear)(const struct device *dev);
53 int (*parity_error_log_get)(const struct device *dev, uint64_t *value);
54 int (*parity_error_log_clear)(const struct device *dev);
55
56 /* Error stats API */
57 int (*errors_cor_get)(const struct device *dev);
58 int (*errors_uc_get)(const struct device *dev);
59
60 /* Notification callback API */
61 int (*notify_cb_set)(const struct device *dev,
63};
64
65/* Optional interfaces */
66
78static inline int edac_inject_set_param1(const struct device *dev,
79 uint64_t value)
80{
81 const struct edac_driver_api *api =
82 (const struct edac_driver_api *)dev->api;
83
84 if (api->inject_set_param1 == NULL) {
85 return -ENOSYS;
86 }
87
88 return api->inject_set_param1(dev, value);
89}
90
102static inline int edac_inject_get_param1(const struct device *dev,
103 uint64_t *value)
104{
105 const struct edac_driver_api *api =
106 (const struct edac_driver_api *)dev->api;
107
108 if (api->inject_get_param1 == NULL) {
109 return -ENOSYS;
110 }
111
112 return api->inject_get_param1(dev, value);
113
114}
115
127static inline int edac_inject_set_param2(const struct device *dev,
128 uint64_t value)
129{
130 const struct edac_driver_api *api =
131 (const struct edac_driver_api *)dev->api;
132
133 if (api->inject_set_param2 == NULL) {
134 return -ENOSYS;
135 }
136
137 return api->inject_set_param2(dev, value);
138}
139
149static inline int edac_inject_get_param2(const struct device *dev,
150 uint64_t *value)
151{
152 const struct edac_driver_api *api =
153 (const struct edac_driver_api *)dev->api;
154
155 if (api->inject_get_param2 == NULL) {
156 return -ENOSYS;
157 }
158
159 return api->inject_get_param2(dev, value);
160}
161
173static inline int edac_inject_set_error_type(const struct device *dev,
174 uint32_t error_type)
175{
176 const struct edac_driver_api *api =
177 (const struct edac_driver_api *)dev->api;
178
179 if (api->inject_set_error_type == NULL) {
180 return -ENOSYS;
181 }
182
183 return api->inject_set_error_type(dev, error_type);
184}
185
197static inline int edac_inject_get_error_type(const struct device *dev,
198 uint32_t *error_type)
199{
200 const struct edac_driver_api *api =
201 (const struct edac_driver_api *)dev->api;
202
203 if (api->inject_get_error_type == NULL) {
204 return -ENOSYS;
205 }
206
207 return api->inject_get_error_type(dev, error_type);
208}
209
220static inline int edac_inject_error_trigger(const struct device *dev)
221{
222 const struct edac_driver_api *api =
223 (const struct edac_driver_api *)dev->api;
224
225 if (api->inject_error_trigger == NULL) {
226 return -ENOSYS;
227 }
228
229 return api->inject_error_trigger(dev);
230}
231
232/* Mandatory interfaces */
233
245static inline int edac_ecc_error_log_get(const struct device *dev,
246 uint64_t *value)
247{
248 const struct edac_driver_api *api =
249 (const struct edac_driver_api *)dev->api;
250
251 if (api->ecc_error_log_get == NULL) {
252 return -ENOSYS;
253 }
254
255 return api->ecc_error_log_get(dev, value);
256}
257
268static inline int edac_ecc_error_log_clear(const struct device *dev)
269{
270 const struct edac_driver_api *api =
271 (const struct edac_driver_api *)dev->api;
272
273 if (api->ecc_error_log_clear == NULL) {
274 return -ENOSYS;
275 }
276
277 return api->ecc_error_log_clear(dev);
278}
279
291static inline int edac_parity_error_log_get(const struct device *dev,
292 uint64_t *value)
293{
294 const struct edac_driver_api *api =
295 (const struct edac_driver_api *)dev->api;
296
297 if (api->parity_error_log_get == NULL) {
298 return -ENOSYS;
299 }
300
301 return api->parity_error_log_get(dev, value);
302}
303
314static inline int edac_parity_error_log_clear(const struct device *dev)
315{
316 const struct edac_driver_api *api =
317 (const struct edac_driver_api *)dev->api;
318
319 if (api->parity_error_log_clear == NULL) {
320 return -ENOSYS;
321 }
322
323 return api->parity_error_log_clear(dev);
324}
325
334static inline int edac_errors_cor_get(const struct device *dev)
335{
336 const struct edac_driver_api *api =
337 (const struct edac_driver_api *)dev->api;
338
339 if (api->errors_cor_get == NULL) {
340 return -ENOSYS;
341 }
342
343 return api->errors_cor_get(dev);
344}
345
354static inline int edac_errors_uc_get(const struct device *dev)
355{
356 const struct edac_driver_api *api =
357 (const struct edac_driver_api *)dev->api;
358
359 if (api->errors_uc_get == NULL) {
360 return -ENOSYS;
361 }
362
363 return api->errors_uc_get(dev);
364}
365
377static inline int edac_notify_callback_set(const struct device *dev,
379{
380 const struct edac_driver_api *api = dev->api;
381
382 if (api->notify_cb_set == NULL) {
383 return -ENOSYS;
384 }
385
386 return api->notify_cb_set(dev, cb);
387}
388
393#endif /* ZEPHYR_INCLUDE_DRIVERS_EDAC_H_ */
void(* edac_notify_callback_f)(const struct device *dev, void *data)
Definition: edac.h:17
void
Definition: eswifi_shell.c:15
static int edac_inject_set_error_type(const struct device *dev, uint32_t error_type)
Set error type value.
Definition: edac.h:173
static int edac_notify_callback_set(const struct device *dev, edac_notify_callback_f cb)
Definition: edac.h:377
static int edac_inject_get_param2(const struct device *dev, uint64_t *value)
Get injection parameter param2.
Definition: edac.h:149
edac_error_type
EDAC error type.
Definition: edac.h:28
static int edac_ecc_error_log_get(const struct device *dev, uint64_t *value)
Get ECC Error Log.
Definition: edac.h:245
static int edac_inject_get_param1(const struct device *dev, uint64_t *value)
Get injection parameter param1.
Definition: edac.h:102
static int edac_inject_set_param2(const struct device *dev, uint64_t value)
Set injection parameter param2.
Definition: edac.h:127
static int edac_parity_error_log_get(const struct device *dev, uint64_t *value)
Get Parity Error Log.
Definition: edac.h:291
static int edac_ecc_error_log_clear(const struct device *dev)
Clear ECC Error Log.
Definition: edac.h:268
static int edac_parity_error_log_clear(const struct device *dev)
Clear Parity Error Log.
Definition: edac.h:314
static int edac_inject_set_param1(const struct device *dev, uint64_t value)
Set injection parameter param1.
Definition: edac.h:78
static int edac_errors_cor_get(const struct device *dev)
Get number of correctable errors.
Definition: edac.h:334
static int edac_errors_uc_get(const struct device *dev)
Get number of uncorrectable errors.
Definition: edac.h:354
static int edac_inject_error_trigger(const struct device *dev)
Set injection control.
Definition: edac.h:220
static int edac_inject_get_error_type(const struct device *dev, uint32_t *error_type)
Get error type value.
Definition: edac.h:197
@ EDAC_ERROR_TYPE_DRAM_UC
Definition: edac.h:32
@ EDAC_ERROR_TYPE_DRAM_COR
Definition: edac.h:30
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
#define ENOSYS
Definition: errno.h:83
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
const void * api
Definition: device.h:373
EDAC driver API.
Definition: edac.h:40
int(* inject_get_error_type)(const struct device *dev, uint32_t *value)
Definition: edac.h:47
int(* ecc_error_log_get)(const struct device *dev, uint64_t *value)
Definition: edac.h:51
int(* errors_uc_get)(const struct device *dev)
Definition: edac.h:58
int(* inject_set_error_type)(const struct device *dev, uint32_t value)
Definition: edac.h:46
int(* parity_error_log_get)(const struct device *dev, uint64_t *value)
Definition: edac.h:53
int(* errors_cor_get)(const struct device *dev)
Definition: edac.h:57
int(* inject_get_param1)(const struct device *dev, uint64_t *value)
Definition: edac.h:43
int(* inject_get_param2)(const struct device *dev, uint64_t *value)
Definition: edac.h:45
int(* inject_set_param1)(const struct device *dev, uint64_t value)
Definition: edac.h:42
int(* ecc_error_log_clear)(const struct device *dev)
Definition: edac.h:52
int(* parity_error_log_clear)(const struct device *dev)
Definition: edac.h:54
int(* notify_cb_set)(const struct device *dev, edac_notify_callback_f cb)
Definition: edac.h:61
int(* inject_error_trigger)(const struct device *dev)
Definition: edac.h:48
int(* inject_set_param2)(const struct device *dev, uint64_t value)
Definition: edac.h:44
static fdata_t data[2]
Definition: test_fifo_contexts.c:15