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