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