1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate *
4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate * with the License.
8*7c478bd9Sstevel@tonic-gate *
9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate *
20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1999-2000 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate * All rights reserved.
25*7c478bd9Sstevel@tonic-gate */
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gate /*
30*7c478bd9Sstevel@tonic-gate * t1394_errmsg.c
31*7c478bd9Sstevel@tonic-gate * Utility function that targets can use to convert an error code into a
32*7c478bd9Sstevel@tonic-gate * printable string.
33*7c478bd9Sstevel@tonic-gate */
34*7c478bd9Sstevel@tonic-gate
35*7c478bd9Sstevel@tonic-gate #include <sys/tnf_probe.h>
36*7c478bd9Sstevel@tonic-gate
37*7c478bd9Sstevel@tonic-gate #include <sys/1394/t1394.h>
38*7c478bd9Sstevel@tonic-gate #include <sys/1394/s1394.h>
39*7c478bd9Sstevel@tonic-gate #include <sys/1394/cmd1394.h>
40*7c478bd9Sstevel@tonic-gate #include <sys/1394/ixl1394.h>
41*7c478bd9Sstevel@tonic-gate
42*7c478bd9Sstevel@tonic-gate static const char *error_string[] = {
43*7c478bd9Sstevel@tonic-gate "CMD1394_CMDSUCCESS: Command Success", /* 0 */
44*7c478bd9Sstevel@tonic-gate "", /* -1 */
45*7c478bd9Sstevel@tonic-gate "", /* -2 */
46*7c478bd9Sstevel@tonic-gate "", /* -3 */
47*7c478bd9Sstevel@tonic-gate "", /* -4 */
48*7c478bd9Sstevel@tonic-gate "", /* -5 */
49*7c478bd9Sstevel@tonic-gate "", /* -6 */
50*7c478bd9Sstevel@tonic-gate "", /* -7 */
51*7c478bd9Sstevel@tonic-gate "", /* -8 */
52*7c478bd9Sstevel@tonic-gate "", /* -9 */
53*7c478bd9Sstevel@tonic-gate "CMD1394_ENULL_MBLK: NULL mblk pointer", /* -10 */
54*7c478bd9Sstevel@tonic-gate "CMD1394_EMBLK_TOO_SMALL: Mblk too small", /* -11 */
55*7c478bd9Sstevel@tonic-gate "CMD1394_ESTALE_GENERATION: Stale generation", /* -12 */
56*7c478bd9Sstevel@tonic-gate "CMD1394_EDEVICE_REMOVED: Device removed", /* -13 */
57*7c478bd9Sstevel@tonic-gate "CMD1394_EINVALID_CONTEXT: Invalid context", /* -14 */
58*7c478bd9Sstevel@tonic-gate "CMD1394_EINVALID_COMMAND: Invalid command", /* -15 */
59*7c478bd9Sstevel@tonic-gate "CMD1394_EUNKNOWN_ERROR: Unknown error", /* -16 */
60*7c478bd9Sstevel@tonic-gate "CMD1394_NOSTATUS: No status", /* -17 */
61*7c478bd9Sstevel@tonic-gate "CMD1394_EFATAL_ERROR: Fatal error", /* -18 */
62*7c478bd9Sstevel@tonic-gate "CMD1394_ENO_ATREQ: Unable to send ATREQ", /* -19 */
63*7c478bd9Sstevel@tonic-gate "CMD1394_EDEVICE_ERROR: Device error", /* -20 */
64*7c478bd9Sstevel@tonic-gate "", /* -21 */
65*7c478bd9Sstevel@tonic-gate "", /* -22 */
66*7c478bd9Sstevel@tonic-gate "", /* -23 */
67*7c478bd9Sstevel@tonic-gate "", /* -24 */
68*7c478bd9Sstevel@tonic-gate "", /* -25 */
69*7c478bd9Sstevel@tonic-gate "", /* -26 */
70*7c478bd9Sstevel@tonic-gate "", /* -27 */
71*7c478bd9Sstevel@tonic-gate "", /* -28 */
72*7c478bd9Sstevel@tonic-gate "", /* -29 */
73*7c478bd9Sstevel@tonic-gate "CMD1394_EDEVICE_BUSY: Device busy", /* -30 */
74*7c478bd9Sstevel@tonic-gate "CMD1394_ERETRIES_EXCEEDED: Too many retries", /* -31 */
75*7c478bd9Sstevel@tonic-gate "CMD1394_ETYPE_ERROR: Resp/ack type error", /* -32 */
76*7c478bd9Sstevel@tonic-gate "CMD1394_EDATA_ERROR: Resp/ack data error", /* -33 */
77*7c478bd9Sstevel@tonic-gate "CMD1394_EBUSRESET: Bus reset", /* -34 */
78*7c478bd9Sstevel@tonic-gate "CMD1394_EADDRESS_ERROR: Address error", /* -35 */
79*7c478bd9Sstevel@tonic-gate "CMD1394_ETIMEOUT: Command timed out", /* -36 */
80*7c478bd9Sstevel@tonic-gate "CMD1394_ERSRC_CONFLICT: Resource conflict" /* -37 */
81*7c478bd9Sstevel@tonic-gate };
82*7c478bd9Sstevel@tonic-gate
83*7c478bd9Sstevel@tonic-gate static const char *ixl_compilation_error_string[] = {
84*7c478bd9Sstevel@tonic-gate "IXL1394_EMEM_ALLOC_FAIL: Memory allocation failed", /* -301 */
85*7c478bd9Sstevel@tonic-gate "IXL1394_EBAD_IXL_OPCODE: Bad opcode", /* -302 */
86*7c478bd9Sstevel@tonic-gate "IXL1394_EFRAGMENT_OFLO: Descriptor block overflow", /* -303 */
87*7c478bd9Sstevel@tonic-gate "IXL1394_ENO_DATA_PKTS: No descriptor blocks", /* -304 */
88*7c478bd9Sstevel@tonic-gate "IXL1394_EMISPLACED_RECV: Misplaced receive", /* -305 */
89*7c478bd9Sstevel@tonic-gate "IXL1394_EMISPLACED_SEND: Misplaced send", /* -306 */
90*7c478bd9Sstevel@tonic-gate "IXL1394_EPKT_HDR_MISSING: Packet header missing", /* -307 */
91*7c478bd9Sstevel@tonic-gate "IXL1394_ENULL_BUFFER_ADDR: NULL buffer address", /* -308 */
92*7c478bd9Sstevel@tonic-gate "IXL1394_EPKTSIZE_MAX_OFLO: Packet > 0xFFFF bytes", /* -309 */
93*7c478bd9Sstevel@tonic-gate "IXL1394_EPKTSIZE_RATIO: Improper packet length/count", /* -310 */
94*7c478bd9Sstevel@tonic-gate "IXL1394_EUNAPPLIED_SET_CMD: Unused set command", /* -311 */
95*7c478bd9Sstevel@tonic-gate "IXL1394_EDUPLICATE_SET_CMD: Multiple set commands", /* -312 */
96*7c478bd9Sstevel@tonic-gate "IXL1394_EJUMP_NOT_TO_LABEL: Jump destination not a label", /* -313 */
97*7c478bd9Sstevel@tonic-gate "IXL1394_EUPDATE_DISALLOWED: Update not allowed ", /* -314 */
98*7c478bd9Sstevel@tonic-gate "IXL1394_EBAD_SKIPMODE: Invalid skip mode", /* -315 */
99*7c478bd9Sstevel@tonic-gate "IXL1394_EWRONG_XR_CMD_MODE: Inapproriate xmit/recv mode", /* -316 */
100*7c478bd9Sstevel@tonic-gate "IXL1394_EINTERNAL_ERROR: Internal error", /* -317 */
101*7c478bd9Sstevel@tonic-gate "IXL1394_ENOT_IMPLEMENTED: Unimplemented error", /* -318 */
102*7c478bd9Sstevel@tonic-gate "IXL1394_EOPCODE_MISMATCH: Opcode mismatch", /* -319 */
103*7c478bd9Sstevel@tonic-gate "IXL1394_EOPCODE_DISALLOWED: Opcode disallowed for update", /* -320 */
104*7c478bd9Sstevel@tonic-gate "IXL1394_EBAD_SKIP_LABEL: Skip label destination not a label",
105*7c478bd9Sstevel@tonic-gate "IXL1394_EXFER_BUF_MISSING: Missing buffer in transfer command",
106*7c478bd9Sstevel@tonic-gate "IXL1394_EXFER_BUF_CNT_DIFF: Packet count differs in new buffer",
107*7c478bd9Sstevel@tonic-gate "IXL1394_EORIG_IXL_CORRUPTED: Original IXL program corrupted",
108*7c478bd9Sstevel@tonic-gate "IXL1394_ECOUNT_MISMATCH: IXL command count difference", /* -325 */
109*7c478bd9Sstevel@tonic-gate "IXL1394_EPRE_UPD_DMALOST: DMA path lost before update", /* -326 */
110*7c478bd9Sstevel@tonic-gate "IXL1394_EPOST_UPD_DMALOST: DMA path lost after update", /* -327 */
111*7c478bd9Sstevel@tonic-gate "IXL1394_ERISK_PROHIBITS_UPD: Risk prohibits update" /* -328 */
112*7c478bd9Sstevel@tonic-gate };
113*7c478bd9Sstevel@tonic-gate
114*7c478bd9Sstevel@tonic-gate static const char *addr_error_string[] = {
115*7c478bd9Sstevel@tonic-gate "T1394_EALLOC_ADDR: Unable to alloc 1394 address block", /* -400 */
116*7c478bd9Sstevel@tonic-gate };
117*7c478bd9Sstevel@tonic-gate
118*7c478bd9Sstevel@tonic-gate static const char *cec_error_string[] = {
119*7c478bd9Sstevel@tonic-gate "T1394_ENO_BANDWIDTH: Bandwidth allocation failed", /* -500 */
120*7c478bd9Sstevel@tonic-gate "T1394_ENO_CHANNEL: Channel allocation failed", /* -501 */
121*7c478bd9Sstevel@tonic-gate "T1394_ETARGET: One or more callbacks failed in isoch setup" /* -502 */
122*7c478bd9Sstevel@tonic-gate };
123*7c478bd9Sstevel@tonic-gate
124*7c478bd9Sstevel@tonic-gate static const char *idma_error_string[] = {
125*7c478bd9Sstevel@tonic-gate "T1394_EIDMA_NO_RESRCS: No DMA resources", /* -600 */
126*7c478bd9Sstevel@tonic-gate "T1394_EIDMA_CONFLICT: Conflicting arguments" /* -601 */
127*7c478bd9Sstevel@tonic-gate };
128*7c478bd9Sstevel@tonic-gate
129*7c478bd9Sstevel@tonic-gate static const char *cfgrom_error_string[] = {
130*7c478bd9Sstevel@tonic-gate "T1394_ECFGROM_FULL: Config ROM is full", /* -700 */
131*7c478bd9Sstevel@tonic-gate "T1394_EINVALID_PARAM: Invalid parameter in call", /* -701 */
132*7c478bd9Sstevel@tonic-gate "T1394_EINVALID_CONTEXT: Invalid context for call", /* -702 */
133*7c478bd9Sstevel@tonic-gate "T1394_NOERROR: No error" /* -703 */
134*7c478bd9Sstevel@tonic-gate };
135*7c478bd9Sstevel@tonic-gate
136*7c478bd9Sstevel@tonic-gate #define T1394_ERRMSG_EMPTY_STRING ""
137*7c478bd9Sstevel@tonic-gate
138*7c478bd9Sstevel@tonic-gate /*
139*7c478bd9Sstevel@tonic-gate * Function: t1394_errmsg()
140*7c478bd9Sstevel@tonic-gate * Input(s): result Result code
141*7c478bd9Sstevel@tonic-gate * flags The flags parameter is unused (for now)
142*7c478bd9Sstevel@tonic-gate *
143*7c478bd9Sstevel@tonic-gate * Output(s): const string; empty string if invalid result code is passed in
144*7c478bd9Sstevel@tonic-gate *
145*7c478bd9Sstevel@tonic-gate * Description: t1394_errmsg() returns a string corresponding the error code
146*7c478bd9Sstevel@tonic-gate */
147*7c478bd9Sstevel@tonic-gate /* ARGSUSED */
148*7c478bd9Sstevel@tonic-gate const char *
t1394_errmsg(int result,uint_t flags)149*7c478bd9Sstevel@tonic-gate t1394_errmsg(int result, uint_t flags)
150*7c478bd9Sstevel@tonic-gate {
151*7c478bd9Sstevel@tonic-gate int err;
152*7c478bd9Sstevel@tonic-gate const char *msg = T1394_ERRMSG_EMPTY_STRING;
153*7c478bd9Sstevel@tonic-gate
154*7c478bd9Sstevel@tonic-gate TNF_PROBE_1_DEBUG(t1394_errmsg_enter, S1394_TNF_SL_STACK, "",
155*7c478bd9Sstevel@tonic-gate tnf_int, argument, result);
156*7c478bd9Sstevel@tonic-gate
157*7c478bd9Sstevel@tonic-gate if (result > 0) {
158*7c478bd9Sstevel@tonic-gate TNF_PROBE_2(t1394_errmsg, S1394_TNF_SL_ERROR, "",
159*7c478bd9Sstevel@tonic-gate tnf_string, msg, "invalid result argument",
160*7c478bd9Sstevel@tonic-gate tnf_int, result, result);
161*7c478bd9Sstevel@tonic-gate TNF_PROBE_0_DEBUG(t1394_errmsg_exit, S1394_TNF_SL_STACK, "");
162*7c478bd9Sstevel@tonic-gate return (T1394_ERRMSG_EMPTY_STRING);
163*7c478bd9Sstevel@tonic-gate }
164*7c478bd9Sstevel@tonic-gate
165*7c478bd9Sstevel@tonic-gate result = -result;
166*7c478bd9Sstevel@tonic-gate
167*7c478bd9Sstevel@tonic-gate if ((result >= -CMD1394_ERR_FIRST) && (result <= -CMD1394_ERR_LAST)) {
168*7c478bd9Sstevel@tonic-gate err = result - (-CMD1394_ERR_FIRST);
169*7c478bd9Sstevel@tonic-gate msg = error_string[err];
170*7c478bd9Sstevel@tonic-gate } else if ((result >= -IXL1394_COMP_ERR_FIRST) &&
171*7c478bd9Sstevel@tonic-gate (result <= -IXL1394_COMP_ERR_LAST)) {
172*7c478bd9Sstevel@tonic-gate err = result - (-IXL1394_COMP_ERR_FIRST);
173*7c478bd9Sstevel@tonic-gate msg = ixl_compilation_error_string[err];
174*7c478bd9Sstevel@tonic-gate } else if ((result >= -T1394_EADDR_FIRST) &&
175*7c478bd9Sstevel@tonic-gate (result <= -T1394_EADDR_LAST)) {
176*7c478bd9Sstevel@tonic-gate err = result - (-T1394_EADDR_FIRST);
177*7c478bd9Sstevel@tonic-gate msg = addr_error_string[err];
178*7c478bd9Sstevel@tonic-gate } else if ((result >= -T1394_CEC_ERR_FIRST) &&
179*7c478bd9Sstevel@tonic-gate (result <= -T1394_CEC_ERR_LAST)) {
180*7c478bd9Sstevel@tonic-gate err = result - (-T1394_CEC_ERR_FIRST);
181*7c478bd9Sstevel@tonic-gate msg = cec_error_string[err];
182*7c478bd9Sstevel@tonic-gate } else if ((result >= -T1394_IDMA_ERR_FIRST) &&
183*7c478bd9Sstevel@tonic-gate (result <= -T1394_IDMA_ERR_LAST)) {
184*7c478bd9Sstevel@tonic-gate err = result - (-T1394_IDMA_ERR_FIRST);
185*7c478bd9Sstevel@tonic-gate msg = idma_error_string[err];
186*7c478bd9Sstevel@tonic-gate } else if ((result >= -T1394_ECFG_FIRST) &&
187*7c478bd9Sstevel@tonic-gate (result <= -T1394_ECFG_LAST)) {
188*7c478bd9Sstevel@tonic-gate err = result - (-T1394_ECFG_FIRST);
189*7c478bd9Sstevel@tonic-gate msg = cfgrom_error_string[err];
190*7c478bd9Sstevel@tonic-gate } else {
191*7c478bd9Sstevel@tonic-gate TNF_PROBE_2(t1394_errmsg, S1394_TNF_SL_ERROR, "",
192*7c478bd9Sstevel@tonic-gate tnf_string, msg, "invalid result argument",
193*7c478bd9Sstevel@tonic-gate tnf_int, result, result);
194*7c478bd9Sstevel@tonic-gate }
195*7c478bd9Sstevel@tonic-gate
196*7c478bd9Sstevel@tonic-gate TNF_PROBE_0_DEBUG(t1394_errmsg_exit, S1394_TNF_SL_STACK, "");
197*7c478bd9Sstevel@tonic-gate
198*7c478bd9Sstevel@tonic-gate return (msg);
199*7c478bd9Sstevel@tonic-gate }
200