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

📄 scsi.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
			    */			    if( dodp->opt_flags & RSNS_ALLOCL_VAL){			    	/* 			       	 * is the request size larger then storage			    	*/			    	if( dodp->rsns_allocl > 						sizeof( struct sz_exsns_dt)){				    /*			 	     * truncate the size				    */				    sc->sz_rqsns.alclen = 						sizeof(struct sz_exsns_dt);			        }			        else { 				    sc->sz_rqsns.alclen = dodp->rsns_allocl;			        }			    }			    /* 			     * we have an option table but they never validated			     * the request sense size default it....			    */			    else {			        sc->sz_rqsns.alclen = SZ_RQSNS_LEN;			    }			}		    /*		     * end of if option table		    */		    }		    else{	/* default  No option table */			sc->sz_rqsns.alclen = SZ_RQSNS_LEN;		    }		    break;		case SZ_MODSNS:		    /* 		     * The tape section 		    */		    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 sense is valid			    */			    if( todp->opt_flags & MSNS_ALLOCL_VAL){				/* 				 * is the request size larger then storage				 * The storage area is 44 bytes now....				 * This large enougth for a head +block +page.				 * I know that scsi_tape is not now requesting				 * any pages but that can change.... 				 * for tapes the msns_allocl field should				 * just be the the header + block size and				 * we do the addition for the page if requested.				*/				if( count < 0 ){ 				    /* no pages .....*/				    if( todp->msns_allocl > 						sizeof( struct sz_datfmt)){					/*					 * truncate the size					*/					sc->sz_modsns.alclen = 						sizeof(struct sz_datfmt);					/* ERRLOG_MARK */					cprintf("scsi OPTTABLE off id = %X\n", 						targid);				    }				    else { 					sc->sz_modsns.alclen = 						todp->msns_allocl;				    }				}				/* 				 * Well count is => 0 must mean this is scsi 2				 * and we are requesting a page along with this				 * must check our size...				*/				else{ 				    if( todp->opt_flags & PAGE_VAL) {					if(( todp->msns_allocl + 						todp->page_size) >						sizeof(struct sz_datfmt)){					    /* ERRLOG_MARK */					    cprintf("scsi OPTTABLE off id = %X\n", targid);					    sc->sz_modsns.alclen = 						sizeof(struct sz_datfmt);					}					else { 					    sc->sz_modsns.alclen = 						( todp->msns_allocl +							todp->page_size);					}				    }				    else {					/* whoever set up this tape unit 					 * (dec/customer)					 * said this was a scsi 2 implementation					 * but  not everything is set up ... 					 * lets notify					 * and try to salvage					*/					/* ERRLOG_MARK */					cprintf("scsi OPTTABLE off id = %X\n", targid);					if( todp->msns_allocl > 						sizeof(struct sz_datfmt)){					    sc->sz_modsns.alclen = sizeof(struct sz_datfmt);					}					else { 					    sc->sz_modsns.alclen = 						todp->msns_allocl;					}				    }				/*				 * since count => 0 must set up the page control				 * fields				*/				sc->sz_modsns.pgcode = count & 0x3f;				sc->sz_modsns.pcf = (count >> 6 ) & 0x3;				/* end of if count => 0 */				}			    /* end of if MSNS_ALLOCL_VAL */			    }			    /* 			     * we have an option table but they never validated			     * the mode sense size default it....			    */			    else {				/* ERRLOG_MARK */				cprintf("scsi OPTTABLE off id = %X\n", targid);				sc->sz_rqsns.alclen = SZ_MODSNS_LEN;			    }			/*			 * end of if option table			*/			}			else{	/* default  No option table for all the old stuff */			    /* EXABYTE tape has 2 more mode sense data bytes */			    if (sdp->flags & SCSI_MODSEL_EXABYTE){    				sc->sz_modsns.alclen = 16;			    }			    else{				sc->sz_modsns.alclen = SZ_MODSNS_LEN;			    }		        }		    /* End of if tape */		    }		    /* 		     * Now we start with the disk 		     * else if this for more scsi devices		    */		    else {					/* DISK/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 sense is valid			    */			    if( dodp->opt_flags & MSNS_ALLOCL_VAL){				/* 				 * is the request size larger then storage				 * The storage area is 44 bytes now....				 * This large enougth for a head +block +page.				 * the msns_allocl field should				 * just be the the header + block size and				 * we do the addition for the page if requested.				*/				if( count < 0 ){ 				    /* no pages .....*/				    if( dodp->msns_allocl > 					     sizeof( struct sz_rzmodsns_dt)){					/*					 * truncate the size					*/					sc->sz_modsns.alclen = 						sizeof(struct sz_rzmodsns_dt);					/* ERRLOG_MARK */					cprintf("scsi OPTTABLE off id = %X\n", 						targid);				    }				    else { 					sc->sz_modsns.alclen = dodp->msns_allocl;				    }				}				/* 				 * Well count is => 0 must mean this is scsi 2				 * and we are requesting a page along with this				 * must check our size...				*/				else{ 				    if( dodp->opt_flags & PAGE_VAL) {					if(( dodp->msns_allocl + 						dodp->page_size) >						sizeof(struct sz_rzmodsns_dt)){					    sc->sz_modsns.alclen = 						sizeof(struct sz_rzmodsns_dt);					    /* ERRLOG_MARK */					    cprintf("scsi OPTTABLE off id = %X\n", targid);					}					else { 					    sc->sz_modsns.alclen = 							(dodp->msns_allocl +							dodp->page_size);					}				    }				    else {					/* whoever set up this disk unit 					 * (dec/customer)					 * said this was a scsi 2 implementation					 * but not everything is set up ... 					 * lets notify					 * and try to salvage					*/					/* ERRLOG_MARK */					cprintf("scsi OPTTABLE off id = %X\n", 						targid);					if( dodp->msns_allocl > 						sizeof(struct sz_rzmodsns_dt)){					    sc->sz_modsns.alclen = 						  sizeof(struct sz_rzmodsns_dt);					}					else { 					    sc->sz_modsns.alclen = 						   todp->msns_allocl;					}				    }				/*				 * since count => 0 must set up the page control				 * fields				*/				sc->sz_modsns.pgcode = count & 0x3f;				sc->sz_modsns.pcf = (count >> 6 ) & 0x3;				/* end of if count => 0 */				}			    /* end of if MSNS_ALLOCL_VAL */			    }			    /* 			     * we have an option table but they never validated			     * the mode sense size default it....			    */			    else {				if( count < 0 ){				    /* 				     * scsi 2 ?? just header + block 				    */				    sc->sz_modsns.alclen = 12;				    /* ERRLOG_MARK */				    cprintf("scsi OPTTABLE off id = %X\n", 						targid);				}				else { 				    /*				     * count says we want a page lets doit...				    */				    sc->sz_modsns.alclen =						sizeof(struct sz_rzmodsns_dt);				    sc->sz_modsns.pgcode = count & 0x3f;				    sc->sz_modsns.pcf = (count >> 6) & 0x3;				}			    }			/*			 * 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);		    sc->sz_load.immed = 1;		    break;		case SZ_RECDIAG: {		    if (sc->sc_devtyp[targid] & (SZ_DISK|SZ_CDROM)) {			struct diagnostic_params *dp;			dp = (struct diagnostic_params *) sc->sc_rzparams[targid];			sc->sz_recdiag.alloc_len1 = LTOB(dp->dp_length,1);			sc->sz_recdiag.alloc_len0 = LTOB(dp->dp_length,0);		    } else {			sc->sz_recdiag.alloc_len1 = 0;			sc->sz_recdiag.alloc_len0 = SZ_RECDIAG_LEN;		    }		    break;		}		case SZ_SNDDIAG: {		    struct diagnostic_params *dp;		    dp = (struct diagnostic_params *) sc->sc_rzparams[targid];		    sc->sz_snddiag.control = dp->dp_control;		    sc->sz_snddiag.param_len1 = LTOB(dp->dp_length,1);		    sc->sz_snddiag.param_len0 = LTOB(dp->dp_length,0);		    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;

⌨️ 快捷键说明

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