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