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

📄 scsi.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
				    /*				     * we don't have to convert the btye				     * count to blocks				    */				    sc->sz_t_read.xferlen2 = LTOB( count, 2);				    sc->sz_t_read.xferlen1 = LTOB( count, 1);				    sc->sz_t_read.xferlen0 = LTOB( count, 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);			        sc->sz_t_read.fixed = 0; 			        sc->sz_t_read.xferlen2 = LTOB( count, 2);			        sc->sz_t_read.xferlen1 = LTOB( count, 1);			        sc->sz_t_read.xferlen0 = LTOB( count, 0);			    }			    			/* end of if tape option table */			} 							/* 			 * There is no option table... The default is			 * a normal tape drive......			*/			else{			    sc->sz_t_read.fixed = 0;	/* only records */			    sc->sz_t_read.xferlen2 = LTOB(count,2);			    sc->sz_t_read.xferlen1 = LTOB(count,1);			    sc->sz_t_read.xferlen0 = LTOB(count,0);			}		    /* end of if tape */		    }				    else {		/* DISK r/w */			sc->sz_d_read.lbaddr2 = LTOB(addr,2);			sc->sz_d_read.lbaddr1 = LTOB(addr,1);			sc->sz_d_read.lbaddr0 = LTOB(addr,0);			sc->sz_d_read.xferlen = LTOB(count/512,0);		    }		    break;		case SZ_READ_10:		case SZ_WRITE_10: {		    int blocks = (count / 512);		    sc->sz_d_rw10.lbaddr3 = LTOB(addr, 3);		    sc->sz_d_rw10.lbaddr2 = LTOB(addr, 2);		    sc->sz_d_rw10.lbaddr1 = LTOB(addr, 1);		    sc->sz_d_rw10.lbaddr0 = LTOB(addr, 0);		    sc->sz_d_rw10.xferlen1 = LTOB(blocks, 1);		    sc->sz_d_rw10.xferlen0 = LTOB(blocks, 0);		    break;		}		case SZ_FORMAT:			fp = (struct format_params *)						sc->sc_rzparams[targid];			if(fp->fp_defects == VENDOR_DEFECTS) {				sc->sz_d_fu.fmtdat = 1;				sc->sz_d_fu.cmplst = 1;			}			else if(fp->fp_defects == KNOWN_DEFECTS) {				sc->sz_d_fu.fmtdat = 1;				sc->sz_d_fu.cmplst = 0;			}			else if(fp->fp_defects == NO_DEFECTS) {				sc->sz_d_fu.fmtdat = 0;				sc->sz_d_fu.cmplst = 0;			}			sc->sz_d_fu.dlf = fp->fp_format;			sc->sz_d_fu.pattern = fp->fp_pattern;			sc->sz_d_fu.interleave1 = LTOB(fp->fp_interleave,1);			sc->sz_d_fu.interleave0 = LTOB(fp->fp_interleave,0);			break;		case SZ_REASSIGN:			break;		case SZ_RDD:			rdp = (struct read_defect_params *)						sc->sc_rzparams[targid];			sc->sz_d_rdd.m = 1;			sc->sz_d_rdd.g = 1;			sc->sz_d_rdd.dlf = rdp->rdp_format;			sc->sz_d_rdd.alclen1 = LTOB(rdp->rdp_alclen,1);			sc->sz_d_rdd.alclen0 = LTOB(rdp->rdp_alclen,0);			break;		case SZ_VFY_DATA:			vp = (struct verify_params *)						sc->sc_rzparams[targid];			sc->sz_d_vd.reladr = 0;			sc->sz_d_vd.bytchk = 0;			sc->sz_d_vd.lbaddr3 = LTOB(vp->vp_lbn,3);			sc->sz_d_vd.lbaddr2 = LTOB(vp->vp_lbn,2);			sc->sz_d_vd.lbaddr1 = LTOB(vp->vp_lbn,1);			sc->sz_d_vd.lbaddr0 = LTOB(vp->vp_lbn,0);			sc->sz_d_vd.verflen1 = LTOB(vp->vp_length,1);			sc->sz_d_vd.verflen0 = LTOB(vp->vp_length,0);			break;		case SZ_READL:		case SZ_WRITEL:			iox = (struct io_uxfer *) sc->sc_rzparams[targid];			prwl = (struct sz_rwl_cm *) &(iox->io_cdb[1]);			sc->sz_rwl.reladr = prwl->reladr;			sc->sz_rwl.lun = prwl->lun;			sc->sz_rwl.phad = prwl->phad;			sc->sz_rwl.lbaddr3 = prwl->lbaddr3;			sc->sz_rwl.lbaddr2 = prwl->lbaddr2;			sc->sz_rwl.lbaddr1 = prwl->lbaddr1;			sc->sz_rwl.lbaddr0 = prwl->lbaddr0;			sc->sz_rwl.dspec = prwl->dspec;			break;		case SZ_RQSNS:		    /*		     * 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			*/			if (sc->sc_devtyp[targid] & SZ_TAPE) {				    todp = (struct tape_opt_tab *)sdp->opt_tab;			    /* 			     * lets see if the request sense is valid			    */			    if( todp->opt_flags & RSNS_ALLOCL_VAL){			    	/* 			       	 * is the request size larger then storage			    	*/			    	if( todp->rsns_allocl > 					sizeof( struct sz_exsns_dt)){				    /*			 	     * truncate the size				    */				    sc->sz_rqsns.alclen = 					sizeof(struct sz_exsns_dt);			        }			        else { 				    sc->sz_rqsns.alclen = todp->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;			    }			}			else { /* must be disk */			    dodp = (struct disk_opt_tab *)sdp->opt_tab;			    /* 			     * lets see if the request sense is valid			    */			    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;				}			    }

⌨️ 快捷键说明

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