mpd.hd.data_length = sizeof mpd.hd + sizeof mpd.bd + mpd.dp.rigid_geometry.pg_length;
mpd.hd.data_length = sizeof mpd.hd - sizeof mpd.hd.data_length + sizeof mpd.bd + sizeof mpd.dp.rigid_geometry;
aac_internal_cache_cmd(xs)	struct scsi_xfer *xs;{	struct scsi_link *link = xs->sc_link;	struct aac_softc *sc = link->adapter_softc;	struct scsi_inquiry_data inq;	struct scsi_sense_data sd;	struct {		struct scsi_mode_header hd;		struct scsi_blk_desc bd;		union scsi_disk_pages dp;	} mpd;	struct scsi_read_cap_data rcd;	u_int8_t target = link->target;	AAC_DPRINTF(AAC_D_CMD, ("aac_internal_cache_cmd "));	switch (xs->cmd->opcode) {	case TEST_UNIT_READY:	case START_STOP:#if 0	case VERIFY:#endif		AAC_DPRINTF(AAC_D_CMD, ("opc %d tgt %d ", xs->cmd->opcode,		    target));		break;	case REQUEST_SENSE:		AAC_DPRINTF(AAC_D_CMD, ("REQUEST SENSE tgt %d ", target));		bzero(&sd, sizeof sd);		sd.error_code = 0x70;		sd.segment = 0;		sd.flags = SKEY_NO_SENSE;		aac_enc32(sd.info, 0);		sd.extra_len = 0;		aac_copy_internal_data(xs, (u_int8_t *)&sd, sizeof sd);		break;	case INQUIRY:		AAC_DPRINTF(AAC_D_CMD, ("INQUIRY tgt %d devtype %x ", target,		    sc->sc_hdr[target].hd_devtype));		bzero(&inq, sizeof inq);		/* XXX How do we detect removable/CD-ROM devices?  */		inq.device = T_DIRECT;		inq.dev_qual2 = 0;		inq.version = 2;		inq.response_format = 2;		inq.additional_length = 32;		strlcpy(inq.vendor, "Adaptec", sizeof inq.vendor);		snprintf(inq.product, sizeof inq.product, "Container #%02d",		    target);		strlcpy(inq.revision, "   ", sizeof inq.revision);		aac_copy_internal_data(xs, (u_int8_t *)&inq, sizeof inq);		break;	case MODE_SENSE:		AAC_DPRINTF(AAC_D_CMD, ("MODE SENSE tgt %d ", target));		bzero(&mpd, sizeof mpd);		switch (((struct scsi_mode_sense *)xs->cmd)->page) {		case 4:			/* scsi_disk.h says this should be 0x16 */			mpd.dp.rigid_geometry.pg_length = 0x16;			mpd.hd.data_length = sizeof mpd.hd + sizeof mpd.bd +			    mpd.dp.rigid_geometry.pg_length;			mpd.hd.blk_desc_len = sizeof mpd.bd;			/* XXX */			mpd.hd.dev_spec = 0;			_lto3b(AAC_BLOCK_SIZE, mpd.bd.blklen);			mpd.dp.rigid_geometry.pg_code = 4;			_lto3b(sc->sc_hdr[target].hd_size /			    sc->sc_hdr[target].hd_heads /			    sc->sc_hdr[target].hd_secs,			    mpd.dp.rigid_geometry.ncyl);			mpd.dp.rigid_geometry.nheads =			    sc->sc_hdr[target].hd_heads;			aac_copy_internal_data(xs, (u_int8_t *)&mpd,			    sizeof mpd);			break;		default:			printf("%s: mode sense page %d not simulated\n",			    sc->sc_dev.dv_xname,			    ((struct scsi_mode_sense *)xs->cmd)->page);			xs->error = XS_DRIVER_STUFFUP;			return (0);		}		break;	case READ_CAPACITY:		AAC_DPRINTF(AAC_D_CMD, ("READ CAPACITY tgt %d ", target));		bzero(&rcd, sizeof rcd);		_lto4b(sc->sc_hdr[target].hd_size - 1, rcd.addr);		_lto4b(AAC_BLOCK_SIZE, rcd.length);		aac_copy_internal_data(xs, (u_int8_t *)&rcd, sizeof rcd);		break;	default:		printf("aac_internal_cache_cmd got bad opcode: %d\n",		    xs->cmd->opcode);		xs->error = XS_DRIVER_STUFFUP;		return (0);	}	xs->error = XS_NOERROR;	return (1);}