10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 230Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * PCI nexus driver general debug support 310Sstevel@tonic-gate */ 320Sstevel@tonic-gate #include <sys/async.h> 330Sstevel@tonic-gate #include <sys/sunddi.h> /* dev_info_t */ 340Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 350Sstevel@tonic-gate #include <sys/disp.h> 360Sstevel@tonic-gate #include "px_debug.h" 370Sstevel@tonic-gate 380Sstevel@tonic-gate /*LINTLIBRARY*/ 390Sstevel@tonic-gate 400Sstevel@tonic-gate #ifdef DEBUG 41*332Sjchu uint64_t px_debug_flags = 0; 420Sstevel@tonic-gate 430Sstevel@tonic-gate static char *px_debug_sym [] = { /* same sequence as px_debug_bit */ 440Sstevel@tonic-gate /* 0 */ "attach", 450Sstevel@tonic-gate /* 1 */ "detach", 460Sstevel@tonic-gate /* 2 */ "map", 470Sstevel@tonic-gate /* 3 */ "nex-ctlops", 480Sstevel@tonic-gate 490Sstevel@tonic-gate /* 4 */ "introps", 500Sstevel@tonic-gate /* 5 */ "intx-add", 510Sstevel@tonic-gate /* 6 */ "intx-rem", 520Sstevel@tonic-gate /* 7 */ "intx-intr", 530Sstevel@tonic-gate 540Sstevel@tonic-gate /* 8 */ "msiq", 550Sstevel@tonic-gate /* 9 */ "msiq-intr", 560Sstevel@tonic-gate /* 10 */ "msg", 570Sstevel@tonic-gate /* 11 */ "msg-intr", 580Sstevel@tonic-gate 590Sstevel@tonic-gate /* 12 */ "msix-add", 600Sstevel@tonic-gate /* 13 */ "msix-rem", 610Sstevel@tonic-gate /* 14 */ "msix-intr", 620Sstevel@tonic-gate /* 15 */ "err", 630Sstevel@tonic-gate 640Sstevel@tonic-gate /* 16 */ "dma-alloc", 650Sstevel@tonic-gate /* 17 */ "dma-free", 660Sstevel@tonic-gate /* 18 */ "dma-bind", 670Sstevel@tonic-gate /* 19 */ "dma-unbind", 680Sstevel@tonic-gate 690Sstevel@tonic-gate /* 20 */ "chk-dma-mode", 700Sstevel@tonic-gate /* 21 */ "bypass-dma", 710Sstevel@tonic-gate /* 22 */ "fast-dvma", 720Sstevel@tonic-gate /* 23 */ "init_child", 730Sstevel@tonic-gate 740Sstevel@tonic-gate /* 24 */ "dma-map", 750Sstevel@tonic-gate /* 25 */ "dma-win", 760Sstevel@tonic-gate /* 26 */ "map-win", 770Sstevel@tonic-gate /* 27 */ "unmap-win", 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* 28 */ "dma-ctl", 800Sstevel@tonic-gate /* 29 */ "dma-sync", 810Sstevel@tonic-gate /* 30 */ NULL, 820Sstevel@tonic-gate /* 31 */ NULL, 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* 32 */ "ib", 850Sstevel@tonic-gate /* 33 */ "cb", 860Sstevel@tonic-gate /* 34 */ "dmc", 870Sstevel@tonic-gate /* 35 */ "pec", 880Sstevel@tonic-gate 890Sstevel@tonic-gate /* 36 */ "ilu", 900Sstevel@tonic-gate /* 37 */ "tlu", 910Sstevel@tonic-gate /* 38 */ "lpu", 920Sstevel@tonic-gate /* 39 */ NULL, 930Sstevel@tonic-gate 940Sstevel@tonic-gate /* 40 */ "open", 950Sstevel@tonic-gate /* 41 */ "close", 960Sstevel@tonic-gate /* 42 */ "ioctl", 970Sstevel@tonic-gate /* 43 */ "pwr", 980Sstevel@tonic-gate 990Sstevel@tonic-gate /* 44 */ "lib-cfg", 1000Sstevel@tonic-gate /* 45 */ "lib-intr", 1010Sstevel@tonic-gate /* 46 */ "lib-dma", 1020Sstevel@tonic-gate /* 47 */ "lib-msiq", 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate /* 48 */ "lib-msi", 1050Sstevel@tonic-gate /* 49 */ "lib-msg", 1060Sstevel@tonic-gate /* 50 */ "NULL", 1070Sstevel@tonic-gate /* 51 */ "NULL", 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate /* 52 */ "tools", 1100Sstevel@tonic-gate /* 53 */ "phys_acc", 1110Sstevel@tonic-gate /* LAST */ "unknown" 1120Sstevel@tonic-gate }; 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate void 1150Sstevel@tonic-gate px_dbg(px_debug_bit_t bit, dev_info_t *dip, char *fmt, ...) 1160Sstevel@tonic-gate { 1170Sstevel@tonic-gate int cont = bit >> DBG_BITS; 1180Sstevel@tonic-gate va_list ap; 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate bit &= DBG_MASK; 1210Sstevel@tonic-gate if (bit >= sizeof (px_debug_sym) / sizeof (char *)) 1220Sstevel@tonic-gate return; 1230Sstevel@tonic-gate if (!(1ull << bit & px_debug_flags)) 1240Sstevel@tonic-gate return; 1250Sstevel@tonic-gate if (cont) 1260Sstevel@tonic-gate goto body; 127*332Sjchu 128*332Sjchu if (dip) 129*332Sjchu prom_printf("%s(%d): %s: ", ddi_driver_name(dip), 130*332Sjchu ddi_get_instance(dip), px_debug_sym[bit]); 131*332Sjchu else 132*332Sjchu prom_printf("px: %s: ", px_debug_sym[bit]); 1330Sstevel@tonic-gate body: 1340Sstevel@tonic-gate va_start(ap, fmt); 135*332Sjchu prom_vprintf(fmt, ap); 1360Sstevel@tonic-gate va_end(ap); 1370Sstevel@tonic-gate } 1380Sstevel@tonic-gate #endif /* DEBUG */ 139