1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate /*
30*0Sstevel@tonic-gate * PCI nexus driver general debug support
31*0Sstevel@tonic-gate */
32*0Sstevel@tonic-gate #include <sys/promif.h> /* prom_printf */
33*0Sstevel@tonic-gate #include <sys/async.h>
34*0Sstevel@tonic-gate #include <sys/sunddi.h> /* dev_info_t */
35*0Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
36*0Sstevel@tonic-gate #include <sys/pci/pci_obj.h>
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gate /*LINTLIBRARY*/
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gate #ifdef DEBUG
41*0Sstevel@tonic-gate extern uint64_t pci_debug_flags;
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gate pci_debug_flag_to_string_t pci_flags_to_string [] = {
44*0Sstevel@tonic-gate {DBG_ATTACH, "attach"},
45*0Sstevel@tonic-gate {DBG_DETACH, "detach"},
46*0Sstevel@tonic-gate {DBG_MAP, "map"},
47*0Sstevel@tonic-gate {DBG_RSV1, "reserved"},
48*0Sstevel@tonic-gate {DBG_A_INTX, "add_intx"},
49*0Sstevel@tonic-gate {DBG_R_INTX, "rem_intx"},
50*0Sstevel@tonic-gate {DBG_INIT_CLD, "init_child"},
51*0Sstevel@tonic-gate {DBG_CTLOPS, "ctlops"},
52*0Sstevel@tonic-gate {DBG_INTR, "intr_wrapper"},
53*0Sstevel@tonic-gate {DBG_ERR_INTR, "pbm_error_intr"},
54*0Sstevel@tonic-gate {DBG_BUS_FAULT, "pci_fault"},
55*0Sstevel@tonic-gate {DBG_DMA_ALLOCH, "dma_alloc_handle"},
56*0Sstevel@tonic-gate {DBG_DMA_FREEH, "dma_free_handle"},
57*0Sstevel@tonic-gate {DBG_DMA_BINDH, "dma_bind_handle"},
58*0Sstevel@tonic-gate {DBG_DMA_UNBINDH, "dma_unbind_handle"},
59*0Sstevel@tonic-gate {DBG_DMA_MAP, "dma_map"},
60*0Sstevel@tonic-gate {DBG_CHK_MOD, "check_dma_mode"},
61*0Sstevel@tonic-gate {DBG_BYPASS, "bypass"},
62*0Sstevel@tonic-gate {DBG_IOMMU, "iommu"},
63*0Sstevel@tonic-gate {DBG_DMA_WIN, "dma_win"},
64*0Sstevel@tonic-gate {DBG_MAP_WIN, "map_window"},
65*0Sstevel@tonic-gate {DBG_UNMAP_WIN, "unmap_window"},
66*0Sstevel@tonic-gate {DBG_DMA_CTL, "dma_ctl"},
67*0Sstevel@tonic-gate {DBG_DMA_SYNC, "dma_sync"},
68*0Sstevel@tonic-gate {DBG_DMA_SYNC_PBM, "dma_sync_pbm"},
69*0Sstevel@tonic-gate {DBG_FAST_DVMA, "fast_dvma"},
70*0Sstevel@tonic-gate {DBG_IB, "ib"},
71*0Sstevel@tonic-gate {DBG_CB, "cb"},
72*0Sstevel@tonic-gate {DBG_PBM, "pbm"},
73*0Sstevel@tonic-gate {DBG_OPEN, "open"},
74*0Sstevel@tonic-gate {DBG_CLOSE, "close"},
75*0Sstevel@tonic-gate {DBG_IOCTL, "ioctl"},
76*0Sstevel@tonic-gate {DBG_SC, "sc"},
77*0Sstevel@tonic-gate {DBG_PWR, "pwr"},
78*0Sstevel@tonic-gate {DBG_RELOC, "dma_reloc"},
79*0Sstevel@tonic-gate {DBG_TOOLS, "tools"},
80*0Sstevel@tonic-gate {DBG_PHYS_ACC, "phys_acc"}
81*0Sstevel@tonic-gate };
82*0Sstevel@tonic-gate
83*0Sstevel@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*0Sstevel@tonic-gate pci_debug(uint64_t flag, dev_info_t *dip, char *fmt,
85*0Sstevel@tonic-gate uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5)
86*0Sstevel@tonic-gate {
87*0Sstevel@tonic-gate char *s = NULL;
88*0Sstevel@tonic-gate uint_t cont = 0;
89*0Sstevel@tonic-gate
90*0Sstevel@tonic-gate if (flag & DBG_CONT) {
91*0Sstevel@tonic-gate flag &= ~DBG_CONT;
92*0Sstevel@tonic-gate cont = 1;
93*0Sstevel@tonic-gate }
94*0Sstevel@tonic-gate if ((pci_debug_flags & flag) == flag) {
95*0Sstevel@tonic-gate int i;
96*0Sstevel@tonic-gate int no_rec = (sizeof (pci_flags_to_string) /
97*0Sstevel@tonic-gate sizeof (pci_debug_flag_to_string_t));
98*0Sstevel@tonic-gate for (i = 0; i < no_rec; i++) {
99*0Sstevel@tonic-gate if (pci_flags_to_string[i].flag == flag) {
100*0Sstevel@tonic-gate s = pci_flags_to_string[i].string;
101*0Sstevel@tonic-gate break;
102*0Sstevel@tonic-gate }
103*0Sstevel@tonic-gate }
104*0Sstevel@tonic-gate
105*0Sstevel@tonic-gate if (i >= no_rec)
106*0Sstevel@tonic-gate s = "PCI debug unknown";
107*0Sstevel@tonic-gate
108*0Sstevel@tonic-gate if (s && cont == 0) {
109*0Sstevel@tonic-gate prom_printf("%s(%d): %s: ", ddi_driver_name(dip),
110*0Sstevel@tonic-gate ddi_get_instance(dip), s);
111*0Sstevel@tonic-gate }
112*0Sstevel@tonic-gate prom_printf(fmt, a1, a2, a3, a4, a5);
113*0Sstevel@tonic-gate }
114*0Sstevel@tonic-gate }
115*0Sstevel@tonic-gate #endif
116