1 /*
2 * CDDL HEADER START
3 *
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.
8 *
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.
13 *
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]
19 *
20 * CDDL HEADER END
21 */
22
23 /*
24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
28 #pragma ident "%Z%%M% %I% %E% SMI"
29
30 #include <sys/smbios_impl.h>
31
32 static const char *const _smb_errlist[] = {
33 "System does not export an SMBIOS table", /* ESMB_NOTFOUND */
34 "Failed to map SMBIOS table", /* ESMB_MAPDEV */
35 "Failed to locate specified structure", /* ESMB_NOENT */
36 "Failed to allocate memory", /* ESMB_NOMEM */
37 "Failed to read SMBIOS entry point", /* ESMB_NOHDR */
38 "Failed to read SMBIOS structure table", /* ESMB_NOSTAB */
39 "Generic info not available for structure", /* ESMB_NOINFO */
40 "Structure table is shorter than expected", /* ESMB_SHORT */
41 "SMBIOS data structure is corrupted", /* ESMB_CORRUPT */
42 "Requested library version is not supported", /* ESMB_VERSION */
43 "Structure type is not supported by this BIOS", /* ESMB_NOTSUP */
44 "Header is not a valid SMBIOS entry point", /* ESMB_HEADER */
45 "SMBIOS format is too old for processing", /* ESMB_OLD */
46 "SMBIOS format is new and not yet supported", /* ESMB_NEW */
47 "SMBIOS header checksum mismatch", /* ESMB_CKSUM */
48 "Invalid argument specified in library call", /* ESMB_INVAL */
49 "Structure is not of the expected type", /* ESMB_TYPE */
50 "Unknown SMBIOS error" /* ESMB_UNKNOWN */
51 };
52
53 static const int _smb_nerr = sizeof (_smb_errlist) / sizeof (_smb_errlist[0]);
54
55 const char *
smbios_errmsg(int error)56 smbios_errmsg(int error)
57 {
58 const char *str;
59
60 if (error >= ESMB_BASE && (error - ESMB_BASE) < _smb_nerr)
61 str = _smb_errlist[error - ESMB_BASE];
62 else
63 str = smb_strerror(error);
64
65 return (str ? str : "Unknown error");
66 }
67
68 int
smbios_errno(smbios_hdl_t * shp)69 smbios_errno(smbios_hdl_t *shp)
70 {
71 return (shp->sh_err);
72 }
73
74 int
smb_set_errno(smbios_hdl_t * shp,int error)75 smb_set_errno(smbios_hdl_t *shp, int error)
76 {
77 shp->sh_err = error;
78 return (SMB_ERR);
79 }
80