165245Smsmith/*-
265245Smsmith * Copyright (c) 2000 Michael Smith
365245Smsmith * Copyright (c) 2000 BSDi
465245Smsmith * All rights reserved.
565245Smsmith *
665245Smsmith * Redistribution and use in source and binary forms, with or without
765245Smsmith * modification, are permitted provided that the following conditions
865245Smsmith * are met:
965245Smsmith * 1. Redistributions of source code must retain the above copyright
1065245Smsmith *    notice, this list of conditions and the following disclaimer.
1165245Smsmith * 2. Redistributions in binary form must reproduce the above copyright
1265245Smsmith *    notice, this list of conditions and the following disclaimer in the
1365245Smsmith *    documentation and/or other materials provided with the distribution.
1465245Smsmith *
1565245Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1665245Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1765245Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1865245Smsmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1965245Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2065245Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2165245Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2265245Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2365245Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2465245Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2565245Smsmith * SUCH DAMAGE.
2665245Smsmith *
27106225Semoore * Copyright (c) 2002 Eric Moore
28106225Semoore * Copyright (c) 2002 LSI Logic Corporation
29106225Semoore * All rights reserved.
30106225Semoore *
31106225Semoore * Redistribution and use in source and binary forms, with or without
32106225Semoore * modification, are permitted provided that the following conditions
33106225Semoore * are met:
34106225Semoore * 1. Redistributions of source code must retain the above copyright
35106225Semoore *    notice, this list of conditions and the following disclaimer.
36106225Semoore * 2. Redistributions in binary form must reproduce the above copyright
37106225Semoore *    notice, this list of conditions and the following disclaimer in the
38106225Semoore *    documentation and/or other materials provided with the distribution.
39105419Semoore * 3. The party using or redistributing the source code and binary forms
40106225Semoore *    agrees to the disclaimer below and the terms and conditions set forth
41105419Semoore *    herein.
42105419Semoore *
43106225Semoore * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
44106225Semoore * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45106225Semoore * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46106225Semoore * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
47106225Semoore * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48106225Semoore * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49106225Semoore * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50106225Semoore * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51106225Semoore * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52106225Semoore * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53106225Semoore * SUCH DAMAGE.
54105419Semoore *
55106225Semoore *
5665245Smsmith *	$FreeBSD$
5765245Smsmith */
5865245Smsmith
5965245Smsmith/*
6065245Smsmith * Lookup table for code-to-text translations.
6165245Smsmith */
6265245Smsmithstruct amr_code_lookup {
6365245Smsmith    char	*string;
6465245Smsmith    u_int32_t	code;
6565245Smsmith};
6665245Smsmith
6765245Smsmithextern char	*amr_describe_code(struct amr_code_lookup *table, u_int32_t code);
6865245Smsmith
6965245Smsmith#ifndef AMR_DEFINE_TABLES
7065245Smsmithextern struct amr_code_lookup amr_table_qinit[];
7165245Smsmithextern struct amr_code_lookup amr_table_sinit[];
7265245Smsmithextern struct amr_code_lookup amr_table_drvstate[];
7365245Smsmith
7465245Smsmith#else /* AMR_DEFINE_TABLES */
7565245Smsmith
7665245Smsmith/********************************************************************************
7765245Smsmith * Look up a text description of a numeric code and return a pointer to same.
7865245Smsmith */
7965245Smsmithchar *
8065245Smsmithamr_describe_code(struct amr_code_lookup *table, u_int32_t code)
8165245Smsmith{
8265245Smsmith    int		i;
8365245Smsmith
8465245Smsmith    for (i = 0; table[i].string != NULL; i++)
8565245Smsmith	if (table[i].code == code)
8665245Smsmith	    return(table[i].string);
8765245Smsmith    return(table[i+1].string);
8865245Smsmith}
8965245Smsmith
9065245Smsmithstruct amr_code_lookup amr_table_qinit[] = {
9165245Smsmith    {"init scanning drives",		AMR_QINIT_SCAN},
9265245Smsmith    {"init scanning initialising",	AMR_QINIT_SCANINIT},
9365245Smsmith    {"init firmware initing",		AMR_QINIT_FIRMWARE},
9465245Smsmith    {"init in progress",		AMR_QINIT_INPROG},
9565245Smsmith    {"init spinning drives",		AMR_QINIT_SPINUP},
9665245Smsmith    {"insufficient memory",		AMR_QINIT_NOMEM},
9765245Smsmith    {"init flushing cache",		AMR_QINIT_CACHEFLUSH},
9865245Smsmith    {"init successfully done",		AMR_QINIT_DONE},
9965245Smsmith    {NULL, 0},
10065245Smsmith    {"unknown init code", 0}
10165245Smsmith};
10265245Smsmith
10365245Smsmithstruct amr_code_lookup amr_table_sinit[] = {
10465245Smsmith    {"init abnormal terminated",	AMR_SINIT_ABEND},
10565245Smsmith    {"insufficient memory",		AMR_SINIT_NOMEM},
10665245Smsmith    {"firmware flushing cache",		AMR_SINIT_CACHEFLUSH},
10765245Smsmith    {"init in progress",		AMR_SINIT_INPROG},
10865245Smsmith    {"firmware spinning drives",	AMR_SINIT_SPINUP},
10965245Smsmith    {"init successfully done",		AMR_SINIT_DONE},
11065245Smsmith    {NULL, 0},
11165245Smsmith    {"unknown init code", 0}
11265245Smsmith};
11365245Smsmith
11465245Smsmithstruct amr_code_lookup amr_table_drvstate[] = {
11565245Smsmith    {"offline",			AMR_DRV_OFFLINE},
11665245Smsmith    {"degraded",		AMR_DRV_DEGRADED},
11765245Smsmith    {"optimal",			AMR_DRV_OPTIMAL},
11865245Smsmith    {"online",			AMR_DRV_ONLINE},
11965245Smsmith    {"failed",			AMR_DRV_FAILED},
12065245Smsmith    {"rebuild",			AMR_DRV_REBUILD},
12165245Smsmith    {"hot spare",		AMR_DRV_HOTSPARE},
12265245Smsmith    {NULL, 0},
12365245Smsmith    {"unknown",	0}
12465245Smsmith};
12565245Smsmith
12665245Smsmithstruct amr_code_lookup amr_table_adaptertype[] = {
12765245Smsmith    {"Series 431",			AMR_SIG_431},
12865245Smsmith    {"Series 438",			AMR_SIG_438},
12965245Smsmith    {"Series 762",			AMR_SIG_762},
13065245Smsmith    {"Integrated HP NetRAID (T5)",	AMR_SIG_T5},
13165245Smsmith    {"Series 466",			AMR_SIG_466},
13265245Smsmith    {"Series 467",			AMR_SIG_467},
13365245Smsmith    {"Integrated HP NetRAID (T7)",	AMR_SIG_T7},
13465245Smsmith    {"Series 490",			AMR_SIG_490},
13565245Smsmith    {NULL, 0},
13665245Smsmith    {"unknown adapter",	0}
13765245Smsmith};
13865245Smsmith
13965245Smsmith#endif
140