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

📄 scsi.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
#ifndef lintstatic  char    *sccsid = "@(#)scsi.c	4.8  (ULTRIX)        1/22/91";#endif lint/************************************************************************ *									* *			Copyright (c) 1984,86,87,88,89 by		* *		Digital Equipment Corporation, Maynard, MA		* *			All rights reserved.				* *									* *   This software is furnished under a license and may be used and	* *   copied  only  in accordance with the terms of such license and	* *   with the  inclusion  of  the  above  copyright  notice.   This	* *   software  or  any	other copies thereof may not be provided or	* *   otherwise made available to any other person.  No title to and	* *   ownership of the software is hereby transferred.			* *									* *   This software is  derived	from  software	received  from	the	* *   University    of	California,   Berkeley,   and	from   Bell	* *   Laboratories.  Use, duplication, or disclosure is	subject  to	* *   restrictions  under  license  agreements  with  University  of	* *   California and with AT&T.						* *									* *   The information in this software is subject to change  without	* *   notice  and should not be construed as a commitment by Digital	* *   Equipment Corporation.						* *									* *   Digital assumes no responsibility for the use  or	reliability	* *   of its software on equipment which is not supplied by Digital.	* *									* ************************************************************************//************************************************************************ * * scsi.c	22-Jun-89 * * VAX SCSI device driver (common routines) * * Modification history: * *   09-Jan-91	Robin Miller *	On fixed length block tapes (QIC), if the byte count isn't modulo *	the block size or if the byte count is greater than 16KB, return *	the error code EINVAL ("invalid argument") instead of ENXIO ("no *	such device or address") to avoid confusion.  This error occurs *	frequently when using the 'dd' utility if the 'sync=conv' option *	is omitted to pad output records. * *   27-Nov-90	Robin Miller *	Merged in Bill Dallas fix which resets the szflags field before *	retrying the command.  Previously if the device had disconnected *	with a check condition, the DMA disconnect flag (SZ_DMA_DISCON) *	was left set causing the wrong DMA count to be setup which later *	panic'ed the system. * *   26-Nov-90	Robin Miller *	o  Added function sz_cdb_length() to calculate and return the *	   Command Descriptor Block length.  The length is calculated *	   using the group code of the command. *	o  Removed '#ifdef FORMAT' conditionalization, since the special *	   interface is used to implement CD-ROM Audio commands. *	o  Added support for 10-byte read/write CDB's.  If the LBA is *	   too large for 6-byte CDB, setup and send a 10-byte CDB. * * 09-Nov-90	Robin Miller *	Changed logic associated with checking of End Of Media (EOM) and *	File Mark (FM) bits in the sense data for the TLZ04 (RDAT).  The *	RDAT sets both of these bits on reads past LEOT (early warning). *	Previously, we only checked and returned EOM status and ignored *	the FM bit.  This broke the restore utility since it expected an *	end of file indication (FM returns count of 0) to prompt for the *	next volume. * * 21-Sept-90	Bill Dallas *	Added fixes for correct handling of flags for tapes. This *	includes tpmark, dev_cse, and dev_shrtrec. All fixes are * 	in the state machine (state SZ_BEGIN). Please see the  *	comments in the code for a complete description. *  *   15-Aug-89	Robin Miller *	o  Added errlog cases for RRD42, RX26, and RZ25 devices. * *	o  Modified the szerror() routine so "Device Not Ready" errors *	   get sent to the error logger.  This error logging is only *	   done if the current command isn't a Test Unit Ready (SZ_TUR) *	   so checks in device open routines don't get logged as errors. *	   Previously ejecting a tape or a CD during an command didn't *	   get logged, only EIO was returned to the program. * *	o  Fixed problem logging errors for CD-ROM devices.  The *	   scsi_logerr() routine was not checking for CD-ROM devices *	   when setting up the class type field, so it was set to *	   undefined (EL_UNDEF).  The 'uerf' utility would then report *	   "OS EVENT TYPE 65535" and not display the error information. *	   The CD-ROM errors are now treated the same as disk errors. * * 30-Jul-90	Bill Dallas    *	Added fixed block tape units tape mark handling. *	This included a new falg in sc_category_flags called *	TPMARK_PENDING * * 16-Jul-90  Janet Schank *      Added errlog cases for the RZ23L, RZ24, RZ57, and TZ05. * * 05-Jul-90 *	Added support for the TZK10 and the new scsi device option  *	table. * * 23-Feb-90 -- sekhar *      Merged Joe Martin's fix for 3.1 cld. When copying user PTEs, *      check for page crossing and reevaluate vtopte. * *   29-Jan-90  Janet Schank *      Added errlog case for TLZ04 (RDAT). * *   13-Nov-89  Janet L. Schank / JAG / Art Zemon *      The RDAT drive was setting both the filemark and ili bits  *      in the request sense data when a filemark is read.  Changed *      the checks for these bits in szerror to only set one error *      flag depending on these bits.  Added the function get_scsiid. *      Added TZ05 support * *   04-Oct-89	Fred Canter *	Bug fix. Added newline to resetting SCSI bus message. *	Added sector number to error log packet for disk errors. *	Use sz_sbtol() to extract infobytes from sense data. * *   18-Aug-89  Janet L. Schank *      The sz_timetable is now using SZ_TIMETBL_SZ as its size. * *   14-Aug-89	Fred Canter *	Enabled binary error logging (sz_log_errors = 1). *	Bug fix: not setting registers valid flag for SII. * *   25-Jul-89	Fred Canter *	Separate SCSI device name defines from MSCP/TMSCP names. * *   23-Jul-89	Fred Caner *	Convert DBBR printfs to error log calls. *	RX33 support. * *   22-Jul-89	Fred Canter *	Always log "resetting bus" to console. * *   16-Jul-89	Fred Canter *	Do mode sense to get disk geometry. * *   15-Jul-89	Fred Canter *	Add flag to control logging of DATAPROTECT errors (sz_log_we_errors). * *   14-Jul-89	Fred Canter *	Merged Dynamic BBR and error log changes. * *   24-Jun-89	Fred Canter *	Modify scsi_logerr to log to console if error cannot be logged. * *   22-Jun-89	Fred Canter *	Save a copy of the current CDB for the error log. *	Save status byte for current command for error log. * *   22-Jun-89	John A. Gallant *	Moved the completion handling of a bp, from the statemachine to the *	completion handler for the drivers.  Included support for the read/ *	write long commands.  Added the scsi bytes to long conversion routine. * *   17-Jun-89	Fred Canter *	Added scsi_logerr() routine for binary error logging support. * *   11-Jun-89	Fred Canter *	Save additional sense code in sz_softc so we can tell when the *	floppy media has been changed. Hooks for softpc. * *   24-May-89	Fred Canter *	Changes to match the new, more general rzdisk utility. *	Changed the mode select data structures so an address and *	length are passed with the ioctl. This allows pages to be *	added to rzdisk without requiring a kernel rebuild. * *   22-May-89	Fred Canter *	Fixed a bug in the code which copies the data back to the user *	on a unrecoverable data error. The code was completely wrong and *	would cause a panic on a medium error (such as reading a unformatted *	SCSI floppy). * *   17-May-89	Fred Canter *	Bug fix (same as stc.c). Back/forward space thru a file mark *	should fail but wasn't. * *   24-Apr-89	Fred Canter *	Added support for the RX23s SCSI floppy. * *   06-Apr-89	Fred Canter *	Added TZxx (EXABYTE) support: *		Don't send VU bits with mode select (modsel.pll = 12). *		Handle target returning busy status (EXABYTE does this). * *	Fixed a bug in the tape short record read code (DEC_SHRTREC). *	The tapex -s test failed because the driver did not copy *	the data back to the users' buffer on a short record read. * *	Added b_comand to replace b_command for local command buffers. *	Use b_gid instead of b_resid to store command. *	No longer need to restore bp->b_command on error retry. * *	Don't retry any tape commands (position lost). * *	Added the capability to do extended mode select for TZxx tapes. * *   22-Feb-89	Alan Frechette *	Fixed the command timeout table "sz_timetable[]" used for the SII. *	Increased some of the timeout values and got rid of the pseudo-op *	definitions that were not needed. * *   11-Feb-89	Fred Canter *	Fixed yet another bug with 64KB transfers. Use blkcpy instead *	of bcopy (bcopy max byte count is 64KB -1 ) for copying *	data to and from the users' buffer. *	Added function header comments to each routine. * *    5-Feb-89	Fred Canter *	Remove rz_max_xfer, cz_max_xfer, and tz_max_xfer. * *    2-Jan-89	Fred Canter *	Modify szerror() to print "error (retrying...)" instead of *	"soft error" on errors which will be retried. *	Cleanup debug code in szerror(). *	Add code to handle short records on read (thanks JAG). * *   28-Dec-88	Fred Canter *	Call szerror() for certain tzcommands so the reason they *	failed gets entered into the error log. * *   20-Dec-88	Alan Frechette *	Fixed an "rzdisk" related bug. If an "rzdisk" command gets *	a check condition an the sense key is SZ_NOSENSE then return *	good status. * *   17-Dec-88	Fred Canter *	Added pseudo commands to resolve the conflict between *	SZ_UNLOAD and SZ_SSUNIT both being opcode 0x1b. * *   15-Dec-88	Alan Frechette *	Modified the state machine to copy data back to the user *	on UNRECOVERABLE data errors. The data copied back to the *	user consists of the data starting from the beginning of *	the disk transfer upto and including the bad block. This *	is needed mainly for "rzdisk" when REASSIGNING bad blocks. * *   08-Dec-88	Alan Frechette *	Set the "pf" bit when you issue a MODE SELECT to the CDROM. *	Needed so "rzdisk" will work. * *   06-Dec-88	Alan Frechette *	Added the printing of the sector number and partition to the *	error logger for RECOVERABLE and UNRECOVERABLE data errors. *	 *   04-Dec-88	Fred Canter *	Retry MEDIUMERR on RZ disks only (for rzdisk consistency). * *   03-Dec-88	Fred Canter *	Changed sz_se_rstop from 1 to 0. *	Retry hardware error sense key. Report retries as soft error *	but last retry as hard error. *  *   03-Nov-88	Alan Frechette *	Added in support for disk maintainence. Added the commands *	FORMAT UNIT, REASSIGN BLOCK, READ DEFECT DATA and VERIFY DATA. *	Made changes to MODE SENSE and MODE SELECT. Figured out a better *	way to determine length of a SCSI command in "sz_bldpkt()". *	Initialize "sc->sc_c_status[targid]" in "sz_start()". Fixed *	the command timeout table "sz_timetable[]" which is now used *	by the SII for scsi command timeouts. * *	Handle the case of retying a command due to a BUS DEVICE RESET *	or an ABORT from the SII driver. The flag value "SZ_RETRY_CMD" *	in "sc->sc_szflags[targid]" handles this condition in "szerror()". * *   16-Oct-88 -- Fred Canter *	Clean up code and comments. *	Move #deine SZDEBUG to scsireg.h. Add RZxx (non-DEC) support. *	Fixed a bug which caused tape commands to fail if the *	bus was busy (see comment in SZ_SP_START:). Fixed a bug *	which caused MEDIUM errors not to be logged. * *   28-Sep-88 -- Fred Canter *	Clean up comments. clean up code and comments for the device *	failed to select timeout. * *   13-Sep-88 -- Fred Canter *	Do less retries (devices do retries). * *   21-Aug-88 -- Fred Canter *	Improved device failed to select error handling. Spin for a *	short time. Use a timeout for the remaining time. *	Removed unused sz_reset routine. Real one now in scsi_5380.c. *	Added support for bus reset. * *   18-Aug-88 -- Fred Canter *	Pass -1 not 0 to sz_start() to start next I/O (fix target ID 0). *	Add sz_em_print to control extended message debug printout. *	Fix driver not always seeing MICROPOLIS B drive by asserting *	ATTN before droping ACK on last byte of extended message. *	Add SHMEM code to bcopy (pte mapping) to fix BAR 435. *	Changed select enable back to the original way. *	Try interrupt instead of spin on phase change (doesn't work yet). *	Fix driver bug which made it think targets were skipping *	the status command (sometimes), data in was eating status byte. * *	Merge 5380 and SII drivers. * *   08-Aug-88 -- Alan Frechette *	Merged in all of the SII portion of this driver. Modified *	the driver to execute the correct code paths whether using *	the SII chip or the NCR 5380 chip. Fixed a few bugs in the *	SII code, made changes to the SII code based on Fred's new *	driver and tried to improve performance. * *   08-Aug-88 -- Fred Canter *	Removed stray interrupt code (can recover from last delta). *	In szprobe, reset bus if BSY/SEL wedged after inquiry. *	Clean out old debug and hltcod code. *	Fix for parity errors caused by PARCK enabled during arbitration. * *   28-Jul-88 -- Fred Canter *	Removed old code which supported RRD40 as device 'cz' (now 'rz). *	Fixed background timer to work with 2nd SCSI controller. *	Program around TZ30 holding BSY true after command complete. *	Added extended message support so driver will work with *	yet another version of the RZ55. *	Removed ond sz_timer code. *	Clean up sz_flags for much improved reselect timeout handling. *	Removed old disconnect timeout code from background timer. * *   18-Jul-88 -- Fred Canter *	Removed all #ifdef CZ code (can recover it from last delta). *	Fix background timer for 2nd SCSI controller. *	Added work around for TZ30 holding bus after command complete. *	Fixed MICROPOLIS B RZ55 support (handle extended message). * *   16-Jul-88 -- Fred Canter *	Handle unit attn condition (media change). *	Convert sz_active from 0-7 to ID bit position. *	Improve reselect timeout handling (CDROM hacks). *	Enable parity checking at all times. *	Fixed a bug in rzioctl which prevented the driver from *	ever setting the default partitions once the disk had *	a partition table on it. *	Changed the RRD40 name from cz to rz (CDROM is a disk). *	Lots of code cleanup. * *   28-Jun-88 -- Fred Canter *	Several driver improvements and code cleanup: *		Restructure for better ??command() handling. *		Deal with unit attn (TZ cartridge change). *		Read system's (initiator) bus ID from NVR. *		Fix DEV_WRITTEN flag handling. *		Background timer to catch lost interrupts *		and reselect timeouts. * *   18-Jun-88 -- Fred Canter *	Added RZ55 support and fixed a bug in partition table code. *	Fixed a bug in request sense status which caused intalls to fail. *	Improved (but not fixed) lost interrupt and reselect timeout *	handling (massive code changes). * *   07-Jun-88 -- Fred Canter *	Bug fixes for finder opening every possible device in the world. * *   06-Jun-88 -- Fred Canter *	First submit to V2.4 pool (sccs create). Much cleanup done. *	Much more needed. Driver functioning well enough to support *	building a kit for testing. * *   23-Apr-88 -- Fred Canter *	A RED LETTER DAY for sure! *	Fixed "most" of the problems which were preventing the *	driver from running multiple devices concurrently. * *   22-Apr-88 -- Fred Canter *	Prototype driver now functioning reasonably. *	Much cleanup done, much more needed. * *    1-Mar-88 -- Fred Canter *	Created the prototype SCSI driver from the VAXstar *	TZK50 driver (stc.c). * ***********************************************************************//*********************************************************************** * TODO: * *  1.	Tape record size limited to a maximum of 16KB. * *********************************************************************** */  #include "../data/scsi_data.c"#include "scsi_debug.h"extern char cvqmsi[] [512*NBPG];extern char cvqmsirb[];extern char szbufmap[];extern	int sz_retries[];	/* retry counter */int sz_max_numof_fills = SZ_DEFAULT_FILLS; /* Maximum number of fills to write*/					   /* in order to try to keep the tape*/					   /* drive streaming.		      */int	sz_timer1();int	sz_timer2();int	szprobe(), szslave(), szattach(), szintr(), sz_start(),	szerror(), sz_scsistart(), sz_reset();int 	sii_probe(), sii_intr(), sii_scsistart(), sii_reset();u_short	szstd[] = { 0 };/* *	The ud_name entry was changed from "sz" to "rz" *	to make the dump and swap on boot code happy. *	They should get the name from the ubdinit structure (ui_devname). *	The ud_name should really be "scsi". * *	It appears the dump code was fixed on or about 6/5/88. *	However, the code works as is and there not time to change it. */struct	uba_driver scsidriver = { szprobe, szslave, szattach, sz_start,				szstd, "rz", szdinfo, "scsi", szminfo,				0 };struct	uba_driver siidriver = { sii_probe, szslave, szattach, sz_start,				szstd, "rz", szdinfo, "sii", szminfo,				0 };extern struct nexus nexus[];extern int sz_unit_rcvdiag[];	/* If zero, need unit's selftest status *//* * Unit on line flag. Set to one if the * device is on-line. Set to zero on any unit * attention condition. */extern int sz_unit_online[];/* * The following table is the timeout value for each command assuming that * the timer is set to go off every 30 seconds. This table is now used by * the SII driver. *

⌨️ 快捷键说明

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