/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/ddi_impldefs.h>
#include <sys/sysmacros.h>
void **result);
ioat_open, /* cb_open */
ioat_close, /* cb_close */
nodev, /* cb_strategy */
nodev, /* cb_print */
nodev, /* cb_dump */
nodev, /* cb_read */
nodev, /* cb_write */
ioat_ioctl, /* cb_ioctl */
nodev, /* cb_devmap */
nodev, /* cb_mmap */
nodev, /* cb_segmap */
nochpoll, /* cb_chpoll */
ddi_prop_op, /* cb_prop_op */
NULL, /* cb_stream */
};
DEVO_REV, /* devo_rev */
0, /* devo_refcnt */
ioat_getinfo, /* devo_getinfo */
nulldev, /* devo_identify */
nulldev, /* devo_probe */
ioat_attach, /* devo_attach */
ioat_detach, /* devo_detach */
nodev, /* devo_reset */
&ioat_cb_ops, /* devo_cb_ops */
NULL, /* devo_bus_ops */
NULL, /* devo_power */
ioat_quiesce, /* devo_quiesce */
};
&mod_driverops, /* Type of module. This one is a driver */
"ioat driver", /* Name of the module. */
&ioat_dev_ops, /* driver ops */
};
(void *) &ioat_modldrv,
};
void *ioat_statep;
DDI_DEVICE_ATTR_V0, /* devacc_attr_version */
DDI_NEVERSWAP_ACC, /* devacc_attr_endian_flags */
DDI_STORECACHING_OK_ACC, /* devacc_attr_dataorder */
DDI_DEFAULT_ACC /* devacc_attr_access */
};
/* dcopy callback interface */
0, /* reserved */
};
/*
* _init()
*/
int
_init(void)
{
int e;
if (e != 0) {
return (e);
}
e = mod_install(&ioat_modlinkage);
if (e != 0) {
return (e);
}
return (0);
}
/*
* _info()
*/
int
{
}
/*
* _fini()
*/
int
_fini(void)
{
int e;
e = mod_remove(&ioat_modlinkage);
if (e != 0) {
return (e);
}
return (0);
}
/*
* ioat_attach()
*/
static int
{
int instance;
int e;
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_FAILURE);
}
e = ioat_channel_resume(state);
if (e != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
if (e != DDI_SUCCESS) {
return (DDI_FAILURE);
}
}
/* setup the registers, save away some device info */
e = ioat_chip_init(state);
if (e != DDI_SUCCESS) {
goto attachfail_chip_init;
}
/* initialize driver state, must be after chip init */
e = ioat_drv_init(state);
if (e != DDI_SUCCESS) {
goto attachfail_drv_init;
}
/* create the minor node (for the ioctl) */
0);
if (e != DDI_SUCCESS) {
goto attachfail_minor_node;
}
/* Enable device interrupts */
/* Report that driver was loaded */
/* register with dcopy */
if (e != DCOPY_SUCCESS) {
goto attachfail_register;
}
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
/*
* ioat_detach()
*/
static int
{
int instance;
int e;
return (DDI_FAILURE);
}
switch (cmd) {
case DDI_DETACH:
break;
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
/*
* try to unregister from dcopy. Since this driver doesn't follow the
* detach yet.
*/
if (e != DCOPY_SUCCESS) {
if (e == DCOPY_PENDING) {
" detach\n");
}
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* ioat_getinfo()
*/
/*ARGSUSED*/
static int
{
int instance;
int e;
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
return (DDI_FAILURE);
}
e = DDI_SUCCESS;
break;
case DDI_INFO_DEVT2INSTANCE:
e = DDI_SUCCESS;
break;
default:
e = DDI_FAILURE;
break;
}
return (e);
}
/*
* ioat_open()
*/
/*ARGSUSED*/
static int
{
int instance;
return (ENXIO);
}
return (0);
}
/*
* ioat_close()
*/
/*ARGSUSED*/
static int
{
return (0);
}
/*
* ioat_chip_init()
*/
static int
{
int e;
if (e != DDI_SUCCESS) {
goto chipinitfail_regsmap;
}
/* save away ioat chip info */
/*
* If we get a bogus value, something is wrong with the H/W, fail to
* attach.
*/
if (state->is_num_channels == 0) {
goto chipinitfail_numchan;
}
} else {
goto chipinitfail_version;
}
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
/*
* ioat_chip_fini()
*/
static void
{
}
/*
* ioat_drv_init()
*/
static int
{
int e;
if (e != DDI_SUCCESS) {
goto drvinitfail_config_setup;
}
/* read in Vendor ID */
/* read in Device ID */
/* Add in chipset version */
if (e != 0) {
goto drvinitfail_hilevel;
}
/* we don't support MSIs for v2 yet */
if (e != DDI_SUCCESS) {
goto drvinitfail_add_intr;
}
if (e != DDI_SUCCESS) {
}
e = ioat_channel_init(state);
if (e != DDI_SUCCESS) {
goto drvinitfail_channel_init;
}
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
/*
* ioat_drv_fini()
*/
static void
{
}
/*
* ioat_unregister_complete()
*/
void
{
if (status != DCOPY_SUCCESS) {
return;
}
}
/*
* ioat_detach_finish()
*/
void
{
}
/*
* ioat_intr_enable()
*/
static void
{
/* Clear any pending interrupts */
if (intr_status != 0) {
}
/* Enable interrupts on the device */
}
/*
* ioat_intr_disable()
*/
static void
{
/*
* disable interrupts on the device. A read of the interrupt control
* register clears the enable bit.
*/
}
/*
* ioat_isr()
*/
static uint_t
{
uint_t r;
int i;
/* master interrupt enable should always be set */
/* If the interrupt status bit isn't set, it's not ours */
if (!(intrctrl & IOAT_INTRCTL_INTR_STAT)) {
/* re-set master interrupt enable (since it clears on read) */
return (DDI_INTR_UNCLAIMED);
}
/* see which channels generated the interrupt */
/* call the intr handler for the channels */
r = DDI_INTR_UNCLAIMED;
chan = 1;
for (i = 0; i < state->is_num_channels; i++) {
if (intr_status & chan) {
r = DDI_INTR_CLAIMED;
}
}
/*
* if interrupt status bit was set, there should have been an
* attention status bit set too.
*/
ASSERT(r == DDI_INTR_CLAIMED);
/* re-set master interrupt enable (since it clears on read) */
intrctrl);
return (r);
}
static int
{
int instance;
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}