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/async.h> 33*0Sstevel@tonic-gate #include <sys/sunddi.h> /* dev_info_t */ 34*0Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 35*0Sstevel@tonic-gate #include <sys/disp.h> 36*0Sstevel@tonic-gate #include "px_debug.h" 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate /*LINTLIBRARY*/ 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate #ifdef DEBUG 41*0Sstevel@tonic-gate uint64_t px_debug_flags = (1ull << DBG_ERR_INTR | 1ull << DBG_MSG_INTR); 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate static char *px_debug_sym [] = { /* same sequence as px_debug_bit */ 44*0Sstevel@tonic-gate /* 0 */ "attach", 45*0Sstevel@tonic-gate /* 1 */ "detach", 46*0Sstevel@tonic-gate /* 2 */ "map", 47*0Sstevel@tonic-gate /* 3 */ "nex-ctlops", 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate /* 4 */ "introps", 50*0Sstevel@tonic-gate /* 5 */ "intx-add", 51*0Sstevel@tonic-gate /* 6 */ "intx-rem", 52*0Sstevel@tonic-gate /* 7 */ "intx-intr", 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate /* 8 */ "msiq", 55*0Sstevel@tonic-gate /* 9 */ "msiq-intr", 56*0Sstevel@tonic-gate /* 10 */ "msg", 57*0Sstevel@tonic-gate /* 11 */ "msg-intr", 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate /* 12 */ "msix-add", 60*0Sstevel@tonic-gate /* 13 */ "msix-rem", 61*0Sstevel@tonic-gate /* 14 */ "msix-intr", 62*0Sstevel@tonic-gate /* 15 */ "err", 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate /* 16 */ "dma-alloc", 65*0Sstevel@tonic-gate /* 17 */ "dma-free", 66*0Sstevel@tonic-gate /* 18 */ "dma-bind", 67*0Sstevel@tonic-gate /* 19 */ "dma-unbind", 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate /* 20 */ "chk-dma-mode", 70*0Sstevel@tonic-gate /* 21 */ "bypass-dma", 71*0Sstevel@tonic-gate /* 22 */ "fast-dvma", 72*0Sstevel@tonic-gate /* 23 */ "init_child", 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate /* 24 */ "dma-map", 75*0Sstevel@tonic-gate /* 25 */ "dma-win", 76*0Sstevel@tonic-gate /* 26 */ "map-win", 77*0Sstevel@tonic-gate /* 27 */ "unmap-win", 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate /* 28 */ "dma-ctl", 80*0Sstevel@tonic-gate /* 29 */ "dma-sync", 81*0Sstevel@tonic-gate /* 30 */ NULL, 82*0Sstevel@tonic-gate /* 31 */ NULL, 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate /* 32 */ "ib", 85*0Sstevel@tonic-gate /* 33 */ "cb", 86*0Sstevel@tonic-gate /* 34 */ "dmc", 87*0Sstevel@tonic-gate /* 35 */ "pec", 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate /* 36 */ "ilu", 90*0Sstevel@tonic-gate /* 37 */ "tlu", 91*0Sstevel@tonic-gate /* 38 */ "lpu", 92*0Sstevel@tonic-gate /* 39 */ NULL, 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate /* 40 */ "open", 95*0Sstevel@tonic-gate /* 41 */ "close", 96*0Sstevel@tonic-gate /* 42 */ "ioctl", 97*0Sstevel@tonic-gate /* 43 */ "pwr", 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate /* 44 */ "lib-cfg", 100*0Sstevel@tonic-gate /* 45 */ "lib-intr", 101*0Sstevel@tonic-gate /* 46 */ "lib-dma", 102*0Sstevel@tonic-gate /* 47 */ "lib-msiq", 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate /* 48 */ "lib-msi", 105*0Sstevel@tonic-gate /* 49 */ "lib-msg", 106*0Sstevel@tonic-gate /* 50 */ "NULL", 107*0Sstevel@tonic-gate /* 51 */ "NULL", 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gate /* 52 */ "tools", 110*0Sstevel@tonic-gate /* 53 */ "phys_acc", 111*0Sstevel@tonic-gate /* LAST */ "unknown" 112*0Sstevel@tonic-gate }; 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate void 115*0Sstevel@tonic-gate px_dbg(px_debug_bit_t bit, dev_info_t *dip, char *fmt, ...) 116*0Sstevel@tonic-gate { 117*0Sstevel@tonic-gate int cont = bit >> DBG_BITS; 118*0Sstevel@tonic-gate va_list ap; 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate bit &= DBG_MASK; 121*0Sstevel@tonic-gate if (bit >= sizeof (px_debug_sym) / sizeof (char *)) 122*0Sstevel@tonic-gate return; 123*0Sstevel@tonic-gate if (!(1ull << bit & px_debug_flags)) 124*0Sstevel@tonic-gate return; 125*0Sstevel@tonic-gate if (cont) 126*0Sstevel@tonic-gate goto body; 127*0Sstevel@tonic-gate if (dip) { 128*0Sstevel@tonic-gate if (servicing_interrupt()) { 129*0Sstevel@tonic-gate cmn_err(CE_NOTE, "%s(%d): %s: ", ddi_driver_name(dip), 130*0Sstevel@tonic-gate ddi_get_instance(dip), px_debug_sym[bit]); 131*0Sstevel@tonic-gate } else { 132*0Sstevel@tonic-gate prom_printf("%s(%d): %s: ", ddi_driver_name(dip), 133*0Sstevel@tonic-gate ddi_get_instance(dip), px_debug_sym[bit]); 134*0Sstevel@tonic-gate } 135*0Sstevel@tonic-gate } else { 136*0Sstevel@tonic-gate if (servicing_interrupt()) { 137*0Sstevel@tonic-gate cmn_err(CE_NOTE, "px: %s: ", px_debug_sym[bit]); 138*0Sstevel@tonic-gate } else { 139*0Sstevel@tonic-gate prom_printf("px: %s: ", px_debug_sym[bit]); 140*0Sstevel@tonic-gate } 141*0Sstevel@tonic-gate } 142*0Sstevel@tonic-gate body: 143*0Sstevel@tonic-gate va_start(ap, fmt); 144*0Sstevel@tonic-gate if (servicing_interrupt()) { 145*0Sstevel@tonic-gate vcmn_err(CE_NOTE, fmt, ap); 146*0Sstevel@tonic-gate } else { 147*0Sstevel@tonic-gate prom_vprintf(fmt, ap); 148*0Sstevel@tonic-gate } 149*0Sstevel@tonic-gate va_end(ap); 150*0Sstevel@tonic-gate } 151*0Sstevel@tonic-gate #else /* DEBUG */ 152*0Sstevel@tonic-gate 153*0Sstevel@tonic-gate 154*0Sstevel@tonic-gate /*ARGSUSED*/ 155*0Sstevel@tonic-gate void 156*0Sstevel@tonic-gate px_log2ce(px_debug_bit_t bit, dev_info_t *dip, char *fmt, ...) 157*0Sstevel@tonic-gate { 158*0Sstevel@tonic-gate va_list ap; 159*0Sstevel@tonic-gate if (dip) 160*0Sstevel@tonic-gate cmn_err(CE_WARN, "%s(%d): ", 161*0Sstevel@tonic-gate ddi_driver_name(dip), ddi_get_instance(dip)); 162*0Sstevel@tonic-gate else 163*0Sstevel@tonic-gate cmn_err(CE_WARN, "px: "); 164*0Sstevel@tonic-gate va_start(ap, fmt); 165*0Sstevel@tonic-gate vcmn_err(CE_CONT, fmt, ap); 166*0Sstevel@tonic-gate va_end(ap); 167*0Sstevel@tonic-gate } 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gate #endif /* DEBUG */ 170