⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scsi.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
			/*			 * end of if option table			*/			}			/*			 * no option table default old disks			*/			else{			    if( count < 0){				/* 				 * size is 4 byte header plus 8 byte block desc.				*/				sc->sz_modsns.alclen = 12; 			    }			    else {				/* 				 * hdr + blk + 1 (32 byte page)				*/				sc->sz_modsns.alclen = 					sizeof(struct sz_rzmodsns_dt);				sc->sz_modsns.pgcode = count & 0x3f;				sc->sz_modsns.pcf = (count >> 6) & 0x3;			    }			}			/* 			 * For special disk commands			 * Like format and reassigning bad blocks... done			 * thru a ioctl and all the data structs are set			 * up by the utility that....			 * don't mess with this.................the			 * utility knows best.. I hope.			*/			if(sc->sc_rzspecial[targid]) {			    msp = (struct mode_sel_sns_params *)					sc->sc_rzparams[targid];			    sc->sz_modsns.pgcode = msp->msp_pgcode;			    sc->sz_modsns.pcf = msp->msp_pgctrl;			    sc->sz_modsns.alclen = msp->msp_length;			}		    }		    break;		case SZ_INQ:			sc->sz_rqsns.alclen = SZ_INQ_MAXLEN;			break;		case SZ_REWIND:		case SZ_RBL:		case SZ_TUR:			break;		case SZ_RDCAP:			/* DISK: READ CAPACITY */			break;			/* All fields zero */		case SZ_WFM:			sc->sz_wfm.numoffmks2 = 0; /* max of 65536 file marks */			sc->sz_wfm.numoffmks1 = LTOB(count,1);			sc->sz_wfm.numoffmks0 = LTOB(count,0);			break;		case SZ_P_BSPACEF:			count = -count;		case SZ_P_FSPACEF:			cmd = SZ_SPACE;			sc->sz_space.code = 1;			sc->sz_space.count2 = LTOB(count,2);			sc->sz_space.count1 = LTOB(count,1);			sc->sz_space.count0 = LTOB(count,0);			break;		case SZ_P_BSPACER:			count = -count;		case SZ_P_FSPACER:			cmd = SZ_SPACE;			sc->sz_space.code = 0;			sc->sz_space.count2 = LTOB(count,2);			sc->sz_space.count1 = LTOB(count,1);			sc->sz_space.count0 = LTOB(count,0);			break;		case SZ_VFY:			sc->sz_vfy.fixed = 1;	/* only records */			sc->sz_vfy.bytcmp = 0;	/* CRC verify only */			sc->sz_vfy.verflen2 = LTOB(count,2);			sc->sz_vfy.verflen1 = LTOB(count,1);			sc->sz_vfy.verflen0 = LTOB(count,0);			break;		case SZ_ERASE:			sc->sz_erase.longbit = 0; /* don't erase to end							of tape */			break;		case SZ_P_LOAD:		    cmd = SZ_SSLU;		    sc->sz_load.load = 1;  /* load only for now */		    sc->sz_load.reten = 0; /* not used on MAYA    */		    break;		case SZ_P_UNLOAD:			cmd = SZ_SSLU;			sc->sz_load.load = 0;  /* unload only for now */			sc->sz_load.reten = 0; /* not used on MAYA    */			break;		case SZ_P_RETENSION:		    cmd = SZ_SSLU;		    sc->sz_load.load = 1;  /* make sure its loaded */		    sc->sz_load.reten = 1; /* retension tape qic unit */		    break;		case SZ_P_SSUNIT: /* DISK: start/stop unit (count=1 to start) */			cmd = SZ_SSLU;			sc->sz_load.load = (count & 1);			break;		case SZ_RECDIAG:			sc->sz_recdiag.aloclen1 = 0;			sc->sz_recdiag.aloclen0 = SZ_RECDIAG_LEN;			break;		case SZ_SNDDIAG:			return(SZ_RET_ERR);			break;		case SZ_MODSEL:		case SZ_P_CACHE:		    cmd = SZ_MODSEL;		    /* 		     * set these here  will be changed 		     * later if need be		    */		    sc->sz_modsel.pll = 12;		    sc->sz_modsel.rdeclen = 8;		    if (sc->sc_devtyp[targid] & SZ_TAPE) {	 		/*			 * Check to see if we have an option table			 * if we do use those values in the table to set			 * things up.......		   	*/			if( sdp->opt_tab != NULL ){			    /*			     * we have an option table use it.			     * must cast the pointer			    */			     todp = (struct tape_opt_tab *)sdp->opt_tab;			    /* 			     * lets see if the mode select parameter length 			     * is valid			     * We must build it by hand...........			    */			    if( todp->opt_flags & MSEL_PLL_VAL){				sc->sz_modsel.pll = todp->msel_pll;				if( todp->opt_flags & MSEL_BLKDL_VAL){				    sc->sz_modsel.rdeclen = todp->msel_blkdl;				}				if( todp->opt_flags & MSEL_VUL_VAL){				    sc->sz_modsel.vulen = todp->msel_vul;				}			    /* end of if MSEL_PLL_VAL */			    }			    else{				/* 				 * no sense in testing anything else				 * default to hdr and block ( 12 )				*/				sc->sz_modsel.pll = 12;				sc->sz_modsel.rdeclen = 8;				/* ERRLOG_MARK */				cprintf("scsi OPTTABLE off id = %X\n", targid);			    }			    /* 			     * get our density struct pointer...			    */			    ddp = &todp->tape_info[DENS_IDX( bp )];			    /* 			     * lets see if this density selection is valid..			    */			    if( ddp->tape_flags & DENS_VAL ){				/*				 * this is valid lets get our stuff				*/				sc->sz_modsel.density = 					(char)(SCSI_DENS_MASK & ddp->dens);								/*				 * must set our block size......				*/				sc->sz_modsel.reclen2 = LTOB(ddp->blk_size,2);				sc->sz_modsel.reclen1 = LTOB(ddp->blk_size,1);				sc->sz_modsel.reclen0 = LTOB(ddp->blk_size,0);			    }			    /*			     * well we have a option table but this density			     * struct is not valid.... We must do something			     * but is it QIC 9trk 8mm etc... 			    */			    else {				/* ERRLOG_MARK */				cprintf("scsi OPTTABLE off id = %X\n", targid);				/* default it */				sc->sz_modsel.density = 0;			        /*				 * since we zeroed the command struct before				 * we got here we don't have to set zero's				 * in the block size field				*/			    }			    /* 			     * check speed setting 			    */			    if( ddp->tape_flags & SPEED_VAL){				sc->sz_modsel.speed = 					(SCSI_SPEED_MASK & ddp->tape_speed);			    } 			    if( todp->opt_flags & BUF_MOD ){				sc->sz_modsel.bufmode =  sz_bp_bufmode;			    }			    /*			     * is this scsi 2 if so must set pf.			    */			    if( sdp->flags & SCSI_MODSEL_PF ){				sc->sz_modsel.pf = 1;			    }							/*			 * end of if option table for tapes			*/			}			/* 			 * default the tape settings backwards compat			*/			else { 			    sc->sz_modsel.bufmode = sz_bp_bufmode;			    sc->sz_modsel.rdeclen = 8;			    if ((sc->sc_devtyp[ targid ] == TZxx) ||					(sc->sc_devtyp[ targid ] == TZ05) ||					(sc->sc_devtyp[ targid ] == TLZ04)) {				if ((sdp->flags & SCSI_MODSEL_EXABYTE) &&						    (tz_exabyte_vu != -1)) {				    /* Do extended mode select for EXABYTE */				    sc->sz_modsel.pll = 16;				    /* see scsi_data.c for values */				    sc->sz_modsel.vulen = tz_exabyte_vu;				    sc->sz_modsel.pad[0] = tz_exabyte_mt;				    sc->sz_modsel.pad[1] = tz_exabyte_rt;			        }				else {				    /* Don't send any VU bits. */				    sc->sz_modsel.pll = 12;				    sc->sz_modsel.rdeclen = 8;				}			    }			    /* END of if TZXX TZ05 TLZ04 */			    else {				sc->sz_modsel.pll = 14;				sc->sz_modsel.vulen = 1;#ifdef SZDEBUG				sc->sz_modsel.vu7 = sz_direct_track_mode;#endif SZDEBUG				sc->sz_modsel.notimo = 1;				sc->sz_modsel.nof = sz_max_numof_fills;			    }			/* end of tape NO option table */			}		    /* 		     * end of if tape ...... 		    */		    }		    else {		/* DISK or CDROM */	 		/*			 * Check to see if we have an option table			 * if we do use those values in the table to set			 * things up.......		   	*/			if( sdp->opt_tab != NULL ){			    /*			     * we have an option table use it.			     * must cast the pointer			    */			     dodp = (struct disk_opt_tab *)sdp->opt_tab;			    /* 			     * lets see if the mode select parameter length is valid			     * We must build it build hand...........			    */			    if( dodp->opt_flags & MSEL_PLL_VAL){				sc->sz_modsel.pll = dodp->msel_pll;				if( dodp->opt_flags & MSEL_BLKDL_VAL){				    sc->sz_modsel.rdeclen = dodp->msel_blkdl;				}				if( dodp->opt_flags & MSEL_VUL_VAL){				    sc->sz_modsel.vulen = dodp->msel_vul;				}			    /* end of if MSEL_PLL_VAL */			    }			    else{				/* 				 * no sense in testing anything else				 * default to hdr and block ( 12 )				*/				sc->sz_modsel.pll = 12;				sc->sz_modsel.rdeclen = 8;				/* ERRLOG_MARK */				cprintf("scsi OPTTABLE off id = %X\n", targid);			    }							    /*			     * must set our block size..512 for disks			    */			    i = 512;			    sc->sz_modsel.reclen2 = LTOB(i,2);			    sc->sz_modsel.reclen1 = LTOB(i,1);			    sc->sz_modsel.reclen0 = LTOB(i,0);			    /* 			     * get our other flags and set up			    */			    if( dodp->opt_flags & BUF_MOD ){				sc->sz_modsel.bufmode =  sz_bp_bufmode;			    }			    /*			     * is this scsi 2 if so must set pf.			    */			    if( sdp->flags & SCSI_MODSEL_PF ){				sc->sz_modsel.pf = 1;			    }						/* end of if disk option table */			}			/* 			 * we have no option table for this			 * disk... This is here for backward			 * compat.			*/			else { 			    if(sdp->flags & SCSI_MODSEL_PF){				sc->sz_modsel.pf = 1;			    }			    else{				sc->sz_modsel.pf = 0;			    }			    sc->sz_modsel.pll = 12;			    sc->sz_modsel.rdeclen = 8;			    i = 512;	/* reclen really means LBN size */			    sc->sz_modsel.reclen2 = LTOB(i,2);			    sc->sz_modsel.reclen1 = LTOB(i,1);			    sc->sz_modsel.reclen0 = LTOB(i,0);			    if(sc->sc_rzspecial[targid]) {				msp = (struct mode_sel_sns_params *)					    sc->sc_rzparams[targid];				sc->sz_modsel.pll = msp->msp_length;				sc->sz_modsel.sp = msp->msp_setps;			    }			}		    }		    break;		case SZ_P_NOCACHE:		    /* 		     * The following is only for tapes....		    */		    cmd = SZ_MODSEL;		    if( sdp->opt_tab != NULL ){			/*			 * we have an option table use it.			 * must cast the pointer			*/			todp = (struct tape_opt_tab *)sdp->opt_tab;			/* 			 * lets see if the mode select parameter length is valid			 * We must build it build hand...........			*/			if( todp->opt_flags & MSEL_PLL_VAL){			    sc->sz_modsel.pll = todp->msel_pll;			    if( todp->opt_flags & MSEL_BLKDL_VAL){				sc->sz_modsel.rdeclen = todp->msel_blkdl;			    }			    if( todp->opt_flags & MSEL_VUL_VAL){				sc->sz_modsel.vulen = todp->msel_vul;			    }			/* end of if MSEL_PLL_VAL */			 }			 else{			    /* 			     * no sense in testing anything else			     * default to hdr and block ( 12 )			    */			    sc->sz_modsel.pll = 12;			    sc->sz_modsel.rdeclen = 8;			    /* ERRLOG_MARK */			    cprintf("scsi OPTTABLE off id = %X\n", targid);			}		        /* 			 * get our density struct pointer...			*/			ddp = &todp->tape_info[DENS_IDX( bp )];			/* 			 * lets see if this density selection is valid..			*/			if( ddp->tape_flags & DENS_VAL ){			    /*		 	     * this is valid lets get our stuff			    */			    sc->sz_modsel.density = 					(char)(SCSI_DENS_MASK & ddp->dens);							    /*			     * must set our block size......			    */			    sc->sz_modsel.reclen2 = LTOB(ddp->blk_size,2);			    sc->sz_modsel.reclen1 = LTOB(ddp->blk_size,1);			    sc->sz_modsel.reclen0 = LTOB(ddp->blk_size,0);			}			/*			 * well we have a option table but this density			 * struct is not valid.... We must do something			 * but is it QIC 9trk 8mm etc... 			*/			else {			    /* ERRLOG_MARK */			    mprintf("scsi OPTTABLE off id = %X\n", targid);			    /* default it */			    sc->sz_modsel.density = 0;			    /*			     * since we zeroed the command struct before			     * we got here we don't have to set zero's			     * in the block size field			    */			}			/* 			 * check speed setting 			*/			if( ddp->tape_flags & SPEED_VAL){			    sc->sz_modsel.speed = 					(SCSI_SPEED_MASK & ddp->tape_speed);			} 			/*			 * is this scsi 2 if so must set pf.			*/			if( sdp->flags & SCSI_MODSEL_PF ){			    sc->sz_modsel.pf = 1;			}						/*			 * end of if option table for tapes			*/		    }		    /*		     * For the old stuff backward compat

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -