diff options
| author | Stefan Eßer <se@FreeBSD.org> | 1994-09-28 20:16:45 +0000 |
|---|---|---|
| committer | Stefan Eßer <se@FreeBSD.org> | 1994-09-28 20:16:45 +0000 |
| commit | 92a25df797ae42414471ecb68a19fed2e01b019b (patch) | |
| tree | 41b29e7b116b21a3f34c2d8f5a5b3e06ebe20f1d | |
| parent | 92cbac681e6808b513dd02e35513afd2ef4611e5 (diff) | |
Notes
| -rw-r--r-- | sys/scsi/scsi_tape.h | 4 | ||||
| -rw-r--r-- | sys/scsi/scsiconf.c | 218 | ||||
| -rw-r--r-- | sys/scsi/scsiconf.h | 111 | ||||
| -rw-r--r-- | sys/scsi/sd.c | 8 | ||||
| -rw-r--r-- | sys/scsi/st.c | 36 |
5 files changed, 361 insertions, 16 deletions
diff --git a/sys/scsi/scsi_tape.h b/sys/scsi/scsi_tape.h index ac417c2680ce0..920a7816ae3dc 100644 --- a/sys/scsi/scsi_tape.h +++ b/sys/scsi/scsi_tape.h @@ -21,7 +21,7 @@ /* * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 * - * $Id: scsi_tape.h,v 1.8 93/08/31 21:40:16 julian Exp Locker: julian $ + * $Id: scsi_tape.h,v 1.8 1993/11/18 05:02:57 rgrimes Exp $ */ #ifndef SCSI_SCSI_TAPE_H #define SCSI_SCSI_TAPE_H 1 @@ -140,6 +140,7 @@ struct blk_desc_cipher +#ifndef NEW_SCSICONF /********************************************************************** from the scsi2 spec Value Tracks Density(bpi) Code Type Reference Note @@ -200,5 +201,6 @@ struct blk_desc_cipher #define QIC_1320 0x12 #define DDS 0x13 #define DAT_1 0x13 +#endif /* NEW_SCSICONF */ #endif /*SCSI_SCSI_TAPE_H*/ diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 9e2dfef7cd48f..d61bdb114792a 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -14,7 +14,7 @@ * * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 * - * $Id: scsiconf.c,v 1.7 1993/11/18 05:02:58 rgrimes Exp $ + * $Id: scsiconf.c,v 1.8 1993/12/19 00:54:54 wollman Exp $ */ #include <sys/types.h> @@ -120,19 +120,149 @@ struct scsidevs { errval(*attach_rtn) (); char *devname; char flags; /* 1 show my comparisons during boot(debug) */ +#ifdef NEW_SCSICONF + u_int16 quirks; + void *devmodes; +#endif }; #define SC_SHOWME 0x01 #define SC_ONE_LU 0x00 #define SC_MORE_LUS 0x02 -#if NUK > 0 -static struct scsidevs unknowndev = { - -1, 0, "standard", "any" - ,"any", ukattach, "uk", SC_MORE_LUS -}; +#if NUK > 0 +static struct scsidevs unknowndev = + { + -1, 0, "*", "*", "*", + ukattach, "uk", SC_MORE_LUS + }; #endif /*NUK*/ + +#ifdef NEW_SCSICONF +static st_modes mode_tandberg3600 = + { + {0, 0, 0}, /* minor 0,1,2,3 */ + {0, ST_Q_FORCE_VAR_MODE, QIC_525}, /* minor 4,5,6,7 */ + {0, 0, QIC_150}, /* minor 8,9,10,11 */ + {0, 0, QIC_120} /* minor 12,13,14,15 */ + }; +static st_modes mode_archive2525 = + { + {0, ST_Q_SNS_HLP, 0}, /* minor 0,1,2,3 */ + {0, ST_Q_SNS_HLP, QIC_525}, /* minor 4,5,6,7 */ + {0, 0, QIC_150}, /* minor 8,9,10,11 */ + {0, 0, QIC_120} /* minor 12,13,14,15 */ + }; +static st_modes mode_archive150 = + { + {0, 0, 0}, /* minor 0,1,2,3 */ + {0, 0, QIC_150}, /* minor 4,5,6,7 */ + {0, 0, QIC_120}, /* minor 8,9,10,11 */ + {0, 0, QIC_24} /* minor 12,13,14,15 */ + }; +static st_modes mode_wangtek5525 = + { + {0, 0, 0}, /* minor 0,1,2,3 */ + {0, ST_Q_BLKSIZ, QIC_525}, /* minor 4,5,6,7 */ + {0, 0, QIC_150}, /* minor 8,9,10,11 */ + {0, 0, QIC_120} /* minor 12,13,14,15 */ + }; +static st_modes mode_wangdat1300 = + { + {0, 0, 0}, /* minor 0,1,2,3 */ + {512, ST_Q_FORCE_FIXED_MODE, DDS}, /* minor 4,5,6,7 */ + {1024, ST_Q_FORCE_FIXED_MODE, DDS}, /* minor 8,9,10,11 */ + {0, ST_Q_FORCE_VAR_MODE, DDS} /* minor 12,13,14,15 */ + }; +static st_modes mode_unktape = + { + {512, ST_Q_FORCE_FIXED_MODE, 0}, /* minor 0,1,2,3 */ + {512, ST_Q_FORCE_FIXED_MODE, QIC_24}, /* minor 4,5,6,7 */ + {0, ST_Q_FORCE_VAR_MODE, HALFINCH_1600}, /* minor 8,9,10,11 */ + {0, ST_Q_FORCE_VAR_MODE, HALFINCH_6250} /* minor 12,13,14,15 */ + }; +#endif /* NEW_SCSICONF */ + static struct scsidevs knowndevs[] = +#ifdef NEW_SCSICONF +{ +#if NSD > 0 + { + T_DIRECT, T_FIXED, "MAXTOR", "XT-4170S", "B5A", + sdattach, "mx1", SC_ONE_LU + }, + { + T_DIRECT, T_FIXED, "*", "*", "*", + sdattach, "sd", SC_ONE_LU + }, +#endif /* NSD */ +#if NST > 0 + { + T_SEQUENTIAL, T_REMOV, "TANDBERG", " TDC 3600", "*", + stattach, "st", SC_ONE_LU, ST_Q_NEEDS_PAGE_0, mode_tandberg3600 + }, + { + T_SEQUENTIAL, T_REMOV, "ARCHIVE", "VIPER 2525*", "-005", + stattach, "st", SC_ONE_LU, 0, mode_archive2525 + }, + { + T_SEQUENTIAL, T_REMOV, "ARCHIVE", "VIPER 150", "*", + stattach, "st", SC_ONE_LU, ST_Q_NEEDS_PAGE_0, mode_archive150 + }, + { + T_SEQUENTIAL, T_REMOV, "WANGTEK", "5525ES*", "*", + stattach, "st", SC_ONE_LU, 0, mode_wangtek5525 + }, + { + T_SEQUENTIAL, T_REMOV, "WangDAT", "Model 1300", "*", + stattach, "st", SC_ONE_LU, 0, mode_wangdat1300 + }, + { + T_SEQUENTIAL, T_REMOV, "*", "*", "*", + stattach, "st", SC_ONE_LU, 0, mode_unktape + }, +#endif /* NST */ +#if NCALS > 0 + { + T_PROCESSOR, T_FIXED, "*", "*", "*", + calsattach, "cals", SC_MORE_LUS + }, +#endif /* NCALS */ +#if NCH > 0 + { + T_CHANGER, T_REMOV, "*", "*", "*", + chattach, "ch", SC_ONE_LU + }, +#endif /* NCH */ +#if NCD > 0 +#ifndef UKTEST /* make cdroms unrecognised to test the uk driver */ + { + T_READONLY, T_REMOV, "SONY", "CD-ROM CDU-8012", "3.1a", + cdattach, "cd", SC_ONE_LU + }, + { + T_READONLY, T_REMOV, "PIONEER", "CD-ROM DRM-600", "*", + cdattach, "cd", SC_MORE_LUS + }, +#endif +#endif /* NCD */ +#if NBLL > 0 + { + T_PROCESSOR, T_FIXED, "AEG", "READER", "V1.0", + bllattach, "bll", SC_MORE_LUS + }, +#endif /* NBLL */ +#if NKIL > 0 + { + T_SCANNER, T_FIXED, "KODAK", "IL Scanner 900", "*", + kil_attach, "kil", SC_ONE_LU + }, +#endif /* NKIL */ + { + 0 + } +}; +#else { #if NSD > 0 { @@ -191,6 +321,7 @@ static struct scsidevs knowndevs[] = 0 } }; +#endif /* NEW_SCSICONF */ /* * Declarations @@ -244,7 +375,9 @@ scsi_attachdevs(sc_link_proto) #undef SCSI_DELAY #define SCSI_DELAY 2 #endif /* SCSI_DELAY */ - DELAY(1000000 * SCSI_DELAY); + if (scsibus == 0) { + DELAY(1000000 * SCSI_DELAY); + } scsibus++; scsi_probe_bus(scsibus - 1,-1,-1); } @@ -334,8 +467,18 @@ scsi_probe_bus(int bus, int targ, int lun) } sc_link->target = targ; sc_link->lun = lun; + sc_link->quirks = 0; predef = scsi_get_predef(sc_link, &maybe_more); bestmatch = scsi_probedev(sc_link, &maybe_more); +#ifdef NEW_SCSICONF + if (bestmatch) { + sc_link->quirks = bestmatch->quirks; + sc_link->devmodes = bestmatch->devmodes; + } else { + sc_link->quirks = 0; + sc_link->devmodes = NULL; + } +#endif if ((bestmatch) && (predef)) { /* both exist */ if (bestmatch->attach_rtn != predef->attach_rtn) { @@ -624,6 +767,32 @@ scsi_probedev(sc_link, maybe_more) } return (bestmatch); } + +#ifdef NEW_SCSICONF +/* + * Compare name with pattern, return 0 on match. + * Short pattern matches trailing blanks in name, + * wildcard '*' in pattern matches rest of name + */ +int +match(pattern, name) + char *pattern; + char *name; +{ + char c; + while (c = *pattern++) + { + if (c == '*') return 0; + if (c != *name++) return 1; + } + while (c = *name++) + { + if (c != ' ') return 1; + } + return 0; +} +#endif + /* * Try make as good a match as possible with * available sub drivers @@ -634,6 +803,40 @@ selectdev(qualifier, type, remov, manu, model, rev) boolean remov; char *manu, *model, *rev; { +#ifdef NEW_SCSICONF + struct scsidevs *bestmatch = NULL; + struct scsidevs *thisentry; + + type |= qualifier; /* why? */ + + for ( thisentry = knowndevs; thisentry->manufacturer; thisentry++ ) + { + if (type != thisentry->type) { + continue; + } + if (remov != thisentry->removable) { + continue; + } + + if (thisentry->flags & SC_SHOWME) + printf("\n%s-\n%s-", thisentry->manufacturer, manu); + if (match(thisentry->manufacturer, manu)) { + continue; + } + if (thisentry->flags & SC_SHOWME) + printf("\n%s-\n%s-", thisentry->model, model); + if (match(thisentry->model, model)) { + continue; + } + if (thisentry->flags & SC_SHOWME) + printf("\n%s-\n%s-", thisentry->version, rev); + if (match(thisentry->version, rev)) { + continue; + } + bestmatch = thisentry; + break; + } +#else u_int32 numents = (sizeof(knowndevs) / sizeof(struct scsidevs)) - 1; u_int32 count = 0; u_int32 bestmatches = 0; @@ -688,6 +891,7 @@ selectdev(qualifier, type, remov, manu, model, rev) break; } } +#endif /* NEW_SCSICONF */ if (bestmatch == (struct scsidevs *) 0) { #if NUK > 0 bestmatch = &unknowndev; diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h index f3f9586118dbb..50b1657539ac9 100644 --- a/sys/scsi/scsiconf.h +++ b/sys/scsi/scsiconf.h @@ -14,7 +14,7 @@ * * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 * - * $Id: scsiconf.h,v 1.8 1993/12/19 00:54:55 wollman Exp $ + * $Id: scsiconf.h,v 1.9 1994/03/23 09:15:55 davidg Exp $ */ #ifndef SCSI_SCSICONF_H #define SCSI_SCSICONF_H 1 @@ -107,6 +107,48 @@ struct scsi_device /* 32*/ int32 spare[2]; }; +#ifdef NEW_SCSICONF +/* + * Define various devices that we know mis-behave in some way, + * and note how they are bad, so we can correct for them + */ +struct st_mode { +/* 4*/ u_int32 blksiz; +/* 6*/ u_int16 quirks; /* same definitions as in XXX */ +/* 7*/ char density; +/* 8*/ char spare[1]; +}; + +typedef struct st_mode st_modes[4]; + +/* define behaviour codes (quirks) */ +/* common to all SCSI devices */ +#define SCSI_Q_NO_SYNC 0x8000 +#define SCSI_Q_NO_FAST 0x4000 +#define SCSI_Q_NO_WIDE 0x2000 + +/* tape specific ST_Q_* */ +#define ST_Q_NEEDS_PAGE_0 0x0001 +#define ST_Q_FORCE_FIXED_MODE 0x0002 +#define ST_Q_FORCE_VAR_MODE 0x0004 +#define ST_Q_SNS_HLP 0x0008 /* must do READ for good MODE SENSE */ +#define ST_Q_IGNORE_LOADS 0x0010 +#define ST_Q_BLKSIZ 0x0020 /* variable-block media_blksiz > 0 */ +#define ST_Q_CC_NOMSG 0x0040 /* no messages accepted in CC state */ + +#define ST_Q_NO_SYNC SCSI_Q_NO_SYNC +#define ST_Q_NO_FAST SCSI_Q_NO_FAST +#define ST_Q_NO_WIDE SCSI_Q_NO_WIDE + +/* disk specific SD_Q_* */ +#define SD_Q_NO_TAGS 0x0001 + +#define SD_Q_NO_SYNC SCSI_Q_NO_SYNC +#define SD_Q_NO_FAST SCSI_Q_NO_FAST +#define SD_Q_NO_WIDE SCSI_Q_NO_WIDE + +#endif + /* * This structure describes the connection between an adapter driver and * a device driver, and is used by each to call services provided by @@ -124,12 +166,12 @@ struct scsi_link /* 7*/ u_int8 opennings; /* available operations */ /* 8*/ u_int8 active; /* operations in progress */ /* 10*/ u_int16 flags; /* flags that all devices have */ -/* 12*/ u_int8 spareb[2]; /* unused */ +/* 12*/ u_int16 quirks; /* device specific quirks */ /* 16*/ struct scsi_adapter *adapter; /* adapter entry points etc. */ /* 20*/ struct scsi_device *device; /* device entry points etc. */ /* 24*/ struct scsi_xfer *active_xs; /* operations under way */ /* 28*/ void * fordriver; /* for private use by the driver */ -/* 32*/ u_int32 spare; +/* 32*/ void * devmodes; /* device specific mode tables */ }; #define SDEV_MEDIA_LOADED 0x01 /* device figures are still valid */ #define SDEV_WAITING 0x02 /* a process is waiting for this */ @@ -245,5 +287,68 @@ int _3btol __P((u_char *bytes)); extern void sc_print_addr(struct scsi_link *); +#ifdef NEW_SCSICONF +/********************************************************************** + from the scsi2 spec + Value Tracks Density(bpi) Code Type Reference Note + 0x1 9 800 NRZI R X3.22-1983 2 + 0x2 9 1600 PE R X3.39-1986 2 + 0x3 9 6250 GCR R X3.54-1986 2 + 0x5 4/9 8000 GCR C X3.136-1986 1 + 0x6 9 3200 PE R X3.157-1987 2 + 0x7 4 6400 IMFM C X3.116-1986 1 + 0x8 4 8000 GCR CS X3.158-1986 1 + 0x9 18 37871 GCR C X3B5/87-099 2 + 0xA 22 6667 MFM C X3B5/86-199 1 + 0xB 4 1600 PE C X3.56-1986 1 + 0xC 24 12690 GCR C HI-TC1 1,5 + 0xD 24 25380 GCR C HI-TC2 1,5 + 0xF 15 10000 GCR C QIC-120 1,5 + 0x10 18 10000 GCR C QIC-150 1,5 + 0x11 26 16000 GCR C QIC-320(525?) 1,5 + 0x12 30 51667 RLL C QIC-1350 1,5 + 0x13 1 61000 DDS CS X3B5/88-185A 4 + 0x14 1 43245 RLL CS X3.202-1991 4 + 0x15 1 45434 RLL CS ECMA TC17 4 + 0x16 48 10000 MFM C X3.193-1990 1 + 0x17 48 42500 MFM C X3B5/91-174 1 + + where Code means: + NRZI Non Return to Zero, change on ones + GCR Group Code Recording + PE Phase Encoded + IMFM Inverted Modified Frequency Modulation + MFM Modified Frequency Modulation + DDS Dat Data Storage + RLL Run Length Encoding + + where Type means: + R Real-to-Real + C Cartridge + CS cassette + + where Notes means: + 1 Serial Recorded + 2 Parallel Recorded + 3 Old format know as QIC-11 + 4 Helical Scan + 5 Not ANSI standard, rather industry standard. + +********************************************************************/ + +#define HALFINCH_800 0x01 +#define HALFINCH_1600 0x02 +#define HALFINCH_6250 0x03 +#define QIC_11 0x04 /* from Archive 150S Theory of Op. XXX */ +#define QIC_24 0x05 /* may be bad, works for CIPHER ST150S XXX */ +#define QIC_120 0x0f +#define QIC_150 0x10 +#define QIC_320 0x11 +#define QIC_525 0x11 +#define QIC_1320 0x12 +#define DDS 0x13 +#define DAT_1 0x13 +#endif /* NEW_SCSICONF */ + #endif /*SCSI_SCSICONF_H*/ /* END OF FILE */ diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 2ca82014cc0fc..5a4429ac50279 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -14,7 +14,7 @@ * * Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992 * - * $Id: sd.c,v 1.29 1994/08/31 06:17:45 davidg Exp $ + * $Id: sd.c,v 1.30 1994/09/02 04:12:23 davidg Exp $ */ #define SPLSD splbio @@ -524,7 +524,11 @@ sdstart(unit) */ p = sd->disklabel.d_partitions + PARTITION(bp->b_dev); blkno = bp->b_blkno + p->p_offset; - nblk = (bp->b_bcount + 511) >> 9; + if (bp->b_bcount & 511) + { + goto bad; + } + nblk = bp->b_bcount >> 9; /* * Fill out the scsi command diff --git a/sys/scsi/st.c b/sys/scsi/st.c index 4ecbe23f98953..74733a4f931cb 100644 --- a/sys/scsi/st.c +++ b/sys/scsi/st.c @@ -12,7 +12,7 @@ * on the understanding that TFS is not responsible for the correct * functioning of this software in any circumstances. * - * $Id: st.c,v 1.17 1994/08/02 07:52:34 davidg Exp $ + * $Id: st.c,v 1.18 1994/08/31 06:17:49 davidg Exp $ */ /* @@ -61,6 +61,7 @@ u_int32 ststrats, stqueues; #define SCSI_2_MAX_DENSITY_CODE 0x17 /* maximum density code specified * in SCSI II spec. */ +#ifndef NEW_SCSICONF /* * Define various devices that we know mis-behave in some way, * and note how they are bad, so we can correct for them @@ -147,6 +148,7 @@ static struct rogues gallery[] = /* ends with an all-null entry */ }, {(char *) 0} }; +#endif /* NEW_SCSICONF */ errval st_space __P((u_int32 unit, int32 number, u_int32 what, u_int32 flags)); errval st_rewind __P((u_int32 unit, boolean immed, u_int32 flags)); @@ -165,7 +167,9 @@ void ststart(); void st_unmount(); errval st_mount_tape(); void st_loadquirks(); +#ifndef NEW_SCSICONF void st_identify_drive(); +#endif errval st_interpret_sense(); #define ESUCCESS 0 @@ -195,7 +199,9 @@ struct st_data { /*--------------------parameters reported by the device ----------------------*/ u_int32 blkmin; /* min blk size */ u_int32 blkmax; /* max blk size */ +#ifndef NEW_SCSICONF struct rogues *rogues; /* if we have a rogue entry */ +#endif /*--------------------parameters reported by the device for this media--------*/ u_int32 numblks; /* nominal blocks capacity */ u_int32 media_blksiz; /* 0 if not ST_FIXEDBLOCKS */ @@ -203,7 +209,11 @@ struct st_data { /*--------------------quirks for the whole drive------------------------------*/ u_int32 drive_quirks; /* quirks of this drive */ /*--------------------How we should set up when openning each minor device----*/ +#ifdef NEW_SCSICONF + st_modes modes; /* plus more for each mode */ +#else struct modes modes[4]; /* plus more for each mode */ +#endif u_int8 modeflags[4]; /* flags for the modes */ #define DENSITY_SET_BY_USER 0x01 #define DENSITY_SET_BY_QUIRK 0x02 @@ -286,12 +296,17 @@ stattach(sc_link) */ st->sc_link = sc_link; + + /* * Check if the drive is a known criminal and take * Any steps needed to bring it into line */ +#ifdef NEW_SCSICONF + st_loadquirks(st); +#else st_identify_drive(unit); - +#endif /* * Use the subdriver to request information regarding * the drive. We cannot use interrupts yet, so the @@ -321,6 +336,7 @@ stattach(sc_link) return 0; } +#ifndef NEW_SCSICONF /* * Use the inquiry routine in 'scsi_base' to get drive info so we can * Further tailor our behaviour. @@ -395,6 +411,7 @@ st_identify_drive(unit) } } } +#endif /* NEW_SCSICONF */ /* * initialise the subdevices to the default (QUIRK) state. @@ -406,15 +423,28 @@ st_loadquirks(st) struct st_data *st; { int i; +#ifdef NEW_SCSICONF + struct st_mode *mode; + struct st_mode *mode2; + + mode = (struct st_mode*) st->sc_link->devmodes; + if (!mode) + return; + + st->quirks = st->drive_quirks = st->sc_link->quirks; + +#else struct modes *mode; struct modes *mode2; if (!st->rogues) return; mode = st->rogues->modes; +#endif mode2 = st->modes; + for (i = 0; i < 4; i++) { - bzero(mode2, sizeof(struct modes)); + bzero(mode2, sizeof(*mode2)); st->modeflags[i] &= ~(BLKSIZE_SET_BY_QUIRK | DENSITY_SET_BY_QUIRK | BLKSIZE_SET_BY_USER |
