summaryrefslogtreecommitdiff
path: root/usr/src/uts/sun4u/io/pci/pci_debug.c
blob: e4c8c56176d9c2078b7aecca2d91652dca67dcff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#pragma ident	"%Z%%M%	%I%	%E% SMI"

/*
 * PCI nexus driver general debug support
 */
#include <sys/promif.h>		/* prom_printf */
#include <sys/async.h>
#include <sys/sunddi.h>		/* dev_info_t */
#include <sys/ddi_impldefs.h>
#include <sys/pci/pci_obj.h>

/*LINTLIBRARY*/

#ifdef DEBUG
extern uint64_t pci_debug_flags;

pci_debug_flag_to_string_t pci_flags_to_string [] = {
	{DBG_ATTACH,		"attach"},
	{DBG_DETACH,		"detach"},
	{DBG_MAP,		"map"},
	{DBG_RSV1,		"reserved"},
	{DBG_A_INTX,		"add_intx"},
	{DBG_R_INTX,		"rem_intx"},
	{DBG_INIT_CLD,		"init_child"},
	{DBG_CTLOPS,		"ctlops"},
	{DBG_INTR,		"intr_wrapper"},
	{DBG_ERR_INTR,		"pbm_error_intr"},
	{DBG_BUS_FAULT,		"pci_fault"},
	{DBG_DMA_ALLOCH,	"dma_alloc_handle"},
	{DBG_DMA_FREEH,		"dma_free_handle"},
	{DBG_DMA_BINDH,		"dma_bind_handle"},
	{DBG_DMA_UNBINDH,	"dma_unbind_handle"},
	{DBG_DMA_MAP,		"dma_map"},
	{DBG_CHK_MOD,		"check_dma_mode"},
	{DBG_BYPASS,		"bypass"},
	{DBG_IOMMU,		"iommu"},
	{DBG_DMA_WIN,		"dma_win"},
	{DBG_MAP_WIN,		"map_window"},
	{DBG_UNMAP_WIN,		"unmap_window"},
	{DBG_DMA_CTL,		"dma_ctl"},
	{DBG_DMA_SYNC,		"dma_sync"},
	{DBG_DMA_SYNC_PBM,	"dma_sync_pbm"},
	{DBG_FAST_DVMA,		"fast_dvma"},
	{DBG_IB,		"ib"},
	{DBG_CB,		"cb"},
	{DBG_PBM,		"pbm"},
	{DBG_OPEN,		"open"},
	{DBG_CLOSE,		"close"},
	{DBG_IOCTL,		"ioctl"},
	{DBG_SC,		"sc"},
	{DBG_PWR,		"pwr"},
	{DBG_RELOC,		"dma_reloc"},
	{DBG_TOOLS,		"tools"},
	{DBG_PHYS_ACC,		"phys_acc"}
};

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)
{
	char *s = NULL;
	uint_t cont = 0;

	if (flag & DBG_CONT) {
		flag &= ~DBG_CONT;
		cont = 1;
	}
	if ((pci_debug_flags & flag) == flag) {
		int i;
		int no_rec = (sizeof (pci_flags_to_string) /
		    sizeof (pci_debug_flag_to_string_t));
		for (i = 0; i < no_rec; i++) {
			if (pci_flags_to_string[i].flag == flag) {
				s = pci_flags_to_string[i].string;
				break;
			}
		}

		if (i >= no_rec)
			s = "PCI debug unknown";

		if (s && cont == 0) {
			prom_printf("%s(%d): %s: ", ddi_driver_name(dip),
			    ddi_get_instance(dip), s);
		}
		prom_printf(fmt, a1, a2, a3, a4, a5);
	}
}
#endif