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

📄 scsi.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
#ifndef lintstatic  char    *sccsid = "@(#)scsi.c	4.11  (ULTRIX)        2/14/91";#endif lint/************************************************************************ *									* *			Copyright (c) 1988 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.			* *									* *   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	12/19/89 * * CVAX/FIREFOXstar/PVAX/PMAX SCSI device driver (common code) * * Modification history: * *   29-Jan-91	Robin Miller *	o  Added support for CD-ROM audio commands. *	o  Moved pseudo SCSI commands to group 3 range (0x60-0x7f) *	   to avoid conflict with CD-ROM audio commands. * *   09-Jan-91	Robin Miller *	On fixed length block tapes (QIC), if the byte count isn't modulo *	the block size, 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. * *   07-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. * *   26-Oct-90	Robin Miller *	Modified scsi_logerr() function to pickup the proper controller *	base address out of the softc structure.  Previously, it was *	always using the base address of the first SCSI controller. * * 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. *  *   10-Sep-90  Charles Richmond IIS Corp *	Added declarations required for kzqsa board and driver. * *   24-Aug-90  Maria Vella *      - Set the sc_category_flags field with DEV_SHRTREC when ILI bit *        set in Request Sense data.  Used to be set in sc_flags which *        was interpreted as DEV_EOM in tape driver. * *   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. * *   10-Aug-90  Maria Vella *      - Cleared the SZ_NEED_SENSE bit in sc_szflags for:  *          - SP_START in the default case on return from sc->port_start() *          - SP_START_ERR after call to sz_restore_rqsns(). *      - Added call to sz_restore_rqsns() in SZ_W_DMA in the *        default case on return from sc->port_start(). *       *   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. * *   25-Jun-90	 Mitchell McConnell *	o  Fix for PMAX - port_start for RQSNS will return BUSBUSY if *	   unable to select due to reselection.  In this case, instead *	   of the event remaining the same, we need to set the event to *	   SZ_SELRETRY_SNS to work with state machine changes for 3max *	   (see explanation for 13-Jun-90). * *   13-Jun-90	 Mitchell McConnell *	o  Fix for RDAT "dropped packets" problem.  The port_start for  *	   RQSNS was returning SZ_IP, but we then lost arbitration (which *	   we didn't find out till interrupt time).  The problem is how to *	   recover state in a sufficiently general way without having *	   to create more sub-states, etc.  The proposed solution is to *	   use the pxstate field in the softc (this is how it is used by *	   the vax) which will be the state to return to if the select  *	   fails.  In the "normal" case, the oops state will be SZ_NEXT/BEGIN, *	   just as it has always been.  For the special RQSNS states, *	   the new state must revert "back" one state, i.e., SZ_RDMA_ERR *	   must go back to SZ_R_DMA.  The catch is that any flags that *	   may have been altered must be set back to their original values. *	   E.g., the routines save_rqsns and restore_rqsns must be called *	   so that on the next iteration through SZ_R_DMA, the NEED_SENSE *	   flag will be set, and the RQSNS may be retried. * *   07-Jun-90 	 Mitchell McConnell *	o  Reverted change of 20-Jan-90 back to original scheme to try *	   and isolate RDAT problem. * *   06-June-90	Bill Dallas *	Added support for the option table... new field in the devtab struct. *	This will allow easy additions of devices of a known type..tape/disk * *   17-May-90  John A. Gallant *	Added setting BERROR in the error leg of the SM. * *   16-May-90   Mitchell McConnell *	o  Removed ifdef'ed FORMAT stuff. *	o  Added new error states to handle SZ_IP return code from  *	   RQSNS.  All of the main states now have a box before their *	   case statement, to help in following the code. *	o  Because of asynchronous nature of RQSNS, must save relevant *	   softc fields on a per-target basis.  Created new structure *	   and routines to save/restore... * *   19-Mar-90  Janet Schank *      Added errlog cases for RZ24, RZ57, and TZ05. * *   26-FEB-90  Janet Schank *      Added errlog case for TLZ04 (RDAT). * * 23-Feb-90 -- sekhar *      Merged Joe Martin's fix for 3.1 cld. When copying user PTEs, *      check for page crossing and reevaluate vtopte. * *   20-Jan-90  Mitchell McConnell *	DEV_TPMARK and DEV_SHRTREC were previously set in category_flags *	to indicate filemark and over-read, respectively.  DEV_TPMARK was *	doing double duty, however, since it remained set until cleared by *	another tzopen or clear serious exception.  What is needed are 2 *	flags which apply only to the current i/o to know how to handle *	residual bytes (in ST_R_DMA).  Since sc_flags is elsewhere used *	in this way, we now set TPMARK (when it occurs) in both sc_flags  *	and sc_category flags, with sc_flags being cleared as soon as  *	sc_resid is set.  Similarly, we now use sc_flags for SHRTREC  *	instead of category flags. * *   19-Dec-89	John A. Gallant *	Restored the error retry code in the szerror() routine, and in the SM *	now compare the retries aginst the SP/RW_RTCNT defines in scsireg.h * *   11-Dec-89  Mitchell McConnell *	Set sc_attached flag in szattach() to catch problem where devices *	which were physically present and alive but not configured were *	causing the system to hang. * *   11-Nov-89  Mitchell McConnell *      Added ASC support to scsi_logerr.  Added ASC logerr string  *      to sz_BusErr array entry #5. Made entry for 4C non-SII  *      specific, since I need to share it and the context *	should be clear from the controller id. * *   17-Oct-89  Janet L. Schank / JAG *      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. * *   17-Oct-89  Janet L. Schank / Art Zemon *      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. * * 10/12/89     Janet L. Schank *      Moved the clearing of the rambuff from scsi.c to sii_scsistart * * 09/22/89     Janet L. Schank *      Changed some defines and ifdefs to include and use sii.h. *      Removed many "ifdef vax"'s.  Added default scsi_devtab *      entries:  szp_rz_udt, szp_tz_udt, szp_cz_udt.  Added sz_devname *      and sz_revlevel arrays.  Replaced the szattach and szslave *      functions with "auto-config" versions from the vax-side code. * *   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 Canter *	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 *	Merged Dynamic BBR and error log changes. *	Add flag to control logging of DATAPROTECT errors (sz_log_we_errors). * * *   13-Jul-89	Fred Canter *	Special mode select/sense handling for the EXABYTE tape. * *   12-Jul-89	Fred Canter *	Added scsi_logerr() routine for SCSI binary error logging. *	Save current CDB and status byte for error log. * *	Buf gix (same as stc.c). Back/forward space thru a file mark *	should fail but wasn't. * *   27-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. * *   14-Jun-89	Fred Canter *	Initialize sc_c_status in sz_start(), caused rzspecial commands *	to fail because of left over bad status. * *   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). * * 03/30/89	John A. Gallant *	Pulled more fixed from the VAX side for rxdisk: *	Fixed an "rzdisk" related bug. If an "rzdisk" command gets *	a check condition an the sense key is SZ_NOSENSE then return *	good status. *	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. * * 03/22/89	John A. Gallant *	In sz_bldpkt() for mode select, if the tape is a TZxx don't send *	any of the vender unique bits.  Set the pll field to 12. * * 03/01/89	John A. Gallant *	Added the pseudo command codes for to allow the tape to unload.  I *	followed the same conventions as the firefox/pvax code. * * 01/16/89	John A. Gallant *	More modifications from the firefox/pvax code: *	Call szerror() for certain tzcommands so the reason they *	failed gets entered into the error log. *	If BBWAIT is set, the b_command/b_resid field is not copied to curcmd. *	I also found the "black hole". * * 12/14/88	John A. Gallant *	More additions from the firefox code: *	Set the "pf" bit when you issue a MODE SELECT to the CDROM. *	Needed so "rzdisk" will work. *	Added the printing of the sector number and partition to the *	error logger for RECOVERABLE and UNRECOVERABLE data errors. *	 * 12/01/88	John A. Gallant *	Fixed the tape ILI, bug, an "over-read" is now flaged in category_flags *	for the state machine to check for. * * 11/23/88	John A. Gallant *	Revamped the debug printfs, to allow tracking of single targets. * * 11/09/88	John A. Gallant *	Started the merge with the V3.0 source level.  Due to time constraints *	only the changes for the new IOCTL support will be merged.  Others *	changes will hopefully occur as time permits.  Copied over the timeout *	table, however, it is not implemented. *   COMMENTS from V3.0: *   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()". * * 11/07/88	John A. Gallant *	All changes are removal of target 5 debug statements.  Added a debug *	statement for each interation of the statemachine. * *   10-Oct-88	 Ricky Palmer (rsp) *	One last pass through here for FT1. * *   16-Sep-88	 Ricky Palmer (rsp) *	Fixed rz23 support. * *   14-Sep-88	 Ricky Palmer (rsp) *	Added IS_KUSEG macro test to mapping code. *	Also put in panic for bad addr if mapping is to user space. * *    7-Sep-88	 Ricky Palmer (rsp) *	Added new code and support for PMAX. There are changes  *	in the probe and setup code as well as the start routine *	in order to support the scsi_sii.c routines. The changes *	are surrounded by ifdef's where necessary. * *   25-Aug-88   Ricky Palmer *      Ifdef'ed again for vax and mips. This time it is based on *      my August 1, 1988 ifdef's of the original scsi.c "glob" driver. * *   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 PVAX and FIREFOX 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.

⌨️ 快捷键说明

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