xref: /illumos-gate/usr/src/uts/sun4u/io/pci/pci_debug.c (revision 7c478bd9)
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 2005 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate /*
30*7c478bd9Sstevel@tonic-gate  * PCI nexus driver general debug support
31*7c478bd9Sstevel@tonic-gate  */
32*7c478bd9Sstevel@tonic-gate #include <sys/promif.h>		/* prom_printf */
33*7c478bd9Sstevel@tonic-gate #include <sys/async.h>
34*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>		/* dev_info_t */
35*7c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
36*7c478bd9Sstevel@tonic-gate #include <sys/pci/pci_obj.h>
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate /*LINTLIBRARY*/
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #ifdef DEBUG
41*7c478bd9Sstevel@tonic-gate extern uint64_t pci_debug_flags;
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate pci_debug_flag_to_string_t pci_flags_to_string [] = {
44*7c478bd9Sstevel@tonic-gate 	{DBG_ATTACH,		"attach"},
45*7c478bd9Sstevel@tonic-gate 	{DBG_DETACH,		"detach"},
46*7c478bd9Sstevel@tonic-gate 	{DBG_MAP,		"map"},
47*7c478bd9Sstevel@tonic-gate 	{DBG_RSV1,		"reserved"},
48*7c478bd9Sstevel@tonic-gate 	{DBG_A_INTX,		"add_intx"},
49*7c478bd9Sstevel@tonic-gate 	{DBG_R_INTX,		"rem_intx"},
50*7c478bd9Sstevel@tonic-gate 	{DBG_INIT_CLD,		"init_child"},
51*7c478bd9Sstevel@tonic-gate 	{DBG_CTLOPS,		"ctlops"},
52*7c478bd9Sstevel@tonic-gate 	{DBG_INTR,		"intr_wrapper"},
53*7c478bd9Sstevel@tonic-gate 	{DBG_ERR_INTR,		"pbm_error_intr"},
54*7c478bd9Sstevel@tonic-gate 	{DBG_BUS_FAULT,		"pci_fault"},
55*7c478bd9Sstevel@tonic-gate 	{DBG_DMA_ALLOCH,	"dma_alloc_handle"},
56*7c478bd9Sstevel@tonic-gate 	{DBG_DMA_FREEH,		"dma_free_handle"},
57*7c478bd9Sstevel@tonic-gate 	{DBG_DMA_BINDH,		"dma_bind_handle"},
58*7c478bd9Sstevel@tonic-gate 	{DBG_DMA_UNBINDH,	"dma_unbind_handle"},
59*7c478bd9Sstevel@tonic-gate 	{DBG_DMA_MAP,		"dma_map"},
60*7c478bd9Sstevel@tonic-gate 	{DBG_CHK_MOD,		"check_dma_mode"},
61*7c478bd9Sstevel@tonic-gate 	{DBG_BYPASS,		"bypass"},
62*7c478bd9Sstevel@tonic-gate 	{DBG_IOMMU,		"iommu"},
63*7c478bd9Sstevel@tonic-gate 	{DBG_DMA_WIN,		"dma_win"},
64*7c478bd9Sstevel@tonic-gate 	{DBG_MAP_WIN,		"map_window"},
65*7c478bd9Sstevel@tonic-gate 	{DBG_UNMAP_WIN,		"unmap_window"},
66*7c478bd9Sstevel@tonic-gate 	{DBG_DMA_CTL,		"dma_ctl"},
67*7c478bd9Sstevel@tonic-gate 	{DBG_DMA_SYNC,		"dma_sync"},
68*7c478bd9Sstevel@tonic-gate 	{DBG_DMA_SYNC_PBM,	"dma_sync_pbm"},
69*7c478bd9Sstevel@tonic-gate 	{DBG_FAST_DVMA,		"fast_dvma"},
70*7c478bd9Sstevel@tonic-gate 	{DBG_IB,		"ib"},
71*7c478bd9Sstevel@tonic-gate 	{DBG_CB,		"cb"},
72*7c478bd9Sstevel@tonic-gate 	{DBG_PBM,		"pbm"},
73*7c478bd9Sstevel@tonic-gate 	{DBG_OPEN,		"open"},
74*7c478bd9Sstevel@tonic-gate 	{DBG_CLOSE,		"close"},
75*7c478bd9Sstevel@tonic-gate 	{DBG_IOCTL,		"ioctl"},
76*7c478bd9Sstevel@tonic-gate 	{DBG_SC,		"sc"},
77*7c478bd9Sstevel@tonic-gate 	{DBG_PWR,		"pwr"},
78*7c478bd9Sstevel@tonic-gate 	{DBG_RELOC,		"dma_reloc"},
79*7c478bd9Sstevel@tonic-gate 	{DBG_TOOLS,		"tools"},
80*7c478bd9Sstevel@tonic-gate 	{DBG_PHYS_ACC,		"phys_acc"}
81*7c478bd9Sstevel@tonic-gate };
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate void
pci_debug(uint64_t flag,dev_info_t * dip,char * fmt,uintptr_t a1,uintptr_t a2,uintptr_t a3,uintptr_t a4,uintptr_t a5)84*7c478bd9Sstevel@tonic-gate pci_debug(uint64_t flag, dev_info_t *dip, char *fmt,
85*7c478bd9Sstevel@tonic-gate 	uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5)
86*7c478bd9Sstevel@tonic-gate {
87*7c478bd9Sstevel@tonic-gate 	char *s = NULL;
88*7c478bd9Sstevel@tonic-gate 	uint_t cont = 0;
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate 	if (flag & DBG_CONT) {
91*7c478bd9Sstevel@tonic-gate 		flag &= ~DBG_CONT;
92*7c478bd9Sstevel@tonic-gate 		cont = 1;
93*7c478bd9Sstevel@tonic-gate 	}
94*7c478bd9Sstevel@tonic-gate 	if ((pci_debug_flags & flag) == flag) {
95*7c478bd9Sstevel@tonic-gate 		int i;
96*7c478bd9Sstevel@tonic-gate 		int no_rec = (sizeof (pci_flags_to_string) /
97*7c478bd9Sstevel@tonic-gate 		    sizeof (pci_debug_flag_to_string_t));
98*7c478bd9Sstevel@tonic-gate 		for (i = 0; i < no_rec; i++) {
99*7c478bd9Sstevel@tonic-gate 			if (pci_flags_to_string[i].flag == flag) {
100*7c478bd9Sstevel@tonic-gate 				s = pci_flags_to_string[i].string;
101*7c478bd9Sstevel@tonic-gate 				break;
102*7c478bd9Sstevel@tonic-gate 			}
103*7c478bd9Sstevel@tonic-gate 		}
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate 		if (i >= no_rec)
106*7c478bd9Sstevel@tonic-gate 			s = "PCI debug unknown";
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate 		if (s && cont == 0) {
109*7c478bd9Sstevel@tonic-gate 			prom_printf("%s(%d): %s: ", ddi_driver_name(dip),
110*7c478bd9Sstevel@tonic-gate 			    ddi_get_instance(dip), s);
111*7c478bd9Sstevel@tonic-gate 		}
112*7c478bd9Sstevel@tonic-gate 		prom_printf(fmt, a1, a2, a3, a4, a5);
113*7c478bd9Sstevel@tonic-gate 	}
114*7c478bd9Sstevel@tonic-gate }
115*7c478bd9Sstevel@tonic-gate #endif
116