mem.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <mem.h>
#include <fm/fmd_fmri.h>
#include <string.h>
#include <strings.h>
/*
* The scheme plugin for mem FMRIs.
*/
static mem_dimm_map_t *
{
return (dm);
}
return (NULL);
}
/*
* Returns 0 with serial numbers if found, -1 (with errno set) for errors. If
* the unum (or a component of same) wasn't found, -1 is returned with errno
* set to ENOENT.
*/
static int
{
int i, rc = 0;
return (-1); /* errno is set for us */
for (i = 0; i < ndimms; i++) {
break;
}
/*
* We don't have a cached copy, or the copy we've got is
* out of date. Look it up again.
*/
break;
}
}
}
if (i == ndimms) {
} else {
}
return (rc);
}
static int
{
char *unum;
return (fmd_fmri_set_errno(EINVAL));
return (0);
}
{
const char *fmt = "mem:///component=%1$s";
int i;
return (-1); /* errno is set for us */
/*
* If we leave the unum as-is, the spaces and colons will be escaped,
* rendering the resulting FMRI pretty much unreadable. We're therefore
* going to do some escaping of our own first.
*/
for (i = 0; i < presz - 1; i++) {
presz - (i + 2));
} else if (preunum[i] == ' ') {
preunum[i] = ',';
}
}
return (size);
}
int
{
int rc;
return (0); /* nothing to add - no s/n support here */
return (fmd_fmri_set_errno(EINVAL));
return (0); /* fmri is already expanded */
return (fmd_fmri_set_errno(EINVAL));
return (-1); /* errno is set for us */
nserids);
if (rc != 0)
return (fmd_fmri_set_errno(EINVAL));
return (0);
}
static int
{
int i;
return (0);
for (i = 0; i < nserids1; i++) {
return (0);
}
return (1);
}
int
{
int rc;
return (1); /* assume it's there - no s/n support here */
return (-1); /* errno is set for us */
&nnvlserids) != 0)
return (fmd_fmri_set_errno(EINVAL));
/*
* Errors are only signalled to the caller if they're
* the caller's fault. This isn't - it's a failure on
* our part to burst or read the serial numbers. We'll
* whine about it, and tell the caller the named
*/
fmd_fmri_warn("failed to retrieve serial number for "
"unum %s", unum);
}
return (0);
}
return (rc);
}
int
{
return (-1); /* errno is set for us */
/* container has a PA; only match if containee has same PA */
}
return (1);
}
int
{
/*
* without page addresses will be reported as usable.
*/
return (fmd_fmri_set_errno(EINVAL));
return (0); /* no page, so assume it's still usable */
else if (err != 0)
return (fmd_fmri_set_errno(EINVAL));
return (0); /* the page wonders, "why all the fuss?" */
/*
* The page has been retired, is in the process of being
* retired, or doesn't exist. The latter is valid if the page
* existed in the past but has been DR'd out.
*/
return (1);
} else {
/*
* Errors are only signalled to the caller if they're the
* caller's fault. This isn't - it's a failure of the
* retirement-check code. We'll whine about it and tell
* the caller the page is unusable.
*/
fmd_fmri_warn("failed to determine usability of page %llx",
pageaddr);
return (1);
}
}
int
fmd_fmri_init(void)
{
return (mem_discover());
}
void
fmd_fmri_fini(void)
{
mem_destroy();
}