simmstat.c revision 29949e866e40b95795203f3ee46f44a197c946e4
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 <sys/ddi_impldefs.h>
#include <sys/sysmacros.h>
#include <sys/autoconf.h>
#include <sys/simmstat.h>
/* Useful debugging Stuff */
#include <sys/nexusdebug.h>
/*
* Function prototypes
*/
static void simmstat_add_kstats(struct simmstat_soft_state *);
static int simmstat_kstat_update(kstat_t *, int);
/*
* Configuration data structures
*/
static struct cb_ops simmstat_cb_ops = {
nulldev, /* open */
nulldev, /* close */
nulldev, /* strategy */
nulldev, /* print */
nodev, /* dump */
nulldev, /* read */
nulldev, /* write */
nulldev, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* cb_prop_op */
0, /* streamtab */
CB_REV, /* rev */
nodev, /* cb_aread */
nodev /* cb_awrite */
};
static struct dev_ops simmstat_ops = {
DEVO_REV, /* rev */
0, /* refcnt */
ddi_no_info, /* getinfo */
nulldev, /* identify */
nulldev, /* probe */
simmstat_attach, /* attach */
simmstat_detach, /* detach */
nulldev, /* reset */
&simmstat_cb_ops, /* cb_ops */
(struct bus_ops *)0, /* bus_ops */
nulldev /* power */
};
/*
* Driver globals
*/
void *simmstatp;
extern struct mod_ops mod_driverops;
&mod_driverops, /* module type, this one is a driver */
"SIMM-status Leaf v%I%", /* module name */
&simmstat_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
MODREV_1, /* rev */
(void *)&modldrv,
};
#ifndef lint
static char _depends_on[] = "drv/fhc";
#endif /* lint */
/*
* These are the module initialization routines.
*/
int
_init(void)
{
int error;
sizeof (struct simmstat_soft_state), 1)) != 0)
return (error);
return (mod_install(&modlinkage));
}
int
_fini(void)
{
int error;
return (error);
return (0);
}
int
{
}
static int
{
struct simmstat_soft_state *softsp;
int instance;
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
return (DDI_FAILURE);
/* Set the dip in the soft state */
/* Get the board number from this nodes parent device. */
goto bad;
}
/* map in the registers for this device. */
instance);
goto bad;
}
"pm-hardware-state", "no-suspend-resume");
/* create the kstats for this device */
return (DDI_SUCCESS);
bad:
return (DDI_FAILURE);
}
/* ARGSUSED */
static int
{
int instance;
struct simmstat_soft_state *softsp;
/* get the instance of this devi */
/* get the soft state pointer for this device node */
switch (cmd) {
case DDI_SUSPEND:
return (DDI_SUCCESS);
case DDI_DETACH:
break;
else
/* FALLTHROUGH */
default:
return (DDI_FAILURE);
}
/* remove the kstat for this board */
/* unmap the registers */
/* free up the soft state */
return (DDI_SUCCESS);
}
static void
{
struct kstat *simmstat_ksp;
}
}
/*
* Kstats only need ks_update functions when they change dynamically
* at run time.
* In the case of the simmstat registers, they contain battery
* information for NVSIMMs. These need to be updated whenever a
* kstat_read asks for the data. There is currently no plan to
* ship NVSIMMs on this platform, but this support must be present.
*/
static int
{
struct simmstat_soft_state *softsp;
volatile char *statp; /* pointer to hardware register */
char *kstatp; /* pointer to kstat data buffer */
int i;
/* this is a read-only kstat. Bail out on a write */
if (rw == KSTAT_WRITE) {
return (EACCES);
} else {
/*
* copy current status of hardware into the kstat
* structure.
*/
}
}
return (0);
}