xref: /illumos-gate/usr/src/common/mc/mc-amd/mcamd_err.c (revision c40a6cd785e883b3f052b122c332e21174fc1871)
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 #include <mcamd_api.h>
267aec1d6eScindi #include <mcamd_err.h>
277aec1d6eScindi 
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 };
357aec1d6eScindi 
367aec1d6eScindi static const int _mcamd_nerr = sizeof (_mcamd_errlist) /
377aec1d6eScindi     sizeof (_mcamd_errlist[0]);
387aec1d6eScindi 
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 }
457aec1d6eScindi 
467aec1d6eScindi const char *
mcamd_strerror(int err)477aec1d6eScindi mcamd_strerror(int err)
487aec1d6eScindi {
497aec1d6eScindi 	const char *str = NULL;
507aec1d6eScindi 
517aec1d6eScindi 	if (err >= EMCAMD_BASE && (err - EMCAMD_BASE) < _mcamd_nerr)
527aec1d6eScindi 		str = _mcamd_errlist[err - EMCAMD_BASE];
537aec1d6eScindi 
547aec1d6eScindi 	return (str == NULL ? "Unknown error" : str);
557aec1d6eScindi }
567aec1d6eScindi 
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