Zephyr API Documentation 4.3.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
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
13#ifndef ZEPHYR_INCLUDE_DRIVERS_EDAC_H_
14#define ZEPHYR_INCLUDE_DRIVERS_EDAC_H_
15
16#include <errno.h>
17
18#include <sys/types.h>
19
32
42
48
49typedef void (*edac_notify_callback_f)(const struct device *dev, void *data);
50
56__subsystem struct edac_driver_api {
57 /* Error Injection API is disabled by default */
58 int (*inject_set_param1)(const struct device *dev, uint64_t value);
59 int (*inject_get_param1)(const struct device *dev, uint64_t *value);
60 int (*inject_set_param2)(const struct device *dev, uint64_t value);
61 int (*inject_get_param2)(const struct device *dev, uint64_t *value);
62 int (*inject_set_error_type)(const struct device *dev, uint32_t value);
63 int (*inject_get_error_type)(const struct device *dev, uint32_t *value);
64 int (*inject_error_trigger)(const struct device *dev);
65
66 /* Error Logging API */
67 int (*ecc_error_log_get)(const struct device *dev, uint64_t *value);
68 int (*ecc_error_log_clear)(const struct device *dev);
69 int (*parity_error_log_get)(const struct device *dev, uint64_t *value);
70 int (*parity_error_log_clear)(const struct device *dev);
71
72 /* Error stats API */
73 int (*errors_cor_get)(const struct device *dev);
74 int (*errors_uc_get)(const struct device *dev);
75
76 /* Notification callback API */
77 int (*notify_cb_set)(const struct device *dev,
78 edac_notify_callback_f cb);
79};
80
84
91
103static inline int edac_inject_set_param1(const struct device *dev,
104 uint64_t value)
105{
106 const struct edac_driver_api *api =
107 (const struct edac_driver_api *)dev->api;
108
109 if (api->inject_set_param1 == NULL) {
110 return -ENOSYS;
111 }
112
113 return api->inject_set_param1(dev, value);
114}
115
127static inline int edac_inject_get_param1(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_get_param1 == NULL) {
134 return -ENOSYS;
135 }
136
137 return api->inject_get_param1(dev, value);
138
139}
140
152static inline int edac_inject_set_param2(const struct device *dev,
153 uint64_t value)
154{
155 const struct edac_driver_api *api =
156 (const struct edac_driver_api *)dev->api;
157
158 if (api->inject_set_param2 == NULL) {
159 return -ENOSYS;
160 }
161
162 return api->inject_set_param2(dev, value);
163}
164
174static inline int edac_inject_get_param2(const struct device *dev,
175 uint64_t *value)
176{
177 const struct edac_driver_api *api =
178 (const struct edac_driver_api *)dev->api;
179
180 if (api->inject_get_param2 == NULL) {
181 return -ENOSYS;
182 }
183
184 return api->inject_get_param2(dev, value);
185}
186
198static inline int edac_inject_set_error_type(const struct device *dev,
199 uint32_t error_type)
200{
201 const struct edac_driver_api *api =
202 (const struct edac_driver_api *)dev->api;
203
204 if (api->inject_set_error_type == NULL) {
205 return -ENOSYS;
206 }
207
208 return api->inject_set_error_type(dev, error_type);
209}
210
222static inline int edac_inject_get_error_type(const struct device *dev,
223 uint32_t *error_type)
224{
225 const struct edac_driver_api *api =
226 (const struct edac_driver_api *)dev->api;
227
228 if (api->inject_get_error_type == NULL) {
229 return -ENOSYS;
230 }
231
232 return api->inject_get_error_type(dev, error_type);
233}
234
245static inline int edac_inject_error_trigger(const struct device *dev)
246{
247 const struct edac_driver_api *api =
248 (const struct edac_driver_api *)dev->api;
249
250 if (api->inject_error_trigger == NULL) {
251 return -ENOSYS;
252 }
253
254 return api->inject_error_trigger(dev);
255}
256 /* End of EDAC Optional Interfaces */
258
265
277static inline int edac_ecc_error_log_get(const struct device *dev,
278 uint64_t *value)
279{
280 const struct edac_driver_api *api =
281 (const struct edac_driver_api *)dev->api;
282
283 if (api->ecc_error_log_get == NULL) {
284 return -ENOSYS;
285 }
286
287 return api->ecc_error_log_get(dev, value);
288}
289
300static inline int edac_ecc_error_log_clear(const struct device *dev)
301{
302 const struct edac_driver_api *api =
303 (const struct edac_driver_api *)dev->api;
304
305 if (api->ecc_error_log_clear == NULL) {
306 return -ENOSYS;
307 }
308
309 return api->ecc_error_log_clear(dev);
310}
311
323static inline int edac_parity_error_log_get(const struct device *dev,
324 uint64_t *value)
325{
326 const struct edac_driver_api *api =
327 (const struct edac_driver_api *)dev->api;
328
329 if (api->parity_error_log_get == NULL) {
330 return -ENOSYS;
331 }
332
333 return api->parity_error_log_get(dev, value);
334}
335
346static inline int edac_parity_error_log_clear(const struct device *dev)
347{
348 const struct edac_driver_api *api =
349 (const struct edac_driver_api *)dev->api;
350
351 if (api->parity_error_log_clear == NULL) {
352 return -ENOSYS;
353 }
354
355 return api->parity_error_log_clear(dev);
356}
357
366static inline int edac_errors_cor_get(const struct device *dev)
367{
368 const struct edac_driver_api *api =
369 (const struct edac_driver_api *)dev->api;
370
371 if (api->errors_cor_get == NULL) {
372 return -ENOSYS;
373 }
374
375 return api->errors_cor_get(dev);
376}
377
386static inline int edac_errors_uc_get(const struct device *dev)
387{
388 const struct edac_driver_api *api =
389 (const struct edac_driver_api *)dev->api;
390
391 if (api->errors_uc_get == NULL) {
392 return -ENOSYS;
393 }
394
395 return api->errors_uc_get(dev);
396}
397
409static inline int edac_notify_callback_set(const struct device *dev,
410 edac_notify_callback_f cb)
411{
412 const struct edac_driver_api *api = (const struct edac_driver_api *)dev->api;
413
414 if (api->notify_cb_set == NULL) {
415 return -ENOSYS;
416 }
417
418 return api->notify_cb_set(dev, cb);
419}
420
421 /* End of EDAC Mandatory Interfaces */
423 /* End of EDAC API */
425
426#endif /* ZEPHYR_INCLUDE_DRIVERS_EDAC_H_ */
System error numbers.
static int edac_inject_set_error_type(const struct device *dev, uint32_t error_type)
Set error type value.
Definition edac.h:198
static int edac_notify_callback_set(const struct device *dev, edac_notify_callback_f cb)
Register callback function for memory error exception.
Definition edac.h:409
static int edac_inject_get_param2(const struct device *dev, uint64_t *value)
Get injection parameter param2.
Definition edac.h:174
edac_error_type
EDAC error type.
Definition edac.h:36
static int edac_ecc_error_log_get(const struct device *dev, uint64_t *value)
Get ECC Error Log.
Definition edac.h:277
static int edac_inject_get_param1(const struct device *dev, uint64_t *value)
Get injection parameter param1.
Definition edac.h:127
static int edac_inject_set_param2(const struct device *dev, uint64_t value)
Set injection parameter param2.
Definition edac.h:152
static int edac_parity_error_log_get(const struct device *dev, uint64_t *value)
Get Parity Error Log.
Definition edac.h:323
static int edac_ecc_error_log_clear(const struct device *dev)
Clear ECC Error Log.
Definition edac.h:300
static int edac_parity_error_log_clear(const struct device *dev)
Clear Parity Error Log.
Definition edac.h:346
static int edac_inject_set_param1(const struct device *dev, uint64_t value)
Set injection parameter param1.
Definition edac.h:103
static int edac_errors_cor_get(const struct device *dev)
Get number of correctable errors.
Definition edac.h:366
static int edac_errors_uc_get(const struct device *dev)
Get number of uncorrectable errors.
Definition edac.h:386
static int edac_inject_error_trigger(const struct device *dev)
Set injection control.
Definition edac.h:245
static int edac_inject_get_error_type(const struct device *dev, uint32_t *error_type)
Get error type value.
Definition edac.h:222
@ EDAC_ERROR_TYPE_DRAM_UC
Uncorrectable error type.
Definition edac.h:40
@ EDAC_ERROR_TYPE_DRAM_COR
Correctable error type.
Definition edac.h:38
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
#define ENOSYS
Function not implemented.
Definition errno.h:82
#define NULL
Definition iar_missing_defs.h:20
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
Runtime device structure (in ROM) per driver instance.
Definition device.h:510
void * data
Address of the device instance private data.
Definition device.h:520
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:516