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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2007 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#include "ghd.h"
30#include "ghd_debug.h"
31
32#if !(defined(GHD_DEBUG) || defined(__lint))
33ulong_t	ghd_debug_flags = 0;
34#else
35ulong_t	ghd_debug_flags = GDBG_FLAG_ERROR
36		/*	| GDBG_FLAG_WAITQ	*/
37		/*	| GDBG_FLAG_INTR	*/
38		/*	| GDBG_FLAG_START	*/
39		/*	| GDBG_FLAG_WARN	*/
40		/*	| GDBG_FLAG_DMA		*/
41		/*	| GDBG_FLAG_PEND_INTR	*/
42		/*	| GDBG_FLAG_START	*/
43		/*	| GDBG_FLAG_PKT		*/
44		/*	| GDBG_FLAG_INIT	*/
45			;
46#endif
47
48void
49ghd_err(const char *fmt, ...)
50{
51	va_list	ap;
52
53	va_start(ap, fmt);
54	vcmn_err(CE_CONT, fmt, ap);
55	va_end(ap);
56}
57
58#if defined(GHD_DEBUG)
59#include <sys/promif.h>
60#define	PRF	prom_printf
61
62static void
63ghd_dump_ccc(ccc_t *P)
64{
65	PRF("nextp 0x%p tmrp 0x%p label 0x%p &mutex 0x%p\n",
66	    P->ccc_nextp, P->ccc_tmrp, P->ccc_label, &P->ccc_activel_mutex);
67	PRF("&activel 0x%p dip 0x%p iblock 0x%p\n",
68	    &P->ccc_activel, P->ccc_hba_dip, P->ccc_iblock);
69	PRF("softid 0x%p &hba_mutext 0x%p\n poll 0x%p\n",
70	    P->ccc_soft_id, &P->ccc_hba_mutex, &P->ccc_hba_pollmode);
71	PRF("&devs 0x%p &waitq_mutex 0x%p &waitq 0x%p\n",
72	    &P->ccc_devs, &P->ccc_waitq_mutex, &P->ccc_waitq);
73	PRF("waitq_freezetime 0x%p waitq_freezedelay %p\n",
74	    &P->ccc_waitq_freezetime, &P->ccc_waitq_freezedelay);
75	PRF("dq softid 0x%p &dq_mutex 0x%p &doneq 0x%p\n",
76	    P->ccc_doneq_softid, &P->ccc_doneq_mutex, &P->ccc_doneq);
77	PRF("handle 0x%p &ccballoc 0x%p\n",
78	    P->ccc_hba_handle, &P->ccc_ccballoc);
79	PRF("hba_reset_notify_callback 0x%p notify_list 0x%p mutex 0x%p\n",
80	    P->ccc_hba_reset_notify_callback, &P->ccc_reset_notify_list,
81	    &P->ccc_reset_notify_mutex);
82}
83
84
85static void
86ghd_dump_gcmd(gcmd_t *P)
87{
88	PRF("cmd_q nextp 0x%p prevp 0x%p private 0x%p\n",
89	    P->cmd_q.l2_nextp, P->cmd_q.l2_prevp, P->cmd_q.l2_private);
90	PRF("state %ul wq lev %ld flags 0x%x\n",
91	    P->cmd_state, P->cmd_waitq_level, P->cmd_flags);
92	PRF("timer Q nextp 0x%p prevp 0x%p private 0x%p\n",
93	    P->cmd_timer_link.l2_nextp, P->cmd_timer_link.l2_prevp,
94	    P->cmd_timer_link.l2_private);
95
96	PRF("start time 0x%lx timeout 0x%lx hba private 0x%p pktp 0x%p\n",
97	    P->cmd_start_time, P->cmd_timeout, P->cmd_private, P->cmd_pktp);
98	PRF("gtgtp 0x%p dma_flags 0x%x dma_handle 0x%p dmawin 0x%p "
99	    "dmaseg 0x%p\n", P->cmd_gtgtp, P->cmd_dma_flags,
100	    P->cmd_dma_handle, P->cmd_dmawin, P->cmd_dmaseg);
101	PRF("wcount %d windex %d ccount %d cindex %d\n",
102	    P->cmd_wcount, P->cmd_windex, P->cmd_ccount, P->cmd_cindex);
103	PRF("totxfer %ld\n", P->cmd_totxfer);
104}
105#endif
106