1507c3241Smlf /*
2507c3241Smlf * CDDL HEADER START
3507c3241Smlf *
4507c3241Smlf * The contents of this file are subject to the terms of the
5507c3241Smlf * Common Development and Distribution License (the "License").
6507c3241Smlf * You may not use this file except in compliance with the License.
7507c3241Smlf *
8507c3241Smlf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9507c3241Smlf * or http://www.opensolaris.org/os/licensing.
10507c3241Smlf * See the License for the specific language governing permissions
11507c3241Smlf * and limitations under the License.
12507c3241Smlf *
13507c3241Smlf * When distributing Covered Code, include this CDDL HEADER in each
14507c3241Smlf * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15507c3241Smlf * If applicable, add the following below this CDDL HEADER, with the
16507c3241Smlf * fields enclosed by brackets "[]" replaced with your own identifying
17507c3241Smlf * information: Portions Copyright [yyyy] [name of copyright owner]
18507c3241Smlf *
19507c3241Smlf * CDDL HEADER END
20507c3241Smlf */
21507c3241Smlf
22507c3241Smlf /*
23*2df1fe9cSrandyf * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24507c3241Smlf * Use is subject to license terms.
25507c3241Smlf */
26507c3241Smlf
27507c3241Smlf #include "ghd.h"
28507c3241Smlf #include "ghd_debug.h"
29507c3241Smlf
30507c3241Smlf #if !(defined(GHD_DEBUG) || defined(__lint))
31507c3241Smlf ulong_t ghd_debug_flags = 0;
32507c3241Smlf #else
33507c3241Smlf ulong_t ghd_debug_flags = GDBG_FLAG_ERROR
34507c3241Smlf /* | GDBG_FLAG_WAITQ */
35507c3241Smlf /* | GDBG_FLAG_INTR */
36507c3241Smlf /* | GDBG_FLAG_START */
37507c3241Smlf /* | GDBG_FLAG_WARN */
38507c3241Smlf /* | GDBG_FLAG_DMA */
39507c3241Smlf /* | GDBG_FLAG_PEND_INTR */
40507c3241Smlf /* | GDBG_FLAG_START */
41507c3241Smlf /* | GDBG_FLAG_PKT */
42507c3241Smlf /* | GDBG_FLAG_INIT */
43507c3241Smlf ;
44507c3241Smlf #endif
45507c3241Smlf
46507c3241Smlf void
ghd_err(const char * fmt,...)47507c3241Smlf ghd_err(const char *fmt, ...)
48507c3241Smlf {
49507c3241Smlf va_list ap;
50507c3241Smlf
51507c3241Smlf va_start(ap, fmt);
52507c3241Smlf vcmn_err(CE_CONT, fmt, ap);
53507c3241Smlf va_end(ap);
54507c3241Smlf }
55507c3241Smlf
56507c3241Smlf #if defined(GHD_DEBUG)
57*2df1fe9cSrandyf #include <sys/promif.h>
58507c3241Smlf #define PRF prom_printf
59507c3241Smlf
60507c3241Smlf static void
ghd_dump_ccc(ccc_t * P)61507c3241Smlf ghd_dump_ccc(ccc_t *P)
62507c3241Smlf {
63507c3241Smlf PRF("nextp 0x%p tmrp 0x%p label 0x%p &mutex 0x%p\n",
64*2df1fe9cSrandyf P->ccc_nextp, P->ccc_tmrp, P->ccc_label, &P->ccc_activel_mutex);
65507c3241Smlf PRF("&activel 0x%p dip 0x%p iblock 0x%p\n",
66*2df1fe9cSrandyf &P->ccc_activel, P->ccc_hba_dip, P->ccc_iblock);
67507c3241Smlf PRF("softid 0x%p &hba_mutext 0x%p\n poll 0x%p\n",
68*2df1fe9cSrandyf P->ccc_soft_id, &P->ccc_hba_mutex, &P->ccc_hba_pollmode);
69507c3241Smlf PRF("&devs 0x%p &waitq_mutex 0x%p &waitq 0x%p\n",
70*2df1fe9cSrandyf &P->ccc_devs, &P->ccc_waitq_mutex, &P->ccc_waitq);
71507c3241Smlf PRF("waitq_freezetime 0x%p waitq_freezedelay %p\n",
72*2df1fe9cSrandyf &P->ccc_waitq_freezetime, &P->ccc_waitq_freezedelay);
73507c3241Smlf PRF("dq softid 0x%p &dq_mutex 0x%p &doneq 0x%p\n",
74*2df1fe9cSrandyf P->ccc_doneq_softid, &P->ccc_doneq_mutex, &P->ccc_doneq);
75507c3241Smlf PRF("handle 0x%p &ccballoc 0x%p\n",
76*2df1fe9cSrandyf P->ccc_hba_handle, &P->ccc_ccballoc);
77507c3241Smlf PRF("hba_reset_notify_callback 0x%p notify_list 0x%p mutex 0x%p\n",
78*2df1fe9cSrandyf P->ccc_hba_reset_notify_callback, &P->ccc_reset_notify_list,
79*2df1fe9cSrandyf &P->ccc_reset_notify_mutex);
80507c3241Smlf }
81507c3241Smlf
82507c3241Smlf
83507c3241Smlf static void
ghd_dump_gcmd(gcmd_t * P)84507c3241Smlf ghd_dump_gcmd(gcmd_t *P)
85507c3241Smlf {
86507c3241Smlf PRF("cmd_q nextp 0x%p prevp 0x%p private 0x%p\n",
87507c3241Smlf P->cmd_q.l2_nextp, P->cmd_q.l2_prevp, P->cmd_q.l2_private);
88507c3241Smlf PRF("state %ul wq lev %ld flags 0x%x\n",
89507c3241Smlf P->cmd_state, P->cmd_waitq_level, P->cmd_flags);
90507c3241Smlf PRF("timer Q nextp 0x%p prevp 0x%p private 0x%p\n",
91507c3241Smlf P->cmd_timer_link.l2_nextp, P->cmd_timer_link.l2_prevp,
92507c3241Smlf P->cmd_timer_link.l2_private);
93507c3241Smlf
94507c3241Smlf PRF("start time 0x%lx timeout 0x%lx hba private 0x%p pktp 0x%p\n",
95507c3241Smlf P->cmd_start_time, P->cmd_timeout, P->cmd_private, P->cmd_pktp);
96507c3241Smlf PRF("gtgtp 0x%p dma_flags 0x%x dma_handle 0x%p dmawin 0x%p "
97507c3241Smlf "dmaseg 0x%p\n", P->cmd_gtgtp, P->cmd_dma_flags,
98507c3241Smlf P->cmd_dma_handle, P->cmd_dmawin, P->cmd_dmaseg);
99507c3241Smlf PRF("wcount %d windex %d ccount %d cindex %d\n",
100507c3241Smlf P->cmd_wcount, P->cmd_windex, P->cmd_ccount, P->cmd_cindex);
101507c3241Smlf PRF("totxfer %ld\n", P->cmd_totxfer);
102507c3241Smlf }
103507c3241Smlf #endif
104