|
|
#include <sys/sdi.h> #include <sys/ddi.h>int prefixrm_dev(struct scsi_adr *sa);
The rm_dev( ) entry point is registered with SDI through the sdi_target_hotregister(D3sdi) function that is called from the rinit(D2sdi) entry point routine.
``SDI peripheral hot add/remove'' in HDK Technical Reference
#define DKINDEX(x) (x / DK_MAX_SLICE) #define DK_MAX_SLICE 512/* * int * sd01rm_dev() * the function to support hot removal of disk drives. * This will spin down the disk and remove it from its internal * structures, sd01_dp. * * returns SDI_RET_ERR or SDI_RET_OK * will fail if the device doesn't exist, is not owned by sd01, * is open. */ int sd01rm_dev(struct scsi_adr *sa) { struct sdi_edt *edtp; struct disk *dp; int index; int part;
ASSERT(sa); edtp = sdi_rxedt(sa->scsi_ctl, sa->scsi_bus, sa->scsi_target, sa->scsi_lun);
if ((edtp == NULL) || /* no device */ (edtp->curdrv == NULL) || /* no owner */ (edtp->curdrv->maj.b_maj != Sd01_bmajor)) /* not mine */ return SDI_RET_ERR;
dp = sd01_dp[DKINDEX(edtp->curdrv->maj.first_minor)];
/* Requested to remove a disk that doesn't exit, return error */ if (dp == NULL) return SDI_RET_ERR;
/* check if the disk is open */ if (sd01_dk_open(dp)) return SDI_RET_ERR; /* flush cache and spin down the disk */ sd01cmd(dp, SS_LOAD, 0, NULL, 0, 0, SCB_READ, FALSE);
sd01_dp[index]=NULL; sd01_dk_free(dp);
sdi_clrconfig(edtp->curdrv, SDI_REMOVE|SDI_DISCLAIM, NULL);
return SDI_RET_OK; }