xref: /titanic_51/usr/src/uts/common/sys/ddifm.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_DDIFM_H
28 #define	_DDIFM_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/dditypes.h>
37 
38 extern int ddi_system_fmcap;
39 
40 /* Fault Management error handling */
41 
42 /* Error handling return status */
43 #define	DDI_FM_OK		0
44 #define	DDI_FM_FATAL	-1
45 #define	DDI_FM_NONFATAL	-2
46 #define	DDI_FM_UNKNOWN	-3
47 
48 /* Driver fault management capabilities */
49 #define	DDI_FM_NOT_CAPABLE	0x00000000
50 #define	DDI_FM_EREPORT_CAPABLE	0x00000001
51 #define	DDI_FM_ACCCHK_CAPABLE	0x00000002
52 #define	DDI_FM_DMACHK_CAPABLE	0x00000004
53 #define	DDI_FM_ERRCB_CAPABLE	0x00000008
54 
55 #define	DDI_FM_DEFAULT_CAP(cap)	(cap == DDI_FM_NOT_CAPABLE)
56 #define	DDI_FM_EREPORT_CAP(cap)	(cap & DDI_FM_EREPORT_CAPABLE)
57 #define	DDI_FM_ACC_ERR_CAP(cap)	(cap & DDI_FM_ACCCHK_CAPABLE)
58 #define	DDI_FM_DMA_ERR_CAP(cap)	(cap & DDI_FM_DMACHK_CAPABLE)
59 #define	DDI_FM_ERRCB_CAP(cap)	(cap & DDI_FM_ERRCB_CAPABLE)
60 
61 /* error expectation values */
62 #define	DDI_FM_ERR_UNEXPECTED	0
63 #define	DDI_FM_ERR_EXPECTED	1
64 #define	DDI_FM_ERR_POKE		2
65 #define	DDI_FM_ERR_PEEK		3
66 
67 #ifdef _KERNEL
68 
69 typedef struct ddi_fm_error {
70 	int fme_version;			/* version of this structure */
71 	int fme_status;				/* status for this error */
72 	int fme_flag;				/* error expectation flag */
73 	uint64_t fme_ena;			/* ENA for this error */
74 	ddi_acc_handle_t fme_acc_handle;	/* optional acc handle */
75 	ddi_dma_handle_t fme_dma_handle;	/* optional dma handle */
76 	void *fme_bus_specific;			/* optional bus specific err */
77 } ddi_fm_error_t;
78 
79 #define	DDI_FME_VER0	0
80 #define	DDI_FME_VERSION	DDI_FME_VER0
81 
82 typedef int (*ddi_err_func_t)(dev_info_t *, ddi_fm_error_t *, const void *);
83 
84 /*
85  * DDI for error handling and ereport generation
86  */
87 
88 /* ereporting and service changes */
89 extern void ddi_fm_ereport_post(dev_info_t *, const char *, uint64_t, int, ...);
90 extern void ddi_fm_service_impact(dev_info_t *, int);
91 
92 /* error handling */
93 extern void ddi_fm_handler_register(dev_info_t *, ddi_err_func_t, void *);
94 extern void ddi_fm_handler_unregister(dev_info_t *);
95 
96 /* fault management initialization and clean-up */
97 extern void ddi_fm_init(dev_info_t *, int *, ddi_iblock_cookie_t *);
98 extern void ddi_fm_fini(dev_info_t *);
99 extern int ddi_fm_capable(dev_info_t *dip);
100 
101 /* access and dma handle error protection */
102 extern void ddi_fm_dma_err_get(ddi_dma_handle_t, ddi_fm_error_t *, int);
103 extern void ddi_fm_acc_err_get(ddi_acc_handle_t, ddi_fm_error_t *, int);
104 
105 #endif /* _KERNEL */
106 
107 #ifdef	__cplusplus
108 }
109 #endif
110 
111 #endif	/* _DDIFM_H */
112