📄 scsi_sii.c
字号:
#ifndef lintstatic char *sccsid = "@(#)scsi_sii.c 4.10 (ULTRIX) 3/13/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_sii.c 05/03/90 * * PVAX/FIREFOX/PMAX SCSI device driver (SII routines) * * Modification history: * * 03/12/91 Randall Brown * Made a fix to sii_intr() if it was called do to a stray sii intr. * The address of the chip must be setup. * * 02/13/91 Paul Grist * Addded latent support for 2nd scsi controller on mipsmate. * * 02/12/91 Robin Miller * o Merge in PMAX wmbcopy(), rmbcopy(), & wmbzero() functions which * John Gallant rewrote for the PDMA design. These functions properly * handle odd byte counts to/from the PMAX SCSI RAM buffer. * o Added two calls to wbflush() in function sii_reset() where the sii * registers were modified, but were not being flushed. * * 01/29/91 Robin Miller * o Setup address/count for various CD-ROM commands which require * data in/data out. * o Added support for disk send/receive diagnostic functions. * * 11/21/90 Robin Miller * o Added support for 10-byte Read/Write CDB's. * o Use function sz_cdb_length() to obtain the Command Descriptor * Block (CDB) length. * * 09/26/90 Robin Miller * Fixed problem introduced in 8/29/90 edit. I inadvertantly left * off the target ID index when referencing the SII DMA count field * (sc_siidmacount[targid]) on disconnect phases. This would have * caused problems when multiple drives disconnected at the same time. * * 08/30/90 Robin Miller * Added check in probe routine to recognize RX26 device type * and setup accordingly for floppy device. * * 08/29/90 Robin T. Miller * Changed the check made in sii_msgin() to set the SZ_DMA_DISCON * flag (disconnect occured during dma) when there is residual dma * count for this target. Previously, this flag was only set if * the previous phase was a data in or a data out. This check was * insufficient for our CDROMs, broke both the RRD40 & RRD42, since * the previous two phases were message in. * * 08/07/90 Richard L. Napolitano * (First Ultrix modification) * In the routine sii_select_target, we must flush the write * to the sii_slcsr register before writing the sii_comm * register to start selection. This change insures that the * SCSI id of the target is written to the SII prior to starting * selection. * * 07/16/90 Janet L. Schank * During selection of a target, it was possible for a reselection * to occur after the ATN line was raised. The RDAT is broken * and can't deal with this. So during the selection process, * reselections are now disabled. This is a slight performance * hit, so if the RDAT is ever fixed this hack should be removed. * * 06/04/90 Bill Dallas * In sii_startdma() got rid of a hard define of SZ_RQSNS_LEN. * Used the scsi command packet for the length. * * 05/30/90 Janet L. Schank * Modified to use kn230_bzero, kn230_rbcopy, and kn230_wbcopy. * * 05/14/90 Janet L. Schank * Added Mipsmate rambuffer copy and zero functions to deal with the * hardware bug. * * 05/03/90 John A. Gallant * Cleaned up a lot of the SCSI bus RESET/clear_io_tasks problems. * removed the bug on sync xfers and RESET in sii_intr. Removed the * clear io call in sii_scsistart. * * 03/19/90 John A. Gallant * Placed the setting/clearing of the req/ack offset control register * for the SII in the state change code and in the selection code. * Now sii_dmctrl is set prior to any data phases occuring. * * 03/14/90 John A. Gallant * Added checks within the data moving code to not go past the true * end of the user's buffer for reads and writes. Added zero fill * for writes less than a sector size. * * 01-Mar-90 Janet Schank * Added retries on busy target in the probe routine. * * 20-Dec-89 Janet L. Schank * Fixed the "sc" initialization bug in probe. Replaced sii_nNSII * with nNSII. Moved sii_stray_intr to scsi_data.c. * * 12-Dec-89 Mitch McConnell * Initialize sc_attached to zero. * * 01-Dec-89 Fred Canter * Calculate the number of PTEs needed to double map the user's * buffer in a machine independant way (no more magic number). * * 02-Nov-89 Janet L. Schank * Added a call to sii_clear_discon_io_tasks in sii_reset. * This will clear all active and disconnected IO requests. * Fixed wmbzero clearing error, wasn't clearing all that was needed. * * 17-Oct-89 Janet L. Schank / JAG * During the message in phase, if an unsupported extended message * is received, ATN is asserted before the last message byte * is acknowledged. In message out, if polled mode, really send * an identify with NO disconnects. Added a call in the probe routine * to get_scsiid. * * 08-Oct-89 Fred Canter * Remove error log #ifdef OLDWAY. * * 07-Oct-89 Fred Canter * Save removable media bit from inquiry data in sz_softc. * * 03-Oct-89 Fred Canter * Added error log debug code (#ifdef ELDEBUG). This allows the * driver to produce most error types for uerf debuging. * * 09/22/89 Janet L. Schank * Changed some defines and ifdefs to include and use sii.h. * Removed alot of "ifdef vax"'s. The softc structure is now used * in the same way as on the vax-side. Replaced siiprobe with * sii_probe taken from the vax code. The sii reg. addr. is * received as an argument to sii_probe and is saved in the softc * structure, which is then used for all further refrences to * "scsiaddr". * * 24-Aug-89 Alan Frechette * Added routine siireset() to reset the SII chip for the * crash dump code in order to always get crash dumps. This * is needed for the PROM boot drivers to work correctly. * * 15-Jul-89 Fred Canter * Merged Dynamic BBR and error log changes. * * 11-Jul-89 Fred Canter * Convert error messages from printf to scsi_logerr(). * Save status byte for current command for error log. * Modify sii_dumpregs() for use by sii_logerr(). * * 27-Jun-89 John A. Gallant * Added the initialization of the completion code routine pointers. In * the start dma code added support for the read/write long commands. * * 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. * * 04/13/89 John A. Gallant * Removed the b_command fixup in sii_busy_target(). * * 03/22/89 John A. Gallant * Able to handle a target returning a status of busy. The command is * left on the queue and after a BUS_WAIT time is restarted. The start * dma routine for mode select uses the parameter length in the CDB for * the data count. The select target routine checks the SII to determine * if it can start a selecton command. * * 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. The start/stop * command was changed to a pseudo command. * * 01/16/89 John A. Gallant * Improved the Selection code, made it more forgiving. If selection * fails, the SII is checked to see if it is being reselected. * * 12/21/88 John A. Gallant * In sii_recvdata() during a dma transfer, the MIS bit is also checked * to watch for the target changing phase. When the MIS bit is set the * WAIT loop will terminate. * * 12/20/88 John A. Gallant * During the probe routine, the siidboff[] region is cleared. This * removes the previous inquiry data that was put there. Introduced a * new routine, wmbzero(). It writes 0 to the ram buffer. * * 12/15/88 John A. Gallant * Modified the wait for CON in sii_state_change(), only wait if * a connect is expected. Also in the same routine, if CON is not * set bus_idle is set to TRUE, immediatly. * * 12/13/88 John A. Gallant * Added the changes from firefox: * Had to make a change due to new firmware in CDROM. The CDROM * now sends a message reject message and then disconnects from * the bus when you send it an Extended Synchronous Data Tranfer * Request Message. This is now handled correctly. * * 11/21/88 John A. Gallant * Changes to help the "slower" tape drive, in select_target, returns * ABORT, in scsistart the spin loop breaks out and returns IP. * Revamped the debug statements to be able to track a single target. * * 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. * * 11/09/88 Alan E. Frechette * The following fixes were made to support the CDROM device: * 1: Call "sii_dodev()" in probe for CDROM device. * * 2: Ignore the second disconnect if we get back-to-back * disconnects from the CDROM device. * * 3: Fixed the routine "sii_select_target" to handle the * slower CDROM device. Wait for the connect bit (SII_CON) * after we get the state change bit (SII_SCH). * * Had to change a few things to get "rzdisk" to work but they * were minor. * * 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. * * 11/07/88 John A. Gallant * The sii_scsistart routine now returns success/or error condition. This * allowed the state machine to handle error conditions correctly, this * is very useful for tape and filemarks. * COMMENTS from V3.0: * 03-Nov-88 Alan Frechette * .............................................. If a scsi command * did not have good status then return the value "SZ_RET_ERR" * in "sii_scsistart()" otherwise return "SZ_SUCCESS". This * was a nasty bug. * * 7-Sep-88 Ricky Palmer (rsp) * Did some major re-writing of this code for PMAX. Basically * had some major race conditions on the new architecture/processor * as well as some delays due to how original code was constructed. * I re-wrote the interrupt routine to be single threaded and * not looping. I also updated the pieces of this code that * came from Mike Nielsen as he found bugs in his original * SCSI code that had made their way into this code. Larry Palmer * suggested the new buffer scheme that allows this code to * now support 7 devices plus the host adaptor with normal * transfer requests upto 64KB from the minphys code. Some * other changes were targeted at getting performance up * by a factor of 1.5 to 3.0 depending on the request size. * Also added support for the RZ23 as what was here did not * work correctly. Thanks also goes to Larry Palmer for his efforts * in tracking various bugs and problems along with me. * We both spent considerable time architecting, writing new and * re-writing old code to make this really work for PMAX. * * 23-Aug-88 Alan Frechette * Fixed the GENERIC kernel boot problem for the SII on FIREFOX. * The GENERIC kernel now boots off a FIREFOX workstation. * * Added support to handle SYNCHRONOUS and ASYNCHRONOUS devices * at the same time. I simply save the req/ack offset for each * SCSI device out on the bus after issuing the Synchronous Data * Transfer Request extended message. The req/ack offset is used * to set the DMA Control Register of the SII for synchronous or * asynchronous data transfers. * * Fixed a few bugs in the SII interrupt routine dealing with * reselects and handle quick reselects there rather then wait * for another interrupt. * * 17-Aug-88 Fred Canter * Created this file by moving the SCSI SII specific files * from the old combined driver (scsi.c) to scsi_sii.c. * The SII code was written by Darrell Dunnuck and Alan Frechette. * * 01-Aug-88 -- Ricky Palmer * Ifdef'ed and modified for mips and vax. Wrote some sii code and * also picked up sii code from Mike Nielsen/Alan Frechette/ * Fred Canter/Darrell Dunnuck/Larry Palmer/Bob Rodriguez. * ***********************************************************************/#include "../data/scsi_data.c"/* * Define ELDEBUG to create error for uerf debuging. * NOTE: must not be defined at submit time (performance hit). *//*#define ELDEBUG */#include "scsi_debug.h"int siidebug = 0;int siitarget = 0;#ifdef vaxextern char cvqmsi[] [512*NBPG];extern char cvqmsirb[];#endif vaxextern char szbufmap[];extern short sz_timetable[];extern int cpu;int sii_wait_after_inquiry = 1000;/* For quick hacks at debugging. */#undef DEBUGint sii_busy_target(); /* for forware reference */int wmbcopy(), rmbcopy(), wmbzero(), bzero(), bcopy();extern int kn230_bzero(), kn230_wbcopy(), kn230_rbcopy();/****************************************************************** * * Probe routine for SII chip. * ******************************************************************/short sii_reject_message = 0;short sii_assert_attn = 0; /* Assert Attention Flag *//* * Number of seconds to wait for SCSI devices * to come ready enough to respond to inquiry * after bus reset. Needs to be a variable so * users can change it (I am such a nice guy). * Factory default is 7 seconds (in scsi_data.c). */extern int sz_wait_for_devices;extern int sz_max_wait_for_devices;extern int sii_scsistart();extern int sii_reset();extern struct scsi_devtab szp_rz_udt;extern struct scsi_devtab szp_tz_udt;extern struct scsi_devtab szp_cz_udt;extern int szp_nrz;extern int szp_ntz;extern int szp_ncz;extern int szp_nrx;extern int rz_max_xfer;extern int cz_max_xfer;extern int tz_max_xfer;extern int rzcomplete();extern int tzcomplete();extern int sz_cdb_length();/********************************************************************** * * Name: sii_probe * * Abstract: The SII probe entry point routine from auto-configure * code. Determine if the SII controller exists. Reset the * SCSI bus. Size the number and type of targets on the * SCSI bus. Set up the "sz_softc" structure and the 128K * hardware buffer. * * Inputs: * reg SCSI bus controller CSR address (not used). * cntlr SCSI bus controller number (0 = bus A, 1 = bus B). * * Outputs: * sz_softc * * sc_sysid SCSI bus ID of initiator (CPU). * *port_start() SCSI command start routine - sii_scsistart(). * *port_reset() SCSI bus reset - sii_reset(). * *device_comp() SCSI device completion routine * *sc_rambuff Virtual address of 128KB hardware RAM buffer. * sc_segcnt[] Per target - 128 KB buffer slot size (max byte cnt). * sc_dstp[] Per target - disk default partition table pointer. * sc_devtyp[] Per target - device type (see scsireg.h). * sc_alive[] Per target - device present at this SCSI bus ID. * sc_device[][] Per target - product ID, vendor ID, rev in ascii. * sc_SZ_bufmap[] Per target - virtual address for buffer mapping. * sc_szbufmap[] Per target - PTEs from get_sys_ptes(). * sc_dboff[] Per target - offset into 128 KB buffer. * sc_devnam[][] Per target - vendor & product ID in ascii. * sc_revlvl[][] Per target - revision level in ascii. * sc_siisentsync[] Per target - sent synchronous message flag.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -