fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SCM_
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/ksynch.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/cmn_err.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/modctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/conf.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/file.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/kmem.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/cred.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/ddi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsc_thread.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sd_bcache.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sd_misc.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sd_trace.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sd_ft.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sd_io.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sd_bio.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sd_pcu.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sd_tdaemon.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sdbc_ioctl.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/ncall/ncall.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/nsctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/nsvers.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sdt.h> /* dtrace is S10 or later */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s_k.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_errors.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic dev_info_t *dev_dip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedev_info_t *sdbc_get_dip();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A global variable to set the threshold for large writes to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be in write through mode when NVRAM is present. This should
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * solve the NVRAM bandwidth problem.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint sdbc_wrthru_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_size_t sdbc_max_fbas = _SD_MAX_FBAS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint sdbc_max_devs = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortekrwlock_t sdbc_queue_lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _sd_debug_level = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic kmutex_t _sd_block_lk;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define REGISTER_SVC(X, Y) (ncall_register_svc(X, Y))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define UNREGISTER_SVC(X) (ncall_unregister_svc(X))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int sdbc_major_rev = ISS_VERSION_MAJ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int sdbc_minor_rev = ISS_VERSION_MIN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int sdbc_micro_rev = ISS_VERSION_MIC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int sdbc_baseline_rev = ISS_VERSION_NUM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char sdbc_version[16];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _sdbc_attached = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _sdbc_print(dev_t dev, char *s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sdbcunload(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sdbcload(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sdbcopen(dev_t *devp, int flag, int otyp, cred_t *crp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sdbcclose(dev_t dev, int flag, int otyp, cred_t *crp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sdbcioctl(dev_t dev, int cmd, void *arg, int mode, cred_t *crp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _sdbc_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _sdbc_probe(dev_info_t *dip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _sdbc_attach(dev_info_t *, ddi_attach_cmd_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _sdbc_detach(dev_info_t *, ddi_detach_cmd_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _sdbc_reset(dev_info_t *, ddi_reset_cmd_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef sun
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Solaris specific driver module interface code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef USES_SOFT_STATE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct sdbc_state {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_info_t *dip; /* everyone would need a devinfo */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void *sdbc_statep; /* for soft state routines */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USES_SOFT_STATE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct cb_ops sdbc_cb_ops = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbcopen, /* open */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbcclose, /* close */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* not a block driver, strategy not an entry point */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_print, /* no print routine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* no dump routine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* read */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* write */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (int (*) ()) sdbcioctl, /* ioctl */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* no devmap routine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* no mmap routine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* no segmap routine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nochpoll, /* no chpoll routine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_prop_op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* not a STREAMS driver, no cb_str routine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte D_NEW | D_MP, /* safe for multi-thread/multi-processor */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct dev_ops sdbc_ops = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEVO_REV, /* Driver build version */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* device reference count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_getinfo,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nulldev,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_probe,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_attach,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_detach,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_reset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &sdbc_cb_ops,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (struct bus_ops *)NULL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct modldrv sdbc_ldrv = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &mod_driverops,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "nws:Storage Cache:" ISS_VERSION_STR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &sdbc_ops
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct modlinkage sdbc_modlinkage = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MODREV_1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &sdbc_ldrv,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dynmem interface
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int mutex_and_condvar_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Solaris module load time code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_init(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int err;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_and_condvar_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef USES_SOFT_STATE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_soft_state_init(&sdbc_statep, sizeof (struct sdbc_state),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_INSTANCES);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USES_SOFT_STATE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It is "load" time, call the unixware equivalent.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = sdbcload();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!err)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = mod_install(&sdbc_modlinkage);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sdbcunload();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef USES_SOFT_STATE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_soft_state_fini(&sdbc_statep);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USES_SOFT_STATE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!err) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_and_condvar_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&dynmem_processing_dm.thread_dm_lock, "dynmem",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_init(&dynmem_processing_dm.thread_dm_cv, "dynmem",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CV_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Solaris module unload time code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_fini(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int err;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EBUSY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (_sd_ioset &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_sd_ioset->set_nlive || _sd_ioset->set_nthread)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!sdbc:_fini() %d threads still "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "active; %d threads in set\n", _sd_ioset->set_nlive,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_ioset->set_nthread);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EBUSY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = mod_remove(&sdbc_modlinkage)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE2(_sdbc_fini_mod_remove_succeeded,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int, err,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct modlinkage *, &sdbc_modlinkage);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = sdbcunload();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef USES_SOFT_STATE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_soft_state_fini(&sdbc_statep);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USES_SOFT_STATE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mutex_and_condvar_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_destroy(&dynmem_processing_dm.thread_dm_cv);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_destroy(&dynmem_processing_dm.thread_dm_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_and_condvar_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Solaris module info code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_info(struct modinfo *modinfop)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (mod_info(&sdbc_modlinkage, modinfop));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sdbc_probe(dev_info_t *dip)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_PROBE_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Attach an instance of the device. This happens before an open
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * can succeed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sdbc_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _dm_process_vars_t local_dm_process_vars;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct buf bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd != DDI_ATTACH)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_FAILURE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the threshold value for setting large writes in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * write through mode(when NVRAM is present)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_wrthru_len = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_wrthru_thresh", 64);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get sdbc_max_fbas from sdbc.conf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_max_fbas = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_max_fbas",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _SD_MAX_FBAS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bp.b_bcount = (size_t)FBA_SIZE(sdbc_max_fbas);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte minphys(&bp); /* clamps value to maxphys */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_max_fbas = FBA_NUM(bp.b_bcount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sdbc_max_fbas > _SD_MAX_FBAS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!_sdbc_attach: sdbc_max_fbas set to %d", _SD_MAX_FBAS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_max_fbas = _SD_MAX_FBAS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -get the maximum list length for multipage dynmem
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -time between aging
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -number of agings before dealloc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -what to report D0=shutdown, D1=thread variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.max_dyn_list = MAX_DYN_LIST_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.monitor_dynmem_process =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MONITOR_DYNMEM_PROCESS_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_ct1 = CACHE_AGING_CT_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_ct2 = CACHE_AGING_CT_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_ct3 = CACHE_AGING_CT_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_sec1 = CACHE_AGING_SEC1_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_sec2 = CACHE_AGING_SEC2_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_sec3 = CACHE_AGING_SEC3_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_pcnt1 = CACHE_AGING_PCNT1_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_pcnt2 = CACHE_AGING_PCNT2_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.max_holds_pcnt = MAX_HOLDS_PCNT_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.process_directive = PROCESS_DIRECTIVE_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.max_dyn_list = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_max_dyn_list",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_DYN_LIST_DEFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.monitor_dynmem_process =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_prop_get_int(DDI_DEV_T_ANY, dip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_monitor_dynmem",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MONITOR_DYNMEM_PROCESS_DEFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_ct1 = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_ct1",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_AGING_CT_DEFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_ct2 = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_ct2",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_AGING_CT_DEFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_ct3 = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_ct3",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_AGING_CT_DEFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_sec1 = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_sec1",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_AGING_SEC1_DEFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_sec2 = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_sec2",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_AGING_SEC2_DEFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_sec3 = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_sec3",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_AGING_SEC3_DEFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_pcnt1 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_prop_get_int(DDI_DEV_T_ANY, dip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_pcnt1",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_AGING_PCNT1_DEFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_pcnt2 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_prop_get_int(DDI_DEV_T_ANY, dip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_pcnt2",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_AGING_PCNT2_DEFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.process_directive =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_prop_get_int(DDI_DEV_T_ANY, dip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_process_directive",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PROCESS_DIRECTIVE_DEFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.max_holds_pcnt = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_max_holds_pcnt",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_HOLDS_PCNT_DEFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sdbc_edit_xfer_process_vars_dm(&local_dm_process_vars);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MINOR_NAME "c,sdbc" /* character device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MINOR_NUMBER 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef MINOR_NAME
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_create_minor_node(dip, MINOR_NAME, S_IFCHR,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana MINOR_NUMBER, DDI_PSEUDO, 0) != DDI_SUCCESS) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana /* free anything we allocated here */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana return (DDI_FAILURE);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MINOR_NAME */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Announce presence of the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_report_dev(dip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_dip = dip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mark the device as attached, opens may proceed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_attached = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_init(&sdbc_queue_lock, NULL, RW_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sdbc_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd == DDI_DETACH) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check first if the cache is still in use
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and if it is, prevent the detach.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EBUSY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_attached = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_destroy(&sdbc_queue_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_dip = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_FAILURE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sdbc_reset(dev_info_t *dip, ddi_reset_cmd_t cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sdbc_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_t dev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef USES_SOFT_STATE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sdbc_state *xsp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USES_SOFT_STATE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (cmd) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DDI_INFO_DEVT2INSTANCE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev = (dev_t)arg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The "instance" number is the minor number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *result = (void *)(unsigned long)getminor(dev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = DDI_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DDI_INFO_DEVT2DEVINFO:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev = (dev_t)arg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef USES_SOFT_STATE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the instance number is the minor number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte instance = getminor(dev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xsp = ddi_get_soft_state(sdbc_statep, instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xsp == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_FAILURE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *result = (void *) xsp->dip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *result = (void *) NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USES_SOFT_STATE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = DDI_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = DDI_FAILURE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sdbc_print(dev_t dev, char *s)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!sdbc(_sdbc_print) %s", s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMOD_DRV_WRAPPER(sdbc, sdbcload, sdbcunload, NULL, "Storage Device Block Cache");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* sun */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sdbc_inited;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbcinit(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_inited = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(sdbc_version, _VERSION_, sizeof (sdbc_version));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&_sd_cache_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&_sdbc_config_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef m88k
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_DUAL_WRITE, r_sd_ifs_write);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_DUAL_READ, r_sd_ifs_read);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_SET_CD, r_sd_set_cd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_GETSIZE, r_sd_getsize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_DUAL_OPEN, r_sd_ifs_open);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_REMOTE_FLUSH, r_sd_remote_flush);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_SGREMOTE_FLUSH, r_sd_sgremote_flush);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_DISK_IO, r_sd_disk_io);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_GET_BMAP, r_rem_get_bmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = hpf_register_module("SDBC", _sd_hpf_stats)) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_ENABLE, r_sd_ifs_cache_enable);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_DISABLE, r_sd_ifs_cache_disable);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_CD_DISCARD, r_cd_discard);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_init(&_sd_flush_cv, NULL, CV_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&_sd_block_lk, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_max_devs = nsc_max_devices();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialize the bitmap array that would be useful in determining
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if the mask is not fragmented, instead of determinig this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * at run time. Also initialize a lookup array for each mask, with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the starting position, the length, and the mask subset
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_init_contig_bmap();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_init_lookup_map();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = _sdbc_iobuf_load()) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = _sdbc_handles_load()) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = _sdbc_tr_load()) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = _sdbc_ft_load()) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = _sdbc_tdaemon_load()) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = _sdbc_hash_load()) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_ioj_load();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_inited = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbcunload(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(sdbcunload) cannot unload module - cache in use!");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EEXIST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef m88k
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNREGISTER_SVC(SD_DUAL_WRITE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNREGISTER_SVC(SD_DUAL_READ);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNREGISTER_SVC(SD_SET_CD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNREGISTER_SVC(SD_GETSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNREGISTER_SVC(SD_DUAL_OPEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNREGISTER_SVC(SD_REMOTE_FLUSH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNREGISTER_SVC(SD_SGREMOTE_FLUSH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNREGISTER_SVC(SD_DISK_IO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNREGISTER_SVC(SD_GET_BMAP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) hpf_unregister_module("SDBC");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNREGISTER_SVC(SD_ENABLE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNREGISTER_SVC(SD_DISABLE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UNREGISTER_SVC(SD_CD_DISCARD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_destroy(&_sd_flush_cv);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_destroy(&_sd_block_lk);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_hash_unload();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_ft_unload();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_tr_unload();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_tdaemon_unload();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_handles_unload();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_iobuf_unload();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_ioj_unload();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_destroy(&_sd_cache_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_destroy(&_sdbc_config_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Normally we would unregister memory at deconfig time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * However when chasing things like memory leaks it is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * useful to defer until unload time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sdbc_memtype_deconfigure_delayed)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_memtype_deconfigure();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbcload(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int err;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = sdbcinit()) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sdbcunload();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbcopen(dev_t *devp, int flag, int otyp, cred_t *crp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int nd = nsc_node_id();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we were statically linked in then returning an error out
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of sdbcinit won't prevent someone from coming thru here.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We must prevent them from getting any further.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!sdbc_inited)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EINVAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nd < nsc_min_nodeid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(sdbcopen) open failed, systemid (%d) must be >= %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nd, nsc_min_nodeid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EINVAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!_sdbc_attached)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ENXIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbcclose(dev_t dev, int flag, int otyp, cred_t *crp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _MULTI_DATAMODEL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconvert_ioctl_args(int cmd, void *arg, int mode, _sdbc_ioctl_t *args)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert_ioctl-args - Do a case by case conversion of a ILP32 ioctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * structure to an LP64 structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The main concern here is whether to sign-extend or not. The rule
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is that pointers are not sign extended, the rest are obvious.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Since most everything is sign-extended the definition of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _sdbc_ioctl32_t uses signed fields.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_ioctl32_t args32;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin(arg, &args32, sizeof (_sdbc_ioctl32_t), mode))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *) args, sizeof (_sdbc_ioctl_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (cmd) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_UNUSED_1:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_UNUSED_2:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_UNUSED_3:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(convert_ioctl_args) obsolete sdbc ioctl used");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EINVAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_ADUMP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = args32.arg0; /* cd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg1 = (uint32_t)args32.arg1; /* &tt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg2 = (uint32_t)args32.arg2; /* NULL (buf) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg3 = args32.arg3; /* size of buf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg4 = args32.arg4; /* flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_TEST_INIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* fname (char *) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg1 = args32.arg1; /* index */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg2 = args32.arg2; /* len */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg3 = args32.arg3; /* track size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg4 = args32.arg4; /* flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_TEST_START:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = args32.arg0; /* num */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg1 = args32.arg1; /* type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg2 = args32.arg2; /* loops */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg3 = args32.arg3; /* from */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg4 = args32.arg4; /* seed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_TEST_END:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_ENABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_VERSION:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* pointer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_DISABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_CLUSTER_SIZE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* (int * ) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the gl_file data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_CLUSTER_DATA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pointer to array[2*cluster_size] */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the size of the global info pages for each board */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_GLMUL_SIZES:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* int[CACHE_MEM_PAD] * */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the global info about write blocks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_GLMUL_INFO:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pointer to array[2*(sum of GLMUL_SIZES)] */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_SET_CD_HINT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = args32.arg0; /* cd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg1 = args32.arg1; /* hint */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg2 = args32.arg2; /* flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_CD_HINT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = args32.arg0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_SET_NODE_HINT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = args32.arg0; /* hint */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg1 = args32.arg1; /* flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_NODE_HINT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_STATS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* (_sd_stats_t *) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_ZAP_STATS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_CD_BLK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = args32.arg0; /* cd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg1 = (uint32_t)args32.arg1; /* blk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg2 = (uint32_t)args32.arg2; /* (addr[5] *) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_CONFIG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* (_sdbc_config_t *) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_SET_CONFIG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* (_sdbc_config_t *) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_MAXFILES:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* (int * ) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* toggle flusher flag for testing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_TOGGLE_FLUSH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_INJ_IOERR: /* cd, errnum */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = args32.arg0; /* cd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg1 = args32.arg1; /* i/o error number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg2 = args32.arg2; /* countdown to issuing error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear injected i/o errors */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_CLR_IOERR: /* cd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = args32.arg0; /* cd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DEBUG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EINVAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _MULTI_DATAMODEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_get_cd_blk(_sdbc_ioctl_t *args, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cctl_t *cc_ent;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *taddr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte intptr_t addr[5];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _MULTI_DATAMODEL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t addr_32[5];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _MULTI_DATAMODEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *lookup_file = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_info_t info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t fba_pos; /* disk block number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EINVAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copyin the block number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)args->arg1, &fba_pos, sizeof (nsc_off_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _MULTI_DATAMODEL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_model_convert_from(mode & FMODELS) == DDI_MODEL_ILP32) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)args->arg2, addr_32, sizeof (addr_32),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr[0] = addr_32[0]; /* (sdbc_info_t *) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr[1] = addr_32[1]; /* (char *) cdata */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr[2] = addr_32[2]; /* ( int * ) cblk_size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr[3] = addr_32[3]; /* ( char * ) filename */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr[4] = addr_32[4]; /* ( char *) wdata */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)args->arg2, addr, sizeof (addr), mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* _MULTI_DATAMODEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)args->arg2, addr, sizeof (addr), mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _MULTI_DATAMODEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) copyout(&CACHE_BLOCK_SIZE, (void *)addr[2], sizeof (int));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_get_cd_blk((int)args->arg0, FBA_TO_BLK_NUM(fba_pos),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &cc_ent, &data, &lookup_file)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lookup_file != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) copyout(lookup_file, (void *)addr[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ENOENT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte taddr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte info.ci_write = cc_ent->cc_write ? 1 : 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte info.ci_dirty = cc_ent->cc_dirty;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte info.ci_valid = cc_ent->cc_valid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte info.ci_cd = CENTRY_CD(cc_ent);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte info.ci_dblk = BLK_TO_FBA_NUM(CENTRY_BLK(cc_ent));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) copyout(lookup_file, (void *)addr[3], NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) copyout(&info, (void *)addr[0], sizeof (sdbc_info_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) copyout(data, (void *)addr[1], CACHE_BLOCK_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the write data if any */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cc_ent->cc_write) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sdbc_safestore) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(sdbc_get_cd_blk) cc_write 0x%p sc-res 0x%p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)cc_ent->cc_write,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)cc_ent->cc_write->sc_res);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((taddr = kmem_alloc(CACHE_BLOCK_SIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KM_NOSLEEP)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(sdbc_get_cd_blk) kmem_alloc failed."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " cannot get write data");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte info.ci_write = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = EFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (SSOP_READ_CBLOCK(sdbc_safestore,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cc_ent->cc_write->sc_res, taddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_BLOCK_SIZE, 0) == SS_ERR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN, "sdbc(sdbc_get_cd_blk) "
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!safestore read failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = EFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (copyout(taddr, (void *)addr[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_BLOCK_SIZE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(sdbc_get_cd_blk) copyout failed."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " cannot get write data");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = EFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (taddr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(taddr, CACHE_BLOCK_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbcioctl(dev_t dev, int cmd, void *arg, int mode, cred_t *crp, int *rvp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_ioctl_t args;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int convert_32 = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t kstatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rvp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _MULTI_DATAMODEL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_model_convert_from(mode & FMODELS) == DDI_MODEL_ILP32) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte convert_32 = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = convert_ioctl_args(cmd, arg, mode, &args)) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin(arg, &args, sizeof (_sdbc_ioctl_t), mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* _MULTI_DATAMODEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin(arg, &args, sizeof (_sdbc_ioctl_t), mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _MULTI_DATAMODEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstatus = spcs_s_kcreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!kstatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ENOMEM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (cmd) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_UNUSED_1:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_UNUSED_2:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_UNUSED_3:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SDBC_EOBSOLETE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_ADUMP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sd_adump(&args, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_TEST_INIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sd_test_init(&args);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_TEST_START:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sd_test_start(&args, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_TEST_END:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sd_test_end();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_ENABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_sdbc_config_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sdbc_configure((_sd_cache_param_t *)args.arg0,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana NULL, kstatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc && rc != EALREADY && rc != SDBC_ENONETMEM) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) _sdbc_deconfigure(kstatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_sdbc_config_lock);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana return (spcs_s_ocopyoutf
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana (&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_sdbc_config_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_DISABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_sdbc_config_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_sdbc_config_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SDBC_EDISABLE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sdbc_deconfigure(kstatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_sdbc_config_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_CLUSTER_SIZE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SDBC_ECLUSTER_SIZE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = sd_get_file_info_size((void *)args.arg0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the gl_file data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_CLUSTER_DATA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SDBC_ECLUSTER_DATA));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = sd_get_file_info_data((void *)args.arg0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the size of the global info pages for each board */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_GLMUL_SIZES:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SDBC_EGLMUL_SIZE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = sd_get_glmul_sizes((void *)args.arg0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the global info about write blocks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_GLMUL_INFO:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SDBC_EGLMUL_INFO));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = sd_get_glmul_info((void *)args.arg0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_SET_CD_HINT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args.sdbc_ustatus, EINVAL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = ((args.arg2) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_set_hint((int)args.arg0, (uint_t)args.arg1) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_clear_hint((int)args.arg0, (uint_t)args.arg1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_CD_HINT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t hint;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args.sdbc_ustatus, EINVAL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = _sd_get_cd_hint((int)args.arg0, &hint)) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rvp = hint;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_SET_NODE_HINT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = ((args.arg1) ? _sd_set_node_hint((uint_t)args.arg0) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_clear_node_hint((uint_t)args.arg0));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* FALLTHRU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_NODE_HINT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t hint;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = _sd_get_node_hint(&hint)) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rvp = hint;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_STATS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sd_get_stats((void *)args.arg0, convert_32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_ZAP_STATS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_zap_stats();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, 0));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_CD_BLK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args.sdbc_ustatus, EINVAL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = sdbc_get_cd_blk(&args, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_GET_CONFIG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_config_t sdbc_config_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)args.arg0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &sdbc_config_info,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (_sdbc_config_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_kfree(kstatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sdbc_get_config(&sdbc_config_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_copyout(&sdbc_config_info,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)args.arg0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (_sdbc_config_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_SET_CONFIG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_config_t mgmt_config_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)args.arg0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &mgmt_config_info,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (_sdbc_config_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_kfree(kstatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sdbc_configure(NULL, &mgmt_config_info, kstatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc && rc != EALREADY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) _sdbc_deconfigure(kstatus);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana return (spcs_s_ocopyoutf
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana (&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_MAXFILES:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (copyout(&sdbc_max_devs, (void *)args.arg0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (sdbc_max_devs)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = EFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_VERSION:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cache_version_t cache_version;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cache_version.major = sdbc_major_rev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cache_version.minor = sdbc_minor_rev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cache_version.micro = sdbc_micro_rev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cache_version.baseline = sdbc_baseline_rev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout(&cache_version, (void *)args.arg0,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana sizeof (cache_version_t), mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = EFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* toggle flusher flag for testing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_TOGGLE_FLUSH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdbc_flush_flag ^= 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rvp = _sdbc_flush_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SDBC_ETOGGLE_FLUSH, _sdbc_flush_flag ? "on" : "off"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* inject i/o errors */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_INJ_IOERR: /* cd, errnum */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args.sdbc_ustatus, EINVAL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sdbc_inject_ioerr(args.arg0, args.arg1, args.arg2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear injected i/o errors */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SDBC_CLR_IOERR: /* cd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_initialized == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args.sdbc_ustatus, EINVAL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sdbc_clear_ioerr(args.arg0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DEBUG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana _sd_print(3, "!SDBC unknown ioctl: 0x%x unsupported", cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = EINVAL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_kfree(kstatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _sd_timed_block - sleep waiting for ticks time delay.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ticks - # of ticks to sleep
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cvp - pointer to the cv we wait on while we delay.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NO spin locks can be held at entry!
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sd_timed_block(clock_t ticks, kcondvar_t *cvp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_sd_block_lk);
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni (void) cv_reltimedwait(cvp, &_sd_block_lk, ticks, TR_CLOCK_TICK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_sd_block_lk);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _sd_unblock - awake a sleeper waiting on cv pointed to by cvp.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NO spin locks can be held at entry as we may sleep.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sd_unblock(kcondvar_t *cvp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_sd_block_lk);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_broadcast(cvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_sd_block_lk);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sd_data_log(int num, _sd_cctl_t *centry, nsc_off_t st, nsc_size_t len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if defined(_SD_FBA_DATA_LOG)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_size_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t blk;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte blk = BLK_TO_FBA_NUM(CENTRY_BLK(centry));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = st; i < (st + len); i++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SDTRACE(num, CENTRY_CD(centry), 1, blk + i,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana *(int *)(centry->cc_data + FBA_SIZE(i)),
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana *(int *)(centry->cc_data + FBA_SIZE(i) + 4));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SD_FBA_DATA_LOG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sd_data_log_chain(int num, _sd_cctl_t *centry, nsc_off_t fba_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_size_t fba_len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if defined(_SD_FBA_DATA_LOG)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_cblk_fba_t st_cblk_len; /* FBA len of starting cache block */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_cblk_fba_t end_cblk_len; /* FBA len of ending cache block */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_cblk_fba_t st_cblk_off; /* FBA offset into starting cblock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (CENTRY_BLK(centry) != FBA_TO_BLK_NUM(fba_pos))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte centry = centry->cc_chain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st_cblk_off = BLK_FBA_OFF(fba_pos);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st_cblk_len = BLK_FBAS - st_cblk_off;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (st_cblk_len >= fba_len) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte end_cblk_len = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st_cblk_len = fba_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte end_cblk_len = BLK_FBA_OFF(fba_pos + fba_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DATA_LOG(num, centry, st_cblk_off, st_cblk_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fba_len -= st_cblk_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte centry = centry->cc_chain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (fba_len > end_cblk_len) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DATA_LOG(num, centry, 0, BLK_FBAS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fba_len -= BLK_FBAS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte centry = centry->cc_chain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (end_cblk_len) DATA_LOG(num, centry, 0, end_cblk_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SD_FBA_DATA_LOG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sd_zap_stats(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_cache_stats == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_rdhits = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_rdmiss = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_wrhits = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_wrmiss = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_lru_q.sq_noreq_stat = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_lru_q.sq_req_stat = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < sdbc_max_devs; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_shared[i].sh_cache_read = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_shared[i].sh_cache_write = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_shared[i].sh_disk_read = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_shared[i].sh_disk_write = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return the cache sizes used by the Sense Subsystem Status CCW
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sd_cache_sizes(int *asize, int *wsize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int psize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *asize = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *wsize = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add in the total cache size and the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-volatile (battery-backed) cache size.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_net_config.sn_configured) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte psize = _sd_net_config.sn_psize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *asize += (_sd_net_config.sn_cpages * psize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *wsize += (safestore_config.ssc_wsize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*PRINTFLIKE2*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sd_print(int level, char *fmt, ...)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte va_list adx;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (level <= _sd_debug_level) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte va_start(adx, fmt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vcmn_err(CE_NOTE, fmt, adx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte va_end(adx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sd_get_cd_blk(int cd, nsc_off_t cblk, _sd_cctl_t **cc, caddr_t *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char **filename)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cctl_t *cc_ent;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (FILE_OPENED(cd) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *filename = _sd_cache_files[cd].cd_info->sh_filename;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cc_ent = (_sd_cctl_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_hash_search(cd, cblk, _sd_htable)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *cc = cc_ent;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *data = (caddr_t)cc_ent->cc_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * central dyn mem processing vars edit rtn.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * input a local copy and xfer to global
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sec0,sec1,sec2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * range check 1 to 255 (arbitrary but in any case must be <= 2000 due to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 32bit signed int limits in later calc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * aging_ct
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * range check 1 to 255 (only 8 bits reserved for aging ctr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_edit_xfer_process_vars_dm(_dm_process_vars_t *process_vars)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (process_vars->max_dyn_list > 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.max_dyn_list = process_vars->max_dyn_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no edit on monitor_dynmem_process */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.monitor_dynmem_process =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->monitor_dynmem_process;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no edit on process_directive */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.process_directive =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->process_directive;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (process_vars->cache_aging_ct1 > 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_ct1 <= CACHE_AGING_CT_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_ct1 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_ct1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (process_vars->cache_aging_ct2 > 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_ct2 <= CACHE_AGING_CT_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_ct2 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_ct2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (process_vars->cache_aging_ct3 > 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_ct3 <= CACHE_AGING_CT_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_ct3 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_ct3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (process_vars->cache_aging_sec1 > 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_sec1 <= CACHE_AGING_SEC1_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_sec1 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_sec1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (process_vars->cache_aging_sec2 > 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_sec2 <= CACHE_AGING_SEC2_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_sec2 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_sec2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (process_vars->cache_aging_sec3 > 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_sec3 <= CACHE_AGING_SEC3_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_sec3 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_sec3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (process_vars->cache_aging_pcnt1 >= 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_pcnt1 <= CACHE_AGING_PCNT1_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_pcnt1 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_pcnt1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (process_vars->cache_aging_pcnt2 >= 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_pcnt2 <= CACHE_AGING_PCNT2_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_pcnt2 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_pcnt2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (process_vars->max_holds_pcnt >= 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->max_holds_pcnt <= MAX_HOLDS_PCNT_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.max_holds_pcnt =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->max_holds_pcnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedev_info_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_get_dip()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (dev_dip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}