xref: /titanic_44/usr/src/common/smbios/smb_error.c (revision 84ab085a13f931bc78e7415e7ce921dbaa14fcb3)
1*84ab085aSmws /*
2*84ab085aSmws  * CDDL HEADER START
3*84ab085aSmws  *
4*84ab085aSmws  * The contents of this file are subject to the terms of the
5*84ab085aSmws  * Common Development and Distribution License, Version 1.0 only
6*84ab085aSmws  * (the "License").  You may not use this file except in compliance
7*84ab085aSmws  * with the License.
8*84ab085aSmws  *
9*84ab085aSmws  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*84ab085aSmws  * or http://www.opensolaris.org/os/licensing.
11*84ab085aSmws  * See the License for the specific language governing permissions
12*84ab085aSmws  * and limitations under the License.
13*84ab085aSmws  *
14*84ab085aSmws  * When distributing Covered Code, include this CDDL HEADER in each
15*84ab085aSmws  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*84ab085aSmws  * If applicable, add the following below this CDDL HEADER, with the
17*84ab085aSmws  * fields enclosed by brackets "[]" replaced with your own identifying
18*84ab085aSmws  * information: Portions Copyright [yyyy] [name of copyright owner]
19*84ab085aSmws  *
20*84ab085aSmws  * CDDL HEADER END
21*84ab085aSmws  */
22*84ab085aSmws 
23*84ab085aSmws /*
24*84ab085aSmws  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25*84ab085aSmws  * Use is subject to license terms.
26*84ab085aSmws  */
27*84ab085aSmws 
28*84ab085aSmws #pragma ident	"%Z%%M%	%I%	%E% SMI"
29*84ab085aSmws 
30*84ab085aSmws #include <sys/smbios_impl.h>
31*84ab085aSmws 
32*84ab085aSmws static const char *const _smb_errlist[] = {
33*84ab085aSmws 	"System does not export an SMBIOS table",	/* ESMB_NOTFOUND */
34*84ab085aSmws 	"Failed to map SMBIOS table",			/* ESMB_MAPDEV */
35*84ab085aSmws 	"Failed to locate specified structure",		/* ESMB_NOENT */
36*84ab085aSmws 	"Failed to allocate memory",			/* ESMB_NOMEM */
37*84ab085aSmws 	"Failed to read SMBIOS entry point",		/* ESMB_NOHDR */
38*84ab085aSmws 	"Failed to read SMBIOS structure table",	/* ESMB_NOSTAB */
39*84ab085aSmws 	"Generic info not available for structure",	/* ESMB_NOINFO */
40*84ab085aSmws 	"Structure table is shorter than expected",	/* ESMB_SHORT */
41*84ab085aSmws 	"SMBIOS data structure is corrupted",		/* ESMB_CORRUPT */
42*84ab085aSmws 	"Requested library version is not supported",	/* ESMB_VERSION */
43*84ab085aSmws 	"Structure type is not supported by this BIOS",	/* ESMB_NOTSUP */
44*84ab085aSmws 	"Header is not a valid SMBIOS entry point",	/* ESMB_HEADER */
45*84ab085aSmws 	"SMBIOS format is too old for processing",	/* ESMB_OLD */
46*84ab085aSmws 	"SMBIOS format is new and not yet supported",	/* ESMB_NEW */
47*84ab085aSmws 	"SMBIOS header checksum mismatch",		/* ESMB_CKSUM */
48*84ab085aSmws 	"Invalid argument specified in library call",	/* ESMB_INVAL */
49*84ab085aSmws 	"Structure is not of the expected type",	/* ESMB_TYPE */
50*84ab085aSmws 	"Unknown SMBIOS error"				/* ESMB_UNKNOWN */
51*84ab085aSmws };
52*84ab085aSmws 
53*84ab085aSmws static const int _smb_nerr = sizeof (_smb_errlist) / sizeof (_smb_errlist[0]);
54*84ab085aSmws 
55*84ab085aSmws const char *
smbios_errmsg(int error)56*84ab085aSmws smbios_errmsg(int error)
57*84ab085aSmws {
58*84ab085aSmws 	const char *str;
59*84ab085aSmws 
60*84ab085aSmws 	if (error >= ESMB_BASE && (error - ESMB_BASE) < _smb_nerr)
61*84ab085aSmws 		str = _smb_errlist[error - ESMB_BASE];
62*84ab085aSmws 	else
63*84ab085aSmws 		str = smb_strerror(error);
64*84ab085aSmws 
65*84ab085aSmws 	return (str ? str : "Unknown error");
66*84ab085aSmws }
67*84ab085aSmws 
68*84ab085aSmws int
smbios_errno(smbios_hdl_t * shp)69*84ab085aSmws smbios_errno(smbios_hdl_t *shp)
70*84ab085aSmws {
71*84ab085aSmws 	return (shp->sh_err);
72*84ab085aSmws }
73*84ab085aSmws 
74*84ab085aSmws int
smb_set_errno(smbios_hdl_t * shp,int error)75*84ab085aSmws smb_set_errno(smbios_hdl_t *shp, int error)
76*84ab085aSmws {
77*84ab085aSmws 	shp->sh_err = error;
78*84ab085aSmws 	return (SMB_ERR);
79*84ab085aSmws }
80