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