/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2011 Bayard G. Bell. All rights reserved.
*/
#include <sys/ddi_impldefs.h>
#include <sys/sysmacros.h>
#include <sys/autoconf.h>
/* Useful debugging Stuff */
#include <sys/nexusdebug.h>
/*
* Function protoypes
*/
static void sram_add_kstats(struct sram_soft_state *);
/*
* Configuration data structures
*/
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 */
};
DEVO_REV, /* rev */
0, /* refcnt */
ddi_no_info, /* getinfo */
nulldev, /* identify */
nulldev, /* probe */
sram_attach, /* attach */
sram_detach, /* detach */
nulldev, /* reset */
&sram_cb_ops, /* cb_ops */
(struct bus_ops *)0, /* bus_ops */
nulldev, /* power */
ddi_quiesce_not_needed, /* quiesce */
};
/*
* Driver globals
*/
static int reset_info_created = 0;
extern struct mod_ops mod_driverops;
&mod_driverops, /* Type of module. This one is a driver */
"Sram Leaf", /* name of module */
&sram_ops, /* driver ops */
};
(void *)&modldrv,
};
/*
* These are the module initialization routines.
*/
int
_init(void)
{
int error;
sizeof (struct sram_soft_state), 1)) == 0 &&
return (error);
}
int
_fini(void)
{
int error;
return (error);
}
int
{
}
static int
{
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 devices parent. */
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;
/* 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);
}
/*
* We do not remove the kstat here. There is only one instance for
* the whole machine, and it must remain in existence while the
* system is running.
*/
/* unmap the registers */
/* free the soft state structure */
return (DDI_SUCCESS);
}
/*
* The Reset-info structure passed up by POST has it's own kstat.
* It only needs to get created once. So the first sram instance
* that gets created will check for the OBP property 'reset-info'
* in the root node of the OBP device tree. If this property exists,
* then the reset-info kstat will get created. Otherwise it will
* not get created. This will inform users whether or not a fatal
* hardware reset has recently occurred.
*/
static void
{
int i;
union {
} rst_size;
/*
* only one reset_info kstat per system, so don't create it if
* it exists already.
*/
if (reset_info_created) {
return;
}
/* mark that this code has been run. */
reset_info_created = 1;
/* does the root node have a 'fatal-reset-info' property? */
return;
}
/* XXX - workaround for OBP bug */
/*
* First read size. In case FW has not word aligned structure,
* copy the unsigned int into a 4 byte union, then read it out as
* an inteeger.
*/
}
/*
* If the reset size is zero, then POST did not
* record any info.
*/
if ((uint_t)reset_size == 0) {
return;
}
/* Check for illegal size values. */
"reset_size: 0x%x",
return;
}
/* create the reset-info kstat */
if (resetinfo_ksp == NULL) {
return;
}
/*
* now copy the data into kstat. Don't use block
* copy, the local space sram does not support this.
*/
for (i = 0; i < reset_size; i++) {
}
}