17aec1d6eScindi /*
27aec1d6eScindi * CDDL HEADER START
37aec1d6eScindi *
47aec1d6eScindi * The contents of this file are subject to the terms of the
5*4156fc34Sgavinm * Common Development and Distribution License (the "License").
6*4156fc34Sgavinm * You may not use this file except in compliance with the License.
77aec1d6eScindi *
87aec1d6eScindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97aec1d6eScindi * or http://www.opensolaris.org/os/licensing.
107aec1d6eScindi * See the License for the specific language governing permissions
117aec1d6eScindi * and limitations under the License.
127aec1d6eScindi *
137aec1d6eScindi * When distributing Covered Code, include this CDDL HEADER in each
147aec1d6eScindi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157aec1d6eScindi * If applicable, add the following below this CDDL HEADER, with the
167aec1d6eScindi * fields enclosed by brackets "[]" replaced with your own identifying
177aec1d6eScindi * information: Portions Copyright [yyyy] [name of copyright owner]
187aec1d6eScindi *
197aec1d6eScindi * CDDL HEADER END
207aec1d6eScindi *
217aec1d6eScindi * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
227aec1d6eScindi * Use is subject to license terms.
237aec1d6eScindi */
247aec1d6eScindi
257aec1d6eScindi #pragma ident "%Z%%M% %I% %E% SMI"
267aec1d6eScindi
277aec1d6eScindi #include <mcamd_api.h>
287aec1d6eScindi #include <mcamd_err.h>
297aec1d6eScindi
307aec1d6eScindi static const char *const _mcamd_errlist[] = {
317aec1d6eScindi "Invalid syndrome", /* EMCAMD_SYNDINVALID */
327aec1d6eScindi "Invalid configuration tree", /* EMCAMD_TREEINVALID */
33*4156fc34Sgavinm "Address not found", /* EMCAMD_NOADDR */
34*4156fc34Sgavinm "Operation not supported", /* EMCAMD_NOTSUP */
35*4156fc34Sgavinm "Too few valid address bits", /* EMCAMD_INSUFF_RES */
367aec1d6eScindi };
377aec1d6eScindi
387aec1d6eScindi static const int _mcamd_nerr = sizeof (_mcamd_errlist) /
397aec1d6eScindi sizeof (_mcamd_errlist[0]);
407aec1d6eScindi
417aec1d6eScindi void *
mcamd_set_errno_ptr(struct mcamd_hdl * mcamd,int err)427aec1d6eScindi mcamd_set_errno_ptr(struct mcamd_hdl *mcamd, int err)
437aec1d6eScindi {
447aec1d6eScindi (void) mcamd_set_errno(mcamd, err);
457aec1d6eScindi return (NULL);
467aec1d6eScindi }
477aec1d6eScindi
487aec1d6eScindi const char *
mcamd_strerror(int err)497aec1d6eScindi mcamd_strerror(int err)
507aec1d6eScindi {
517aec1d6eScindi const char *str = NULL;
527aec1d6eScindi
537aec1d6eScindi if (err >= EMCAMD_BASE && (err - EMCAMD_BASE) < _mcamd_nerr)
547aec1d6eScindi str = _mcamd_errlist[err - EMCAMD_BASE];
557aec1d6eScindi
567aec1d6eScindi return (str == NULL ? "Unknown error" : str);
577aec1d6eScindi }
587aec1d6eScindi
597aec1d6eScindi const char *
mcamd_errmsg(struct mcamd_hdl * mcamd)607aec1d6eScindi mcamd_errmsg(struct mcamd_hdl *mcamd)
617aec1d6eScindi {
627aec1d6eScindi return (mcamd_strerror(mcamd_errno(mcamd)));
637aec1d6eScindi }
64