Zephyr Project API 4.2.99
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
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
38
45typedef void (*edac_notify_callback_f)(const struct device *dev, void *data);
46
52__subsystem struct edac_driver_api {
53 /* Error Injection API is disabled by default */
54 int (*inject_set_param1)(const struct device *dev, uint64_t value);
55 int (*inject_get_param1)(const struct device *dev, uint64_t *value);
56 int (*inject_set_param2)(const struct device *dev, uint64_t value);
57 int (*inject_get_param2)(const struct device *dev, uint64_t *value);
58 int (*inject_set_error_type)(const struct device *dev, uint32_t value);
59 int (*inject_get_error_type)(const struct device *dev, uint32_t *value);
60 int (*inject_error_trigger)(const struct device *dev);
61
62 /* Error Logging API */
63 int (*ecc_error_log_get)(const struct device *dev, uint64_t *value);
64 int (*ecc_error_log_clear)(const struct device *dev);
65 int (*parity_error_log_get)(const struct device *dev, uint64_t *value);
66 int (*parity_error_log_clear)(const struct device *dev);
67
68 /* Error stats API */
69 int (*errors_cor_get)(const struct device *dev);
70 int (*errors_uc_get)(const struct device *dev);
71
72 /* Notification callback API */
73 int (*notify_cb_set)(const struct device *dev,
74 edac_notify_callback_f cb);
75};
76
99static inline int edac_inject_set_param1(const struct device *dev,
100 uint64_t value)
101{
102 const struct edac_driver_api *api =
103 (const struct edac_driver_api *)dev->api;
104
105 if (api->inject_set_param1 == NULL) {
106 return -ENOSYS;
107 }
108
109 return api->inject_set_param1(dev, value);
110}
111
123static inline int edac_inject_get_param1(const struct device *dev,
124 uint64_t *value)
125{
126 const struct edac_driver_api *api =
127 (const struct edac_driver_api *)dev->api;
128
129 if (api->inject_get_param1 == NULL) {
130 return -ENOSYS;
131 }
132
133 return api->inject_get_param1(dev, value);
134
135}
136
148static inline int edac_inject_set_param2(const struct device *dev,
149 uint64_t value)
150{
151 const struct edac_driver_api *api =
152 (const struct edac_driver_api *)dev->api;
153
154 if (api->inject_set_param2 == NULL) {
155 return -ENOSYS;
156 }
157
158 return api->inject_set_param2(dev, value);
159}
160
170static inline int edac_inject_get_param2(const struct device *dev,
171 uint64_t *value)
172{
173 const struct edac_driver_api *api =
174 (const struct edac_driver_api *)dev->api;
175
176 if (api->inject_get_param2 == NULL) {
177 return -ENOSYS;
178 }
179
180 return api->inject_get_param2(dev, value);
181}
182
194static inline int edac_inject_set_error_type(const struct device *dev,
195 uint32_t error_type)
196{
197 const struct edac_driver_api *api =
198 (const struct edac_driver_api *)dev->api;
199
200 if (api->inject_set_error_type == NULL) {
201 return -ENOSYS;
202 }
203
204 return api->inject_set_error_type(dev, error_type);
205}
206
218static inline int edac_inject_get_error_type(const struct device *dev,
219 uint32_t *error_type)
220{
221 const struct edac_driver_api *api =
222 (const struct edac_driver_api *)dev->api;
223
224 if (api->inject_get_error_type == NULL) {
225 return -ENOSYS;
226 }
227
228 return api->inject_get_error_type(dev, error_type);
229}
230
241static inline int edac_inject_error_trigger(const struct device *dev)
242{
243 const struct edac_driver_api *api =
244 (const struct edac_driver_api *)dev->api;
245
246 if (api->inject_error_trigger == NULL) {
247 return -ENOSYS;
248 }
249
250 return api->inject_error_trigger(dev);
251}
252
/* End of EDAC Optional Interfaces */
254
273static inline int edac_ecc_error_log_get(const struct device *dev,
274 uint64_t *value)
275{
276 const struct edac_driver_api *api =
277 (const struct edac_driver_api *)dev->api;
278
279 if (api->ecc_error_log_get == NULL) {
280 return -ENOSYS;
281 }
282
283 return api->ecc_error_log_get(dev, value);
284}
285
296static inline int edac_ecc_error_log_clear(const struct device *dev)
297{
298 const struct edac_driver_api *api =
299 (const struct edac_driver_api *)dev->api;
300
301 if (api->ecc_error_log_clear == NULL) {
302 return -ENOSYS;
303 }
304
305 return api->ecc_error_log_clear(dev);
306}
307
319static inline int edac_parity_error_log_get(const struct device *dev,
320 uint64_t *value)
321{
322 const struct edac_driver_api *api =
323 (const struct edac_driver_api *)dev->api;
324
325 if (api->parity_error_log_get == NULL) {
326 return -ENOSYS;
327 }
328
329 return api->parity_error_log_get(dev, value);
330}
331
342static inline int edac_parity_error_log_clear(const struct device *dev)
343{
344 const struct edac_driver_api *api =
345 (const struct edac_driver_api *)dev->api;
346
347 if (api->parity_error_log_clear == NULL) {
348 return -ENOSYS;
349 }
350
351 return api->parity_error_log_clear(dev);
352}
353
362static inline int edac_errors_cor_get(const struct device *dev)
363{
364 const struct edac_driver_api *api =
365 (const struct edac_driver_api *)dev->api;
366
367 if (api->errors_cor_get == NULL) {
368 return -ENOSYS;
369 }
370
371 return api->errors_cor_get(dev);
372}
373
382static inline int edac_errors_uc_get(const struct device *dev)
383{
384 const struct edac_driver_api *api =
385 (const struct edac_driver_api *)dev->api;
386
387 if (api->errors_uc_get == NULL) {
388 return -ENOSYS;
389 }
390
391 return api->errors_uc_get(dev);
392}
393
405static inline int edac_notify_callback_set(const struct device *dev,
406 edac_notify_callback_f cb)
407{
408 const struct edac_driver_api *api = (const struct edac_driver_api *)dev->api;
409
410 if (api->notify_cb_set == NULL) {
411 return -ENOSYS;
412 }
413
414 return api->notify_cb_set(dev, cb);
415}
416
417
/* End of EDAC Mandatory Interfaces */
419
/* End of EDAC API */
421
422#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:194
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:405
static int edac_inject_get_param2(const struct device *dev, uint64_t *value)
Get injection parameter param2.
Definition edac.h:170
edac_error_type
EDAC error type.
Definition edac.h:32
static int edac_ecc_error_log_get(const struct device *dev, uint64_t *value)
Get ECC Error Log.
Definition edac.h:273
static int edac_inject_get_param1(const struct device *dev, uint64_t *value)
Get injection parameter param1.
Definition edac.h:123
static int edac_inject_set_param2(const struct device *dev, uint64_t value)
Set injection parameter param2.
Definition edac.h:148
static int edac_parity_error_log_get(const struct device *dev, uint64_t *value)
Get Parity Error Log.
Definition edac.h:319
static int edac_ecc_error_log_clear(const struct device *dev)
Clear ECC Error Log.
Definition edac.h:296
static int edac_parity_error_log_clear(const struct device *dev)
Clear Parity Error Log.
Definition edac.h:342
static int edac_inject_set_param1(const struct device *dev, uint64_t value)
Set injection parameter param1.
Definition edac.h:99
static int edac_errors_cor_get(const struct device *dev)
Get number of correctable errors.
Definition edac.h:362
static int edac_errors_uc_get(const struct device *dev)
Get number of uncorrectable errors.
Definition edac.h:382
static int edac_inject_error_trigger(const struct device *dev)
Set injection control.
Definition edac.h:241
static int edac_inject_get_error_type(const struct device *dev, uint32_t *error_type)
Get error type value.
Definition edac.h:218
@ EDAC_ERROR_TYPE_DRAM_UC
Uncorrectable error type.
Definition edac.h:36
@ EDAC_ERROR_TYPE_DRAM_COR
Correctable error type.
Definition edac.h:34
#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