📄 scsi_asc.c
字号:
#ifndef lintstatic char *sccsid = "@(#)scsi_asc.c 4.11 (ULTRIX) 2/26/91";#endif lintextern dumphex();/************************************************************************ * * * Copyright (c) 1989 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_asc.c * * 3MAX SCSI device driver (ASC routines) * * 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. * * 12/05/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. * * 11/27/90 Maria Vella v00.00.37 * Removed two calls to DELAY() in asc_phase_change() which were * there for debugging purposes and should have been removed. * They caused the loss of 1/10th of a second of time on the * system clock. Fixes QAR #06476. * * 10/07/90 Maria Vella v00.00.36 * * a. Major modifications to add PDMA support. * b. Fixed QAR having to do with setting sz_unit_rcvdiag[] in * ascprobe(). Was being indexed by targid. * * 08/30/90 Robin Miller v00.00.35 * Added check in probe routine to recognize RX26 device type * and setup accordingly for floppy device. * * 08/24/90 Maria Vella v00.00.34 * a. In asc_state_change(), added check for selection completed * but no command phase asserted by target due to the target * being busy. Problem shows up when RDAT is attached and * doing its diagnostics while booting. This must have * fallen through the cracks during the past few modofications. * * 08/10/90 Maria Vella v00.00.33 * * a. In asc_state_change(), added check for all 4 states in * which a Request Sense command failed selection due to a * reselection from another device. * 07/14/90 mitch mcconnell v00.00.32 * a. Newest attempt to fix RDAT problem. When a select failed due * to being reselected, the code essentially restarted the entire * command by setting state/event back to begin/cont. If the * command which failed was a RQSNS, the "restart" would cause * the drive to send the next data record, and the RQSNS info * was lost. The fix is to use the pxstate field in the softc * (as the Vax code does) to store the state to return to in * this situation. * b. Changed retry states to RETRY_CMD and RETRY_SNS. * * * 07/14/90 mitch mcconnell v00.00.31 * a. Reset chip values for req/ack offset as soon as they are * renegotiated. (on hold...) * b. Removed poll mode for RQSNS. Now will be handled in state * machine in scsi.c. Fix for RDAT reselect timeout problem. * * 06/06/90 Bill Dallas * In asc_startdma() got rid of hard define of SZ_RQSNS_LEN. * Used scsi command packet for the lenght. * * 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. * * 03/01/90 Janet Schank * Added retries on busy target in the probe routine. * * 01/18/90 Mitchell McConnell v00.00.30 * a. Fixed bug in asc_scsistart for "INTP not set", where printing * SCSI cdb was not incrementing a pointer. (Only if SZDEBUG on). * b. Recompiled everything to make sure SZDEBUG off works. * * 12/22/89 Mitchell McConnell v00.00.29 * a. Checkpoint version. * b. Added more debug tools for rz56 problem. * c. Re-compile with temporary rz56 "fix" - set req/ack offset to 7. * * 12/20/89 Mitchell McConnell v00.00.28 * a. Made the cnf1,2, & 3 registers variables. Now set cnf3 to * use the 8 byte threshhold for data phase transfers. * b. Now set up sync offset and sync per registers even for * Select W/O ATN, since this mode is used for the Request * Sense after a Check Condition. * c. Fixed bug in asc_busy_target - was hard-coded for a single * controller. * * 12/14/89 Mitchell McConnell v00.00.27 * o Made the sync. xfer per. and req/ack variables which can be * set via xkvar. * o Removed asc_was_reset as redundant. * o In asc_reset_disc..., added test for sc_attached after checking * sc_alive. * o In asc_dumpregs, use the stored version of sr,isr, and ssr * registers, since re-reading the chip may give misleading results. * * 12/11/89 Mitchell McConnell v00.00.26 * o Moved call to asc_reset_discon_io_tasks to asc_reset() as it * is in PMAX. Because of this, we were not recovering properly * from parity errors. * * 12/08/89 Mitchell McConnell v00.00.25 * o Changed parameter for get_sys_ptes from hard-coded 130 * to btoc(64k) + 2. (per Fred Canter). * o Now use sc_oddbyte as a flag sc_no_disconnects to allow a * particular target to run without disconnecting. * * 12/06/89 Mitchell McConnell v00.00.24 * o Statistics were not getting updated because the 53C94 select & * transfer command bypassed asc_sendcmd. Now collect them in * ascintr (yecchh!) when we know the select & transfer completed * succesfully. * * 12/01/89 Mitchell McConnell v00.00.23 * o Another attempt to fix RQSNS problem. While attempting to select * a target for the RQSNS, we were reselected by a different target. * This made things go quite haywire. Fix is to not reenable selection * for the 53C94 chip when we get a status of CHECK CONDITION. * * 11/29/89 Mitchell McConnell v00.00.22 * o Hack fix for state machine problem with RQSNS - now we will treat * sc_actcmd as a polled command and not return until finished. See * additional comments in asc_scsistart. * * 11/08/89 Mitchell McConnell v00.00.21 * o Checkpoint version. * o Added ifdef'ed test statements for error logging. * * 11/03/89 Mitchell McConnell v00.00.20 * o Merged with ISIS pool. * * 10/31/89 Mitchell McConnell v00.00.19 * o a. Add controller to some PRINTD's to debug multiple controllers. * o Added #defines to compensate for hard-coded references to sii * in softc, e.g., sc_ascnum is really sc_siinum, (the controller * number). * o Replaced large amount of asc_probe to be consistent with vax/pmax. * No longer call routine asc_dodev. * o Added call to get_scsiid for host adapter id. * * 10/25/89 Mitchell McConnell v00.00.18 * o a. Fixed bug in asc_data_intr. Only call restartdma if the * current phase is still DATAI/DATAO, else asc_phase_change * will handle it. * b. Adjust asc_dboff_len in asc_data_intr. It used to be done * in asc_msgin when SDP was received. * c. Put in print_sense routine as a PRINTD for SCSID_CMD_EXP. * * 10/23/89 Mitchell McConnell v00.00.17 * o a. Checkpoint. Fixed several bugs working on new DMA code. * o b. Fixed mixup between fstate values (SZ_DATAO_PHA, etc.) and * SCSI phase (SCS_DATAO). * o c. Removed calls to asc_getactive_target. Made inline code for * ascintr, elsewhere it is passed as an argument. * o d. Moved get of savcnt from SDP to MESSI. By the time we know * we have SDP, the TC is always zero, since we use DMA for * message bytes. * o e. Moved setting of DMA_DISC flag to SDP message. PMAX driver * makes assumption that DISC will always follow SDP, AND polls * for it anyway. Because we handle each message byte individually, * the test for prevpha == DATAI/DATAO does not work. * * 10/20/89 Mitchell McConnell v00.00.16 * o a. Fairly radical changes to ascintr DMA handling to more exactly * imitate PMAX SII. * o b. Make test for phase mismatch (BS || FC) && (PHASE(sr) != fstate). * o c. Moved data phase handling to new routine asc_data_intr(). * * 10/19/89 Mitchell McConnell v00.00.15 * o a. Checkpoint. Flush FIFO fix for 14 (what alliteration!) appears * to have worked. * o b. In ascintr, try and simultate the SII_MIS (phase mismatch) code. * Instead of BS || FC, now test for BS && (current phase != fstate). * * 10/17/89 Mitchell McConnell v00.00.14 * o Checkpoint version. Both dskx and mtx running simultaneously. * o Added support to print sense information for debugging. * o Removed flush fifo at data out phase. * * 10/17/89 Mitchell McConnell v00.00.13 * o Added check for !RSEL in state_change. More printfs to find * out why reselect is not working. * o Removed call to sz_start for reselect case. Should get restarted * when the reselecting target finishes and disconnects. * o Check for scsi_bus_idle in scsistart. If not idle, return * BUSBUSY. Removed setting scsi_bus_idle to 0 for BUSY and * command complete cases in ascintr. * o When reselected, reset the synchronous offset and period registers * for the appropriate values for that target. * * 10/13/89 Mitchell McConnell v00.00.12 * o Fixed bug that kept disconnect/reconnect from working! * Initialization sc did not occur because asc_nNASC was equal to * 4. * * 10/11/89 Mitchell McConnell v00.00.11 * o Checkpoint version. Putting printfs in start to find out why * bpcount = 0 when starting DMA. * o Fixed asc_state_change to recognize reselection during selection. * Must reset state of target which was selecting to Bus Busy so it * will retry later. Also, must set sc_active to the new target id! * * 10/09/89 Mitchell McConnell v00.00.10 * o Fixed bug for synchronous data transfer. NEVER issue Flush * FIFO when the phase = sync. data in. * o Fixed bug in ascintr- when checking for state change, used * wrong mnemonic for testing the RESELECT bit in the isr. * * 10/03/89 Mitchell McConnell v00.00.09 * o Several misc. bug fixes, esp. invalid use of GETCNTR macro * in asc_ext_messg. * o Added call to prom_getenv for scsiid of controller. * o Began adding support for scsi_logerr (with ifdefs) in * place of mprintf's. Before release, the mprintfs will * go away, leaving only the error logging. Changed calls * to asc_dumpregs to use 'who' parameter, since scsi_logerr * also calls it. * * 09/28/89 Mitchell McConnell v00.00.08 * o Newest attempt at handling extended messages. Initially, * always DMA one message byte. If it is an extended message, * set the EXTMESSG flag in szflags. Issue the MSGACPT * command and return. If the last command was MSGACPT, * issue a DMA XINFO command to get the length byte. * At the next interrupt, if the EXTMESSG flag is already * set and the last command was DMA XINFO, save the length * byte and issue MSGACPT. If the last command was MSGACPT, * issue a DMA XINFO for the remaining bytes of the extended * message. The next interrupt should be FC and (msg in?). * Check the Transfer Count register. If > 1, copy the * remaining extended message bytes and go process the * message. Issue MSGACPT to release ACK. The next (and * final) interrupt should be BS with phase COMMAND. * * 09/26/89 Mitchell McConnell v00.00.07 * o Control version - first built under new "isis-sys" pool. * o Fixed bug in ascintr - used ASC_XINFO instead of * (ASC_DMA | ASC_XINFO). * * 09/21/89 Mitchell McConnell v00.00.06 * * o First version to support reads and writes. Attempt to keep * some rudimentary form of version control until placed under * SCCS. * * o Removed the 'attn' flag from asc_senddata, since it was not * being used, and anyway, the ASC will assert ATN when sending * bytes to the target during message out phase. * * 0 Give some more intelligence to asc_select_target to know * whether to issue the SELECT with or without ATN. For now, * just use the asc_sentsync (sp?) as a flag. This assumes that * the ONLY time we will need to do this is after a reset to * (re)set the synchronous parameters. * * o Try using DMA to send command ***********************************************************************/#define SZDEBUGchar asc_version[] = "ASC Version 00.00.32b";#define ASC_LOGERR 1 #define ASC_TEST_LOG 1#define ASCDEBUG 1 /************************************************************************//* WARNING! If the softc EVER changes, these defines need to be re-examined.*/#define sc_ascnum sc_siinum#define sc_ascsentsync sc_siisentsync#define sc_ascdmacount sc_siidmacount#define sc_ascreqack sc_siireqack#define sc_ascdboff sc_siidboff#define enable_sel_rsel use_programmed_io #define sc_no_disconnects sc_oddbyte#include "../data/scsi_data.c"#include "scsi_debug.h"#include "../../tc/tc.h"#include "pdma3min.h"#define MAXASC nNASCextern char szbufmap[];extern int scsidebug;extern short sz_timetable[];extern int cpu;int asc_wait_after_inquiry = 1000;int asc_sync_xfer_per = ASC_SYNC_XFER_PER;int asc_sync_xfer_reg = ASC_SYNC_XFER_REG;char asc_def_cnf1 = ASC_C1_PARITY;char asc_def_cnf2 = 0;char asc_def_cnf3 = 0; /* * Autoconfiguration information */extern u_short szstd[];int szslave(), szattach(), sz_start(), szerror(), ascprobe();struct uba_driver ascdriver = { ascprobe, szslave, szattach, sz_start, szstd, "rz", szdinfo, "asc", szminfo, 0 };int asc_busy_target(); /* for forward reference */short asc_wait_count = ASC_WAIT_COUNT; /* Delay count for ASC chip */short asc_reject_message = 0; /* Message Reject Flag */short asc_assert_attn = 0; /* Assert Attention Flag */short asc_nNASC = NASC; /* Number of ASC controllers*/short asc_firstcall = 1; /* First call to probe flag */#if ASC_TEST_LOGshort asc_tested_log = 1;#endif ASC_TEST_LOG/* * 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 asc_scsistart();extern int asc_reset();extern int tc_addr_to_name();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();/****************************************************************** * * Name: ascprobe * * Abstract: Probe for any SCSI devices on this controller. * Initialize any fields in the softc structure. For * each possible target: * o build SCSI Inquiry command * o call asc_scsistart() * o if command successful, * initialize target-specific data structures * allocate PTEs for buffer mapping * call szattach() * set up buffer for non-DMA commands * * Clear any pending interrupts for this controller. * * Inputs: * * cntrl - the controller number for this bus. * * Outputs: None. * * Return values: None. * ******************************************************************//* rpbfix: fake out the config process */extern int cpu;ascprobe(vbaddr, um) volatile char *vbaddr; /* base address for this option slot */register struct uba_ctlr *um;{ ASC_REG *ascaddr; /* pointer for the ASC registers */ int targid, unit; int dboff; int rz_slotsize, tz_slotsize, cz_slotsize; int i, s, stat; struct sz_inq_dt *idp; struct sz_rdcap_dt *rdp; struct scsi_devtab *sdp; struct scsi_devtab *usdp; int sdp_match; char *p; char *env; int alive; int retries, status; int cntlr = um->um_ctlr; register struct sz_softc *sc = &sz_softc[cntlr]; char modname[TC_ROMNAMLEN+1]; int opt_type=0; s = splbio(); alive = 1; /* On 3MAX asc is always present */ sc->ioasicp = 0; if ((cpu == DS_5000_100) && (cntlr == 0)) { sc->ioasicp = (char *) PHYS_TO_K1( BASE_IOASIC ); } /* * Initialize certain fields in the softc structure * and reset the ASC chip. */ if (alive) { sc->sc_ascnum = cntlr; /* save a pointer to the asc */ sc->sc_slotvaddr = vbaddr; /* init the base address */ sc->sc_sysid = get_scsiid(um->um_ctlr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -