Zephyr API Documentation 4.4.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
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 = DEVICE_API_GET(edac, dev);
107
108 if (api->inject_set_param1 == NULL) {
109 return -ENOSYS;
110 }
111
112 return api->inject_set_param1(dev, value);
113}
114
126static inline int edac_inject_get_param1(const struct device *dev,
127 uint64_t *value)
128{
129 const struct edac_driver_api *api = DEVICE_API_GET(edac, dev);
130
131 if (api->inject_get_param1 == NULL) {
132 return -ENOSYS;
133 }
134
135 return api->inject_get_param1(dev, value);
136
137}
138
150static inline int edac_inject_set_param2(const struct device *dev,
151 uint64_t value)
152{
153 const struct edac_driver_api *api = DEVICE_API_GET(edac, dev);
154
155 if (api->inject_set_param2 == NULL) {
156 return -ENOSYS;
157 }
158
159 return api->inject_set_param2(dev, value);
160}
161
171static inline int edac_inject_get_param2(const struct device *dev,
172 uint64_t *value)
173{
174 const struct edac_driver_api *api = DEVICE_API_GET(edac, dev);
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 = DEVICE_API_GET(edac, dev);
198
199 if (api->inject_set_error_type == NULL) {
200 return -ENOSYS;
201 }
202
203 return api->inject_set_error_type(dev, error_type);
204}
205
217static inline int edac_inject_get_error_type(const struct device *dev,
218 uint32_t *error_type)
219{
220 const struct edac_driver_api *api = DEVICE_API_GET(edac, dev);
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 = DEVICE_API_GET(edac, dev);
242
243 if (api->inject_error_trigger == NULL) {
244 return -ENOSYS;
245 }
246
247 return api->inject_error_trigger(dev);
248}
249 /* End of EDAC Optional Interfaces */
251
258
270static inline int edac_ecc_error_log_get(const struct device *dev,
271 uint64_t *value)
272{
273 const struct edac_driver_api *api = DEVICE_API_GET(edac, dev);
274
275 if (api->ecc_error_log_get == NULL) {
276 return -ENOSYS;
277 }
278
279 return api->ecc_error_log_get(dev, value);
280}
281
292static inline int edac_ecc_error_log_clear(const struct device *dev)
293{
294 const struct edac_driver_api *api = DEVICE_API_GET(edac, dev);
295
296 if (api->ecc_error_log_clear == NULL) {
297 return -ENOSYS;
298 }
299
300 return api->ecc_error_log_clear(dev);
301}
302
314static inline int edac_parity_error_log_get(const struct device *dev,
315 uint64_t *value)
316{
317 const struct edac_driver_api *api = DEVICE_API_GET(edac, dev);
318
319 if (api->parity_error_log_get == NULL) {
320 return -ENOSYS;
321 }
322
323 return api->parity_error_log_get(dev, value);
324}
325
336static inline int edac_parity_error_log_clear(const struct device *dev)
337{
338 const struct edac_driver_api *api = DEVICE_API_GET(edac, dev);
339
340 if (api->parity_error_log_clear == NULL) {
341 return -ENOSYS;
342 }
343
344 return api->parity_error_log_clear(dev);
345}
346
355static inline int edac_errors_cor_get(const struct device *dev)
356{
357 const struct edac_driver_api *api = DEVICE_API_GET(edac, dev);
358
359 if (api->errors_cor_get == NULL) {
360 return -ENOSYS;
361 }
362
363 return api->errors_cor_get(dev);
364}
365
374static inline int edac_errors_uc_get(const struct device *dev)
375{
376 const struct edac_driver_api *api = DEVICE_API_GET(edac, dev);
377
378 if (api->errors_uc_get == NULL) {
379 return -ENOSYS;
380 }
381
382 return api->errors_uc_get(dev);
383}
384
396static inline int edac_notify_callback_set(const struct device *dev,
397 edac_notify_callback_f cb)
398{
399 const struct edac_driver_api *api = DEVICE_API_GET(edac, dev);
400
401 if (api->notify_cb_set == NULL) {
402 return -ENOSYS;
403 }
404
405 return api->notify_cb_set(dev, cb);
406}
407
408 /* End of EDAC Mandatory Interfaces */
410 /* End of EDAC API */
412
413#endif /* ZEPHYR_INCLUDE_DRIVERS_EDAC_H_ */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1375
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:396
static int edac_inject_get_param2(const struct device *dev, uint64_t *value)
Get injection parameter param2.
Definition edac.h:171
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:270
static int edac_inject_get_param1(const struct device *dev, uint64_t *value)
Get injection parameter param1.
Definition edac.h:126
static int edac_inject_set_param2(const struct device *dev, uint64_t value)
Set injection parameter param2.
Definition edac.h:150
static int edac_parity_error_log_get(const struct device *dev, uint64_t *value)
Get Parity Error Log.
Definition edac.h:314
static int edac_ecc_error_log_clear(const struct device *dev)
Clear ECC Error Log.
Definition edac.h:292
static int edac_parity_error_log_clear(const struct device *dev)
Clear Parity Error Log.
Definition edac.h:336
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:355
static int edac_errors_uc_get(const struct device *dev)
Get number of uncorrectable errors.
Definition edac.h:374
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:217
@ 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:513
void * data
Address of the device instance private data.
Definition device.h:523