Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 <errno.h>
16
17#include <sys/types.h>
18
19typedef void (*edac_notify_callback_f)(const struct device *dev, void *data);
20
35};
36
42__subsystem struct edac_driver_api {
43 /* Error Injection API is disabled by default */
44 int (*inject_set_param1)(const struct device *dev, uint64_t value);
45 int (*inject_get_param1)(const struct device *dev, uint64_t *value);
46 int (*inject_set_param2)(const struct device *dev, uint64_t value);
47 int (*inject_get_param2)(const struct device *dev, uint64_t *value);
48 int (*inject_set_error_type)(const struct device *dev, uint32_t value);
49 int (*inject_get_error_type)(const struct device *dev, uint32_t *value);
50 int (*inject_error_trigger)(const struct device *dev);
51
52 /* Error Logging API */
53 int (*ecc_error_log_get)(const struct device *dev, uint64_t *value);
54 int (*ecc_error_log_clear)(const struct device *dev);
55 int (*parity_error_log_get)(const struct device *dev, uint64_t *value);
56 int (*parity_error_log_clear)(const struct device *dev);
57
58 /* Error stats API */
59 int (*errors_cor_get)(const struct device *dev);
60 int (*errors_uc_get)(const struct device *dev);
61
62 /* Notification callback API */
63 int (*notify_cb_set)(const struct device *dev,
65};
66
67/* Optional interfaces */
68
80static inline int edac_inject_set_param1(const struct device *dev,
81 uint64_t value)
82{
83 const struct edac_driver_api *api =
84 (const struct edac_driver_api *)dev->api;
85
86 if (api->inject_set_param1 == NULL) {
87 return -ENOSYS;
88 }
89
90 return api->inject_set_param1(dev, value);
91}
92
104static inline int edac_inject_get_param1(const struct device *dev,
105 uint64_t *value)
106{
107 const struct edac_driver_api *api =
108 (const struct edac_driver_api *)dev->api;
109
110 if (api->inject_get_param1 == NULL) {
111 return -ENOSYS;
112 }
113
114 return api->inject_get_param1(dev, value);
115
116}
117
129static inline int edac_inject_set_param2(const struct device *dev,
130 uint64_t value)
131{
132 const struct edac_driver_api *api =
133 (const struct edac_driver_api *)dev->api;
134
135 if (api->inject_set_param2 == NULL) {
136 return -ENOSYS;
137 }
138
139 return api->inject_set_param2(dev, value);
140}
141
151static inline int edac_inject_get_param2(const struct device *dev,
152 uint64_t *value)
153{
154 const struct edac_driver_api *api =
155 (const struct edac_driver_api *)dev->api;
156
157 if (api->inject_get_param2 == NULL) {
158 return -ENOSYS;
159 }
160
161 return api->inject_get_param2(dev, value);
162}
163
175static inline int edac_inject_set_error_type(const struct device *dev,
176 uint32_t error_type)
177{
178 const struct edac_driver_api *api =
179 (const struct edac_driver_api *)dev->api;
180
181 if (api->inject_set_error_type == NULL) {
182 return -ENOSYS;
183 }
184
185 return api->inject_set_error_type(dev, error_type);
186}
187
199static inline int edac_inject_get_error_type(const struct device *dev,
200 uint32_t *error_type)
201{
202 const struct edac_driver_api *api =
203 (const struct edac_driver_api *)dev->api;
204
205 if (api->inject_get_error_type == NULL) {
206 return -ENOSYS;
207 }
208
209 return api->inject_get_error_type(dev, error_type);
210}
211
222static inline int edac_inject_error_trigger(const struct device *dev)
223{
224 const struct edac_driver_api *api =
225 (const struct edac_driver_api *)dev->api;
226
227 if (api->inject_error_trigger == NULL) {
228 return -ENOSYS;
229 }
230
231 return api->inject_error_trigger(dev);
232}
233
234/* Mandatory interfaces */
235
247static inline int edac_ecc_error_log_get(const struct device *dev,
248 uint64_t *value)
249{
250 const struct edac_driver_api *api =
251 (const struct edac_driver_api *)dev->api;
252
253 if (api->ecc_error_log_get == NULL) {
254 return -ENOSYS;
255 }
256
257 return api->ecc_error_log_get(dev, value);
258}
259
270static inline int edac_ecc_error_log_clear(const struct device *dev)
271{
272 const struct edac_driver_api *api =
273 (const struct edac_driver_api *)dev->api;
274
275 if (api->ecc_error_log_clear == NULL) {
276 return -ENOSYS;
277 }
278
279 return api->ecc_error_log_clear(dev);
280}
281
293static inline int edac_parity_error_log_get(const struct device *dev,
294 uint64_t *value)
295{
296 const struct edac_driver_api *api =
297 (const struct edac_driver_api *)dev->api;
298
299 if (api->parity_error_log_get == NULL) {
300 return -ENOSYS;
301 }
302
303 return api->parity_error_log_get(dev, value);
304}
305
316static inline int edac_parity_error_log_clear(const struct device *dev)
317{
318 const struct edac_driver_api *api =
319 (const struct edac_driver_api *)dev->api;
320
321 if (api->parity_error_log_clear == NULL) {
322 return -ENOSYS;
323 }
324
325 return api->parity_error_log_clear(dev);
326}
327
336static inline int edac_errors_cor_get(const struct device *dev)
337{
338 const struct edac_driver_api *api =
339 (const struct edac_driver_api *)dev->api;
340
341 if (api->errors_cor_get == NULL) {
342 return -ENOSYS;
343 }
344
345 return api->errors_cor_get(dev);
346}
347
356static inline int edac_errors_uc_get(const struct device *dev)
357{
358 const struct edac_driver_api *api =
359 (const struct edac_driver_api *)dev->api;
360
361 if (api->errors_uc_get == NULL) {
362 return -ENOSYS;
363 }
364
365 return api->errors_uc_get(dev);
366}
367
379static inline int edac_notify_callback_set(const struct device *dev,
381{
382 const struct edac_driver_api *api = (const struct edac_driver_api *)dev->api;
383
384 if (api->notify_cb_set == NULL) {
385 return -ENOSYS;
386 }
387
388 return api->notify_cb_set(dev, cb);
389}
390
395#endif /* ZEPHYR_INCLUDE_DRIVERS_EDAC_H_ */
void(* edac_notify_callback_f)(const struct device *dev, void *data)
Definition: edac.h:19
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:175
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:379
static int edac_inject_get_param2(const struct device *dev, uint64_t *value)
Get injection parameter param2.
Definition: edac.h:151
edac_error_type
EDAC error type.
Definition: edac.h:30
static int edac_ecc_error_log_get(const struct device *dev, uint64_t *value)
Get ECC Error Log.
Definition: edac.h:247
static int edac_inject_get_param1(const struct device *dev, uint64_t *value)
Get injection parameter param1.
Definition: edac.h:104
static int edac_inject_set_param2(const struct device *dev, uint64_t value)
Set injection parameter param2.
Definition: edac.h:129
static int edac_parity_error_log_get(const struct device *dev, uint64_t *value)
Get Parity Error Log.
Definition: edac.h:293
static int edac_ecc_error_log_clear(const struct device *dev)
Clear ECC Error Log.
Definition: edac.h:270
static int edac_parity_error_log_clear(const struct device *dev)
Clear Parity Error Log.
Definition: edac.h:316
static int edac_inject_set_param1(const struct device *dev, uint64_t value)
Set injection parameter param1.
Definition: edac.h:80
static int edac_errors_cor_get(const struct device *dev)
Get number of correctable errors.
Definition: edac.h:336
static int edac_errors_uc_get(const struct device *dev)
Get number of uncorrectable errors.
Definition: edac.h:356
static int edac_inject_error_trigger(const struct device *dev)
Set injection control.
Definition: edac.h:222
static int edac_inject_get_error_type(const struct device *dev, uint32_t *error_type)
Get error type value.
Definition: edac.h:199
@ EDAC_ERROR_TYPE_DRAM_UC
Uncorrectable error type.
Definition: edac.h:34
@ EDAC_ERROR_TYPE_DRAM_COR
Correctable error type.
Definition: edac.h:32
#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:83
__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:381
void * data
Address of the device instance private data.
Definition: device.h:391
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:387
EDAC driver API.
Definition: edac.h:42
int(* inject_get_error_type)(const struct device *dev, uint32_t *value)
Definition: edac.h:49
int(* ecc_error_log_get)(const struct device *dev, uint64_t *value)
Definition: edac.h:53
int(* errors_uc_get)(const struct device *dev)
Definition: edac.h:60
int(* inject_set_error_type)(const struct device *dev, uint32_t value)
Definition: edac.h:48
int(* parity_error_log_get)(const struct device *dev, uint64_t *value)
Definition: edac.h:55
int(* errors_cor_get)(const struct device *dev)
Definition: edac.h:59
int(* inject_get_param1)(const struct device *dev, uint64_t *value)
Definition: edac.h:45
int(* inject_get_param2)(const struct device *dev, uint64_t *value)
Definition: edac.h:47
int(* inject_set_param1)(const struct device *dev, uint64_t value)
Definition: edac.h:44
int(* ecc_error_log_clear)(const struct device *dev)
Definition: edac.h:54
int(* parity_error_log_clear)(const struct device *dev)
Definition: edac.h:56
int(* notify_cb_set)(const struct device *dev, edac_notify_callback_f cb)
Definition: edac.h:63
int(* inject_error_trigger)(const struct device *dev)
Definition: edac.h:50
int(* inject_set_param2)(const struct device *dev, uint64_t value)
Definition: edac.h:46