1*25cf1a30Sjl /*
2*25cf1a30Sjl  * CDDL HEADER START
3*25cf1a30Sjl  *
4*25cf1a30Sjl  * The contents of this file are subject to the terms of the
5*25cf1a30Sjl  * Common Development and Distribution License (the "License").
6*25cf1a30Sjl  * You may not use this file except in compliance with the License.
7*25cf1a30Sjl  *
8*25cf1a30Sjl  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*25cf1a30Sjl  * or http://www.opensolaris.org/os/licensing.
10*25cf1a30Sjl  * See the License for the specific language governing permissions
11*25cf1a30Sjl  * and limitations under the License.
12*25cf1a30Sjl  *
13*25cf1a30Sjl  * When distributing Covered Code, include this CDDL HEADER in each
14*25cf1a30Sjl  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*25cf1a30Sjl  * If applicable, add the following below this CDDL HEADER, with the
16*25cf1a30Sjl  * fields enclosed by brackets "[]" replaced with your own identifying
17*25cf1a30Sjl  * information: Portions Copyright [yyyy] [name of copyright owner]
18*25cf1a30Sjl  *
19*25cf1a30Sjl  * CDDL HEADER END
20*25cf1a30Sjl  */
21*25cf1a30Sjl /*
22*25cf1a30Sjl  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*25cf1a30Sjl  * Use is subject to license terms.
24*25cf1a30Sjl  */
25*25cf1a30Sjl 
26*25cf1a30Sjl #ifndef	_SYS_PCMU_ERR_H
27*25cf1a30Sjl #define	_SYS_PCMU_ERR_H
28*25cf1a30Sjl 
29*25cf1a30Sjl #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*25cf1a30Sjl 
31*25cf1a30Sjl #include <sys/ddifm.h>
32*25cf1a30Sjl 
33*25cf1a30Sjl #ifdef	__cplusplus
34*25cf1a30Sjl extern "C" {
35*25cf1a30Sjl #endif
36*25cf1a30Sjl 
37*25cf1a30Sjl #ifdef _KERNEL
38*25cf1a30Sjl 
39*25cf1a30Sjl #define	PBM_PRIMARY		1
40*25cf1a30Sjl #define	PBM_SECONDARY		0
41*25cf1a30Sjl #define	PBM_NONFATAL		0
42*25cf1a30Sjl #define	PBM_FATAL		1
43*25cf1a30Sjl #define	FM_LOG_PCI		0
44*25cf1a30Sjl #define	FM_LOG_PBM		1
45*25cf1a30Sjl #define	ECC_MAX_ERRS		6
46*25cf1a30Sjl #define	TARGET_MAX_ERRS		6
47*25cf1a30Sjl 
48*25cf1a30Sjl /*
49*25cf1a30Sjl  * Since pcmu_pbm_err_handler() is called by various interrupt/trap/callback
50*25cf1a30Sjl  * handlers, it is necessary for it to know where it is being called from.
51*25cf1a30Sjl  * Below are the flags passed to pcmu_pbm_err_handler() to give it knowledge
52*25cf1a30Sjl  * of it's caller.
53*25cf1a30Sjl  */
54*25cf1a30Sjl #define	PCI_TRAP_CALL		0x0
55*25cf1a30Sjl #define	PCI_CB_CALL		0x1
56*25cf1a30Sjl #define	PCI_INTR_CALL		0x2
57*25cf1a30Sjl #define	PCI_BUS_EXIT_CALL	0x3
58*25cf1a30Sjl #define	PCI_ECC_CALL		0x4
59*25cf1a30Sjl 
60*25cf1a30Sjl extern errorq_t *pcmu_ecc_queue;	/* per-system ecc handling queue */
61*25cf1a30Sjl 
62*25cf1a30Sjl struct pcmu_errstate {
63*25cf1a30Sjl 	char *pcmu_err_class;
64*25cf1a30Sjl 	uint16_t pcmu_cfg_stat;
65*25cf1a30Sjl 	uint16_t pcmu_cfg_comm;
66*25cf1a30Sjl 	uint64_t pcmu_pa;
67*25cf1a30Sjl };
68*25cf1a30Sjl 
69*25cf1a30Sjl /*
70*25cf1a30Sjl  * pbm errstate use to encompass the state for all errors
71*25cf1a30Sjl  * detected by the pci block
72*25cf1a30Sjl  */
73*25cf1a30Sjl struct pcmu_pbm_errstate {
74*25cf1a30Sjl 	char *pbm_err_class;
75*25cf1a30Sjl 	int pcbm_pri;
76*25cf1a30Sjl 	int pbm_log;
77*25cf1a30Sjl 	uint32_t pbm_err;
78*25cf1a30Sjl 	uint32_t pbm_multi;
79*25cf1a30Sjl 	char *pbm_bridge_type;
80*25cf1a30Sjl 	uint64_t pbm_ctl_stat;
81*25cf1a30Sjl 	uint64_t pbm_afsr;
82*25cf1a30Sjl 	uint64_t pbm_afar;
83*25cf1a30Sjl 	uint64_t pbm_va_log;
84*25cf1a30Sjl 	uint64_t pbm_err_sl;
85*25cf1a30Sjl 	uint64_t pcbm_pcix_stat;
86*25cf1a30Sjl 	uint32_t pcbm_pcix_pfar;
87*25cf1a30Sjl 	pcmu_errstate_t pcbm_pci;
88*25cf1a30Sjl 	char *pcmu_pbm_terr_class;
89*25cf1a30Sjl };
90*25cf1a30Sjl 
91*25cf1a30Sjl /*
92*25cf1a30Sjl  * ecc errstate used to store all state captured,
93*25cf1a30Sjl  * upon detection of an ecc error.
94*25cf1a30Sjl  */
95*25cf1a30Sjl struct pcmu_ecc_errstate {
96*25cf1a30Sjl 	char *ecc_bridge_type;
97*25cf1a30Sjl 	pcmu_ecc_t *pecc_p;
98*25cf1a30Sjl 	uint64_t ecc_afsr;
99*25cf1a30Sjl 	uint64_t ecc_afar;
100*25cf1a30Sjl 	uint64_t ecc_offset;
101*25cf1a30Sjl 	uint64_t ecc_dev_id;
102*25cf1a30Sjl 	uint64_t ecc_dw_offset;
103*25cf1a30Sjl 	struct async_flt ecc_aflt;
104*25cf1a30Sjl 	pcmu_ecc_intr_info_t ecc_ii_p;
105*25cf1a30Sjl 	uint64_t ecc_ctrl;
106*25cf1a30Sjl 	int pecc_pri;
107*25cf1a30Sjl 	char ecc_unum[UNUM_NAMLEN];
108*25cf1a30Sjl 	uint64_t ecc_ena;
109*25cf1a30Sjl 	uint64_t ecc_err_addr;
110*25cf1a30Sjl 	char *ecc_err_type;
111*25cf1a30Sjl 	int pecc_pg_ret;
112*25cf1a30Sjl 	nvlist_t *ecc_fmri;
113*25cf1a30Sjl 	int ecc_caller;
114*25cf1a30Sjl };
115*25cf1a30Sjl 
116*25cf1a30Sjl extern int pcmu_fm_init_child(dev_info_t *dip, dev_info_t *tdip, int cap,
117*25cf1a30Sjl 		ddi_iblock_cookie_t *ibc);
118*25cf1a30Sjl extern void pcmu_bus_enter(dev_info_t *dip, ddi_acc_handle_t handle);
119*25cf1a30Sjl extern void pcmu_bus_exit(dev_info_t *dip, ddi_acc_handle_t handle);
120*25cf1a30Sjl extern void pcmu_pbm_ereport_post(dev_info_t *dip, uint64_t ena,
121*25cf1a30Sjl 		pcmu_pbm_errstate_t *pbm_err);
122*25cf1a30Sjl extern void pcmu_fm_acc_setup(ddi_map_req_t *mp, dev_info_t *rdip);
123*25cf1a30Sjl extern int pcmu_handle_lookup(dev_info_t *dip, int type, uint64_t fme_ena,
124*25cf1a30Sjl 		void *afar);
125*25cf1a30Sjl extern void pcmu_fm_create(pcmu_t *pcmu_p);
126*25cf1a30Sjl extern void pcmu_fm_destroy(pcmu_t *pcmu_p);
127*25cf1a30Sjl extern int pcmu_err_callback(dev_info_t *dip, ddi_fm_error_t *derr,
128*25cf1a30Sjl 		const void *impl_data);
129*25cf1a30Sjl #endif /* _KERNEL */
130*25cf1a30Sjl 
131*25cf1a30Sjl #ifdef	__cplusplus
132*25cf1a30Sjl }
133*25cf1a30Sjl #endif
134*25cf1a30Sjl 
135*25cf1a30Sjl #endif	/* _SYS_PCMU_ERR_H */
136