Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / uts / common / io / 1394 / t1394_errmsg.c
blob75c274d1125cf535c9964461f87c23e2f72f29e1
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright (c) 1999-2000 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * t1394_errmsg.c
31 * Utility function that targets can use to convert an error code into a
32 * printable string.
35 #include <sys/tnf_probe.h>
37 #include <sys/1394/t1394.h>
38 #include <sys/1394/s1394.h>
39 #include <sys/1394/cmd1394.h>
40 #include <sys/1394/ixl1394.h>
42 static const char *error_string[] = {
43 "CMD1394_CMDSUCCESS: Command Success", /* 0 */
44 "", /* -1 */
45 "", /* -2 */
46 "", /* -3 */
47 "", /* -4 */
48 "", /* -5 */
49 "", /* -6 */
50 "", /* -7 */
51 "", /* -8 */
52 "", /* -9 */
53 "CMD1394_ENULL_MBLK: NULL mblk pointer", /* -10 */
54 "CMD1394_EMBLK_TOO_SMALL: Mblk too small", /* -11 */
55 "CMD1394_ESTALE_GENERATION: Stale generation", /* -12 */
56 "CMD1394_EDEVICE_REMOVED: Device removed", /* -13 */
57 "CMD1394_EINVALID_CONTEXT: Invalid context", /* -14 */
58 "CMD1394_EINVALID_COMMAND: Invalid command", /* -15 */
59 "CMD1394_EUNKNOWN_ERROR: Unknown error", /* -16 */
60 "CMD1394_NOSTATUS: No status", /* -17 */
61 "CMD1394_EFATAL_ERROR: Fatal error", /* -18 */
62 "CMD1394_ENO_ATREQ: Unable to send ATREQ", /* -19 */
63 "CMD1394_EDEVICE_ERROR: Device error", /* -20 */
64 "", /* -21 */
65 "", /* -22 */
66 "", /* -23 */
67 "", /* -24 */
68 "", /* -25 */
69 "", /* -26 */
70 "", /* -27 */
71 "", /* -28 */
72 "", /* -29 */
73 "CMD1394_EDEVICE_BUSY: Device busy", /* -30 */
74 "CMD1394_ERETRIES_EXCEEDED: Too many retries", /* -31 */
75 "CMD1394_ETYPE_ERROR: Resp/ack type error", /* -32 */
76 "CMD1394_EDATA_ERROR: Resp/ack data error", /* -33 */
77 "CMD1394_EBUSRESET: Bus reset", /* -34 */
78 "CMD1394_EADDRESS_ERROR: Address error", /* -35 */
79 "CMD1394_ETIMEOUT: Command timed out", /* -36 */
80 "CMD1394_ERSRC_CONFLICT: Resource conflict" /* -37 */
83 static const char *ixl_compilation_error_string[] = {
84 "IXL1394_EMEM_ALLOC_FAIL: Memory allocation failed", /* -301 */
85 "IXL1394_EBAD_IXL_OPCODE: Bad opcode", /* -302 */
86 "IXL1394_EFRAGMENT_OFLO: Descriptor block overflow", /* -303 */
87 "IXL1394_ENO_DATA_PKTS: No descriptor blocks", /* -304 */
88 "IXL1394_EMISPLACED_RECV: Misplaced receive", /* -305 */
89 "IXL1394_EMISPLACED_SEND: Misplaced send", /* -306 */
90 "IXL1394_EPKT_HDR_MISSING: Packet header missing", /* -307 */
91 "IXL1394_ENULL_BUFFER_ADDR: NULL buffer address", /* -308 */
92 "IXL1394_EPKTSIZE_MAX_OFLO: Packet > 0xFFFF bytes", /* -309 */
93 "IXL1394_EPKTSIZE_RATIO: Improper packet length/count", /* -310 */
94 "IXL1394_EUNAPPLIED_SET_CMD: Unused set command", /* -311 */
95 "IXL1394_EDUPLICATE_SET_CMD: Multiple set commands", /* -312 */
96 "IXL1394_EJUMP_NOT_TO_LABEL: Jump destination not a label", /* -313 */
97 "IXL1394_EUPDATE_DISALLOWED: Update not allowed ", /* -314 */
98 "IXL1394_EBAD_SKIPMODE: Invalid skip mode", /* -315 */
99 "IXL1394_EWRONG_XR_CMD_MODE: Inapproriate xmit/recv mode", /* -316 */
100 "IXL1394_EINTERNAL_ERROR: Internal error", /* -317 */
101 "IXL1394_ENOT_IMPLEMENTED: Unimplemented error", /* -318 */
102 "IXL1394_EOPCODE_MISMATCH: Opcode mismatch", /* -319 */
103 "IXL1394_EOPCODE_DISALLOWED: Opcode disallowed for update", /* -320 */
104 "IXL1394_EBAD_SKIP_LABEL: Skip label destination not a label",
105 "IXL1394_EXFER_BUF_MISSING: Missing buffer in transfer command",
106 "IXL1394_EXFER_BUF_CNT_DIFF: Packet count differs in new buffer",
107 "IXL1394_EORIG_IXL_CORRUPTED: Original IXL program corrupted",
108 "IXL1394_ECOUNT_MISMATCH: IXL command count difference", /* -325 */
109 "IXL1394_EPRE_UPD_DMALOST: DMA path lost before update", /* -326 */
110 "IXL1394_EPOST_UPD_DMALOST: DMA path lost after update", /* -327 */
111 "IXL1394_ERISK_PROHIBITS_UPD: Risk prohibits update" /* -328 */
114 static const char *addr_error_string[] = {
115 "T1394_EALLOC_ADDR: Unable to alloc 1394 address block", /* -400 */
118 static const char *cec_error_string[] = {
119 "T1394_ENO_BANDWIDTH: Bandwidth allocation failed", /* -500 */
120 "T1394_ENO_CHANNEL: Channel allocation failed", /* -501 */
121 "T1394_ETARGET: One or more callbacks failed in isoch setup" /* -502 */
124 static const char *idma_error_string[] = {
125 "T1394_EIDMA_NO_RESRCS: No DMA resources", /* -600 */
126 "T1394_EIDMA_CONFLICT: Conflicting arguments" /* -601 */
129 static const char *cfgrom_error_string[] = {
130 "T1394_ECFGROM_FULL: Config ROM is full", /* -700 */
131 "T1394_EINVALID_PARAM: Invalid parameter in call", /* -701 */
132 "T1394_EINVALID_CONTEXT: Invalid context for call", /* -702 */
133 "T1394_NOERROR: No error" /* -703 */
136 #define T1394_ERRMSG_EMPTY_STRING ""
139 * Function: t1394_errmsg()
140 * Input(s): result Result code
141 * flags The flags parameter is unused (for now)
143 * Output(s): const string; empty string if invalid result code is passed in
145 * Description: t1394_errmsg() returns a string corresponding the error code
147 /* ARGSUSED */
148 const char *
149 t1394_errmsg(int result, uint_t flags)
151 int err;
152 const char *msg = T1394_ERRMSG_EMPTY_STRING;
154 if (result > 0) {
155 return (T1394_ERRMSG_EMPTY_STRING);
158 result = -result;
160 if ((result >= -CMD1394_ERR_FIRST) && (result <= -CMD1394_ERR_LAST)) {
161 err = result - (-CMD1394_ERR_FIRST);
162 msg = error_string[err];
163 } else if ((result >= -IXL1394_COMP_ERR_FIRST) &&
164 (result <= -IXL1394_COMP_ERR_LAST)) {
165 err = result - (-IXL1394_COMP_ERR_FIRST);
166 msg = ixl_compilation_error_string[err];
167 } else if ((result >= -T1394_EADDR_FIRST) &&
168 (result <= -T1394_EADDR_LAST)) {
169 err = result - (-T1394_EADDR_FIRST);
170 msg = addr_error_string[err];
171 } else if ((result >= -T1394_CEC_ERR_FIRST) &&
172 (result <= -T1394_CEC_ERR_LAST)) {
173 err = result - (-T1394_CEC_ERR_FIRST);
174 msg = cec_error_string[err];
175 } else if ((result >= -T1394_IDMA_ERR_FIRST) &&
176 (result <= -T1394_IDMA_ERR_LAST)) {
177 err = result - (-T1394_IDMA_ERR_FIRST);
178 msg = idma_error_string[err];
179 } else if ((result >= -T1394_ECFG_FIRST) &&
180 (result <= -T1394_ECFG_LAST)) {
181 err = result - (-T1394_ECFG_FIRST);
182 msg = cfgrom_error_string[err];
183 } else {
186 return (msg);