1218885Sdim/*-
2218885Sdim * Copyright (c) 2000 Michael Smith
3218885Sdim * Copyright (c) 2000 BSDi
4218885Sdim * All rights reserved.
5218885Sdim *
6218885Sdim * Redistribution and use in source and binary forms, with or without
7218885Sdim * modification, are permitted provided that the following conditions
8218885Sdim * are met:
9218885Sdim * 1. Redistributions of source code must retain the above copyright
10218885Sdim *    notice, this list of conditions and the following disclaimer.
11218885Sdim * 2. Redistributions in binary form must reproduce the above copyright
12218885Sdim *    notice, this list of conditions and the following disclaimer in the
13263509Sdim *    documentation and/or other materials provided with the distribution.
14263509Sdim *
15245431Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16218885Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17252723Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18263509Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19221345Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20263509Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21218885Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22218885Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23263509Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24218885Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25263509Sdim * SUCH DAMAGE.
26263509Sdim *
27263509Sdim * Copyright (c) 2002 Eric Moore
28263509Sdim * Copyright (c) 2002 LSI Logic Corporation
29263509Sdim * All rights reserved.
30263509Sdim *
31263509Sdim * Redistribution and use in source and binary forms, with or without
32263509Sdim * modification, are permitted provided that the following conditions
33245431Sdim * are met:
34263509Sdim * 1. Redistributions of source code must retain the above copyright
35221345Sdim *    notice, this list of conditions and the following disclaimer.
36263509Sdim * 2. Redistributions in binary form must reproduce the above copyright
37263509Sdim *    notice, this list of conditions and the following disclaimer in the
38263509Sdim *    documentation and/or other materials provided with the distribution.
39263509Sdim * 3. The party using or redistributing the source code and binary forms
40263509Sdim *    agrees to the disclaimer below and the terms and conditions set forth
41263509Sdim *    herein.
42263509Sdim *
43263509Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
44263509Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45263509Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46263509Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
47263509Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48263509Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49263509Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50263509Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51263509Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52263509Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53263509Sdim * SUCH DAMAGE.
54263509Sdim *
55263509Sdim *
56263509Sdim *	$FreeBSD$
57263509Sdim */
58263509Sdim
59263509Sdim/*
60263509Sdim * Lookup table for code-to-text translations.
61263509Sdim */
62263509Sdimstruct amr_code_lookup {
63263509Sdim    char	*string;
64263509Sdim    u_int32_t	code;
65263509Sdim};
66263509Sdim
67263509Sdimextern char	*amr_describe_code(struct amr_code_lookup *table, u_int32_t code);
68263509Sdim
69263509Sdim#ifndef AMR_DEFINE_TABLES
70263509Sdimextern struct amr_code_lookup amr_table_qinit[];
71263509Sdimextern struct amr_code_lookup amr_table_sinit[];
72263509Sdimextern struct amr_code_lookup amr_table_drvstate[];
73263509Sdim
74263509Sdim#else /* AMR_DEFINE_TABLES */
75263509Sdim
76263509Sdim/********************************************************************************
77263509Sdim * Look up a text description of a numeric code and return a pointer to same.
78263509Sdim */
79263509Sdimchar *
80263509Sdimamr_describe_code(struct amr_code_lookup *table, u_int32_t code)
81263509Sdim{
82263509Sdim    int		i;
83263509Sdim
84263509Sdim    for (i = 0; table[i].string != NULL; i++)
85263509Sdim	if (table[i].code == code)
86263509Sdim	    return(table[i].string);
87263509Sdim    return(table[i+1].string);
88263509Sdim}
89263509Sdim
90263509Sdimstruct amr_code_lookup amr_table_qinit[] = {
91263509Sdim    {"init scanning drives",		AMR_QINIT_SCAN},
92263509Sdim    {"init scanning initialising",	AMR_QINIT_SCANINIT},
93218885Sdim    {"init firmware initing",		AMR_QINIT_FIRMWARE},
94245431Sdim    {"init in progress",		AMR_QINIT_INPROG},
95245431Sdim    {"init spinning drives",		AMR_QINIT_SPINUP},
96221345Sdim    {"insufficient memory",		AMR_QINIT_NOMEM},
97263509Sdim    {"init flushing cache",		AMR_QINIT_CACHEFLUSH},
98263509Sdim    {"init successfully done",		AMR_QINIT_DONE},
99263509Sdim    {NULL, 0},
100263509Sdim    {"unknown init code", 0}
101263509Sdim};
102263509Sdim
103263509Sdimstruct amr_code_lookup amr_table_sinit[] = {
104263509Sdim    {"init abnormal terminated",	AMR_SINIT_ABEND},
105263509Sdim    {"insufficient memory",		AMR_SINIT_NOMEM},
106263509Sdim    {"firmware flushing cache",		AMR_SINIT_CACHEFLUSH},
107263509Sdim    {"init in progress",		AMR_SINIT_INPROG},
108263509Sdim    {"firmware spinning drives",	AMR_SINIT_SPINUP},
109263509Sdim    {"init successfully done",		AMR_SINIT_DONE},
110263509Sdim    {NULL, 0},
111263509Sdim    {"unknown init code", 0}
112263509Sdim};
113263509Sdim
114263509Sdimstruct amr_code_lookup amr_table_drvstate[] = {
115263509Sdim    {"offline",			AMR_DRV_OFFLINE},
116263509Sdim    {"degraded",		AMR_DRV_DEGRADED},
117263509Sdim    {"optimal",			AMR_DRV_OPTIMAL},
118263509Sdim    {"online",			AMR_DRV_ONLINE},
119263509Sdim    {"failed",			AMR_DRV_FAILED},
120263509Sdim    {"rebuild",			AMR_DRV_REBUILD},
121263509Sdim    {"hot spare",		AMR_DRV_HOTSPARE},
122263509Sdim    {NULL, 0},
123263509Sdim    {"unknown",	0}
124263509Sdim};
125263509Sdim
126263509Sdimstruct amr_code_lookup amr_table_adaptertype[] = {
127263509Sdim    {"Series 431",			AMR_SIG_431},
128263509Sdim    {"Series 438",			AMR_SIG_438},
129263509Sdim    {"Series 762",			AMR_SIG_762},
130263509Sdim    {"Integrated HP NetRAID (T5)",	AMR_SIG_T5},
131263509Sdim    {"Series 466",			AMR_SIG_466},
132263509Sdim    {"Series 467",			AMR_SIG_467},
133263509Sdim    {"Integrated HP NetRAID (T7)",	AMR_SIG_T7},
134263509Sdim    {"Series 490",			AMR_SIG_490},
135263509Sdim    {NULL, 0},
136263509Sdim    {"unknown adapter",	0}
137263509Sdim};
138263509Sdim
139263509Sdim#endif
140263509Sdim