Zephyr API Documentation  3.7.0
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#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
35};
36
43typedef void (*edac_notify_callback_f)(const struct device *dev, void *data);
44
50__subsystem struct edac_driver_api {
51 /* Error Injection API is disabled by default */
52 int (*inject_set_param1)(const struct device *dev, uint64_t value);
53 int (*inject_get_param1)(const struct device *dev, uint64_t *value);
54 int (*inject_set_param2)(const struct device *dev, uint64_t value);
55 int (*inject_get_param2)(const struct device *dev, uint64_t *value);
56 int (*inject_set_error_type)(const struct device *dev, uint32_t value);
57 int (*inject_get_error_type)(const struct device *dev, uint32_t *value);
58 int (*inject_error_trigger)(const struct device *dev);
59
60 /* Error Logging API */
61 int (*ecc_error_log_get)(const struct device *dev, uint64_t *value);
62 int (*ecc_error_log_clear)(const struct device *dev);
63 int (*parity_error_log_get)(const struct device *dev, uint64_t *value);
64 int (*parity_error_log_clear)(const struct device *dev);
65
66 /* Error stats API */
67 int (*errors_cor_get)(const struct device *dev);
68 int (*errors_uc_get)(const struct device *dev);
69
70 /* Notification callback API */
71 int (*notify_cb_set)(const struct device *dev,
72 edac_notify_callback_f cb);
73};
74
97static inline int edac_inject_set_param1(const struct device *dev,
98 uint64_t value)
99{
100 const struct edac_driver_api *api =
101 (const struct edac_driver_api *)dev->api;
102
103 if (api->inject_set_param1 == NULL) {
104 return -ENOSYS;
105 }
106
107 return api->inject_set_param1(dev, value);
108}
109
121static inline int edac_inject_get_param1(const struct device *dev,
122 uint64_t *value)
123{
124 const struct edac_driver_api *api =
125 (const struct edac_driver_api *)dev->api;
126
127 if (api->inject_get_param1 == NULL) {
128 return -ENOSYS;
129 }
130
131 return api->inject_get_param1(dev, value);
132
133}
134
146static inline int edac_inject_set_param2(const struct device *dev,
147 uint64_t value)
148{
149 const struct edac_driver_api *api =
150 (const struct edac_driver_api *)dev->api;
151
152 if (api->inject_set_param2 == NULL) {
153 return -ENOSYS;
154 }
155
156 return api->inject_set_param2(dev, value);
157}
158
168static inline int edac_inject_get_param2(const struct device *dev,
169 uint64_t *value)
170{
171 const struct edac_driver_api *api =
172 (const struct edac_driver_api *)dev->api;
173
174 if (api->inject_get_param2 == NULL) {
175 return -ENOSYS;
176 }
177
178 return api->inject_get_param2(dev, value);
179}
180
192static inline int edac_inject_set_error_type(const struct device *dev,
193 uint32_t error_type)
194{
195 const struct edac_driver_api *api =
196 (const struct edac_driver_api *)dev->api;
197
198 if (api->inject_set_error_type == NULL) {
199 return -ENOSYS;
200 }
201
202 return api->inject_set_error_type(dev, error_type);
203}
204
216static inline int edac_inject_get_error_type(const struct device *dev,
217 uint32_t *error_type)
218{
219 const struct edac_driver_api *api =
220 (const struct edac_driver_api *)dev->api;
221
222 if (api->inject_get_error_type == NULL) {
223 return -ENOSYS;
224 }
225
226 return api->inject_get_error_type(dev, error_type);
227}
228
239static inline int edac_inject_error_trigger(const struct device *dev)
240{
241 const struct edac_driver_api *api =
242 (const struct edac_driver_api *)dev->api;
243
244 if (api->inject_error_trigger == NULL) {
245 return -ENOSYS;
246 }
247
248 return api->inject_error_trigger(dev);
249}
250 /* End of EDAC Optional Interfaces */
252
271static inline int edac_ecc_error_log_get(const struct device *dev,
272 uint64_t *value)
273{
274 const struct edac_driver_api *api =
275 (const struct edac_driver_api *)dev->api;
276
277 if (api->ecc_error_log_get == NULL) {
278 return -ENOSYS;
279 }
280
281 return api->ecc_error_log_get(dev, value);
282}
283
294static inline int edac_ecc_error_log_clear(const struct device *dev)
295{
296 const struct edac_driver_api *api =
297 (const struct edac_driver_api *)dev->api;
298
299 if (api->ecc_error_log_clear == NULL) {
300 return -ENOSYS;
301 }
302
303 return api->ecc_error_log_clear(dev);
304}
305
317static inline int edac_parity_error_log_get(const struct device *dev,
318 uint64_t *value)
319{
320 const struct edac_driver_api *api =
321 (const struct edac_driver_api *)dev->api;
322
323 if (api->parity_error_log_get == NULL) {
324 return -ENOSYS;
325 }
326
327 return api->parity_error_log_get(dev, value);
328}
329
340static inline int edac_parity_error_log_clear(const struct device *dev)
341{
342 const struct edac_driver_api *api =
343 (const struct edac_driver_api *)dev->api;
344
345 if (api->parity_error_log_clear == NULL) {
346 return -ENOSYS;
347 }
348
349 return api->parity_error_log_clear(dev);
350}
351
360static inline int edac_errors_cor_get(const struct device *dev)
361{
362 const struct edac_driver_api *api =
363 (const struct edac_driver_api *)dev->api;
364
365 if (api->errors_cor_get == NULL) {
366 return -ENOSYS;
367 }
368
369 return api->errors_cor_get(dev);
370}
371
380static inline int edac_errors_uc_get(const struct device *dev)
381{
382 const struct edac_driver_api *api =
383 (const struct edac_driver_api *)dev->api;
384
385 if (api->errors_uc_get == NULL) {
386 return -ENOSYS;
387 }
388
389 return api->errors_uc_get(dev);
390}
391
403static inline int edac_notify_callback_set(const struct device *dev,
404 edac_notify_callback_f cb)
405{
406 const struct edac_driver_api *api = (const struct edac_driver_api *)dev->api;
407
408 if (api->notify_cb_set == NULL) {
409 return -ENOSYS;
410 }
411
412 return api->notify_cb_set(dev, cb);
413}
414
415 /* End of EDAC Mandatory Interfaces */
417 /* End of EDAC API */
419
420#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:192
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:403
static int edac_inject_get_param2(const struct device *dev, uint64_t *value)
Get injection parameter param2.
Definition: edac.h:168
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:271
static int edac_inject_get_param1(const struct device *dev, uint64_t *value)
Get injection parameter param1.
Definition: edac.h:121
static int edac_inject_set_param2(const struct device *dev, uint64_t value)
Set injection parameter param2.
Definition: edac.h:146
static int edac_parity_error_log_get(const struct device *dev, uint64_t *value)
Get Parity Error Log.
Definition: edac.h:317
static int edac_ecc_error_log_clear(const struct device *dev)
Clear ECC Error Log.
Definition: edac.h:294
static int edac_parity_error_log_clear(const struct device *dev)
Clear Parity Error Log.
Definition: edac.h:340
static int edac_inject_set_param1(const struct device *dev, uint64_t value)
Set injection parameter param1.
Definition: edac.h:97
static int edac_errors_cor_get(const struct device *dev)
Get number of correctable errors.
Definition: edac.h:360
static int edac_errors_uc_get(const struct device *dev)
Get number of uncorrectable errors.
Definition: edac.h:380
static int edac_inject_error_trigger(const struct device *dev)
Set injection control.
Definition: edac.h:239
static int edac_inject_get_error_type(const struct device *dev, uint32_t *error_type)
Get error type value.
Definition: edac.h:216
@ 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:82
__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:403
void * data
Address of the device instance private data.
Definition: device.h:413
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:409