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.
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.
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]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include "dmfe_impl.h"
29 * ========== Message printing & debug routines ==========
42 mutex_init(prtdata
.mutex
, NULL
, MUTEX_DRIVER
, NULL
);
48 mutex_destroy(prtdata
.mutex
);
52 * Backend print routine for all the routines below
55 dmfe_vprt(const char *fmt
, va_list args
)
59 ASSERT(mutex_owned(prtdata
.mutex
));
61 (void) vsnprintf(buf
, sizeof (buf
), fmt
, args
);
62 cmn_err(prtdata
.level
, prtdata
.fmt
, prtdata
.ifname
, buf
);
66 * Report a run-time error (CE_WARN, to console & log)
67 * Also logs all the chip's operating registers
70 dmfe_warning(dmfe_t
*dmfep
, const char *fmt
, ...)
76 mutex_enter(prtdata
.mutex
);
77 prtdata
.ifname
= dmfep
->ifname
;
78 prtdata
.fmt
= "%s: %s";
79 prtdata
.level
= CE_WARN
;
86 * Record all the chip registers in the logfile
88 for (i
= 0; i
< 16; ++i
) {
89 reg
= dmfe_chip_get32(dmfep
, 8*i
);
90 cmn_err(CE_NOTE
, "!%s: CR%d\t%08x", dmfep
->ifname
, i
, reg
);
93 mutex_exit(prtdata
.mutex
);
97 * Log a programming error (CE_WARN, log only)
100 dmfe_error(dmfe_t
*dmfep
, const char *fmt
, ...)
104 mutex_enter(prtdata
.mutex
);
105 prtdata
.ifname
= dmfep
->ifname
;
106 prtdata
.fmt
= "!%s: %s";
107 prtdata
.level
= CE_WARN
;
110 dmfe_vprt(fmt
, args
);
113 mutex_exit(prtdata
.mutex
);
117 * Report a run-time event (CE_NOTE, to console & log)
120 dmfe_notice(dmfe_t
*dmfep
, const char *fmt
, ...)
124 mutex_enter(prtdata
.mutex
);
125 prtdata
.ifname
= dmfep
->ifname
;
126 prtdata
.fmt
= "%s: %s";
127 prtdata
.level
= CE_NOTE
;
130 dmfe_vprt(fmt
, args
);
133 mutex_exit(prtdata
.mutex
);
137 * Log a run-time event (CE_NOTE, log only)
140 dmfe_log(dmfe_t
*dmfep
, const char *fmt
, ...)
144 mutex_enter(prtdata
.mutex
);
145 prtdata
.ifname
= dmfep
->ifname
;
146 prtdata
.fmt
= "!%s: %s";
147 prtdata
.level
= CE_NOTE
;
150 dmfe_vprt(fmt
, args
);
153 mutex_exit(prtdata
.mutex
);