freebsd-src/sys/scsi
Bill Paul fc7c79b907 Make the SCSI probe messages more BSDish. This may raise a few eyebrows
("Hey! Who made _you_ the keeper of all things BSDish?!") but this has
bugged me for a long time, and now that I finally have the chance
to hack on it (and test the results), I'll take my chances. I can also
point to other BSD implementations for precedents if you put my back to
the wall.

The only thing that's changed is how the messages are formatted. Now,
instead of having this:

aha0 at 0x330-0x333 irq 11 drq 5 on isa
(aha0:3:0): "HP C1553A 9503" type 1 removable SCSI 2
st0(aha0:3:0): Sequential-Access density code 0x24, variable blocks, write-enabled
(aha0:3:1): "HP C1553A 9503" type 8 removable SCSI 2
ch0(aha0:3:1): Medium-Changer 6 slot(s) 1 drive(s) 0 arm(s) 0 i/e-slot(s)

We have this:

aha0 at 0x330-0x333 irq 11 drq 5 on isa
scbus0 at aha0 bus 0
st0 at scbus0 target 3 lun 0
st0: <HP C1553A 9503> type 1 removable SCSI 2
st0: Sequential-Access density code 0x24, variable blocks, write-enabled
ch0 at scbus0 target 3 lun 1
ch0: <HP C1553A 9503> type 8 removable SCSI 2
ch0: Medium-Changer 6 slot(s) 1 drive(s) 0 arm(s) 0 i/e-slot(s)

Which is (to me anyway) is a lot more pleasant to look at. (Call me
crazy -- g'head: you know you wanna -- but the previous messages remind
me of Linux. Ever see the output from the linux device probes? It's a mess
of copyright notices, version numbers/dates, author e-mail addresses and
other crap. Let's not go there, okay? Bleh.)

Notice that devices are now specified in terms of the scsi bus they
live on rather than the adapter. This better reflects the contents
of the kernel config file (if you use wired-down device specifications
anyway) and removes some ambiguity that may arise if you have a multi-
channel adapter with more than one bus.

Also, sc_print_addr() now generates messages like this:
st0 at scbus0 target 3 lun 0: NOT READY asc:3a,0 Medium not present

instead of this:
st0(aha0:3:0): NOT READY asc:3a,0 Medium not present

I also added a quirk entry for the HP Superstore 12000e 6 tape DAT
autoloader, which needs SC_MORE_LUS in order for the changer device
to be properly probed and attached. (I'm working on a chcontrol utility
to manipulate the changer on this drive which should hopefully be general
enough to work with other changers too. If you want the prototype I have
now, it's at ftp://skynet.ctr.columbia.edu/pub/freebsd/changer.c.)

Remaining bugs:

- The 'foodev0: yadda yadda yadda' bits should probably be printed entirely
  by the device-specific subdriver attach code instead of half by the
  scsi_device_attach() routine and half by the device specific attach
  routine like it is now.

- The wired-down device specifications in the kernel config file should
  be used to control bus/device probing to some extent rather than just
  for choosing names for devices we find. If the config says there's a
  device at scbus0 target 0 lun 0 called sd0, we should look there and
  check for a device that can be managed by the sd driver. If we don't
  find one, we should probably complain that there's no device there or
  that there is a device but of the wrong type. Once all the devices from
  the wired down list have been probed, the code can then autodetect and
  autoattach any devices that remain unassigned.

- Apparently some tape changers (hi Ulf!) return 'not ready/medium not
  present' when the magazine is loaded but a tape has not been put in the
  drive yet. This causes an open(/dev/ch0) to fail and prevents you from
  using the changer.c utility to load the first tape into the drive. My
  HP changer does not behave this way. The workaround is to manually load
  a tape into the drive before attempting to use the changer program, but
  you can get in trouble if you accidentally eject a tape without loading
  a new one and you're at a remote location: you won't be able to load
  any tapes anymore. I'm not sure what the correct software solution is
  for this but ideally there should be one.

- I should not be doing this: I'm the NIS guru, not the SCSI guru.
  (This is not my beautiful code. How did I get here? My god: what
  have I done?)
1997-01-25 20:27:13 +00:00
..
cd.c Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
ch.c Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
od.c Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
pt.c Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
README Reviewed by: gibbs@freefall.cdrom.com julian@freefall.cdrom.com 1995-03-01 22:24:47 +00:00
scsi_all.h Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
scsi_base.c Make the SCSI probe messages more BSDish. This may raise a few eyebrows 1997-01-25 20:27:13 +00:00
scsi_cd.h Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
scsi_changer.h Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
scsi_debug.h Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
scsi_disk.h Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
scsi_driver.c Make the SCSI probe messages more BSDish. This may raise a few eyebrows 1997-01-25 20:27:13 +00:00
scsi_driver.h Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
scsi_generic.h Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
scsi_ioctl.c Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
scsi_message.h Try number two. Add missing paren in MSG_IDENTIFY macro. 1996-10-07 03:53:43 +00:00
scsi_sense.c Don't depend on <sys/types.h> including <sys/cdefs.h>. 1996-04-19 17:39:57 +00:00
scsi_tape.h Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
scsi_worm.h The Great Merge. 1996-01-27 17:48:12 +00:00
scsiconf.c Make the SCSI probe messages more BSDish. This may raise a few eyebrows 1997-01-25 20:27:13 +00:00
scsiconf.h Make the SCSI probe messages more BSDish. This may raise a few eyebrows 1997-01-25 20:27:13 +00:00
sctarg.c Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
sd.c Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
ssc.c Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
st.c Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
su.c Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
uk.c Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00
worm.c Make the long-awaited change from $Id$ to $FreeBSD$ 1997-01-14 07:20:47 +00:00

WARNING: This file was not fully updated by dufault@hda.com when
changing the configuration.  See the end for new notes.

This release consists of the following files 
(relative to the base of the source tree )

share/man/man4/scsi.4 <-useful general info
share/man/man4/uk.4
share/man/man4/su.4
share/man/man4/ch.4
share/man/man4/cd.4
share/man/man4/sd.4
share/man/man4/st.4 <--READ THIS IF YOU USE TAPES!
sbin/scsi/procargs.c
sbin/scsi/scsi.c
sbin/scsi/scsi.1
sbin/scsi/Makefile
sbin/st/Makefile
sbin/st/st.1
sbin/st/st.c
sys/sys/chio.h
sys/sys/cdio.h
sys/sys/mtio.h
sys/sys/scsiio.h
sys/i386/conf/EXAMPLE
sys/i386/isa/ultra14f.c <-runs 14f and 34f
sys/i386/isa/ultra_all.c.beta <-beta version, runs 14f,24f and 34f
sys/i386/isa/bt742a.c
sys/i386/isa/aha1742.c
sys/i386/isa/aha1542.c
sys/scsi/syspatches
sys/scsi/syspatches/conf.c
sys/scsi/syspatches/user_scsi.diffs
sys/scsi/syspatches/MAKEDEV.diff
sys/scsi/syspatches/isa.c.patch
sys/scsi/syspatches/README
sys/scsi/uk.c
sys/scsi/su.c
sys/scsi/st.c
sys/scsi/sd.c
sys/scsi/ch.c
sys/scsi/cd.c
sys/scsi/scsi_ioctl.c
sys/scsi/scsi_base.c
sys/scsi/scsiconf.c
sys/scsi/scsi_tape.h
sys/scsi/scsi_disk.h
sys/scsi/scsi_changer.h
sys/scsi/scsi_cd.h
sys/scsi/scsi_all.h
sys/scsi/scsi_debug.h
sys/scsi/scsiconf.h
sys/scsi/README <--this file

notice sys/scsi/sg.c and sys/sys/sgio.h have been removed


----------------------------------------------------------------
This scsi system is designed to allow the re-use of top end drivers
such as disk and tape drivers, with different scsi adapters.

As of writing this document, There are top end drivers working for:
----------------------------------------------------------------
generic scsi disk
generic scsi tape
cd-rom  (plays music under the xcplayer (?) program)
AEG Character recognition devices *
Calera Character recognition devices *
Generic scsi-II scanners *
Exabyte tape changer device.
GENERIC SCSI DEVICES (user generated scsi commands) 
----------------------------------------------------------------


There are also working bottom end drivers for:
----------------------------------------------------------------
adaptec 1542 (and 1742 in 1542 mode)
bustec 742a (apparently works for VESA version (445S?))(and 747?)
adaptec 174x  (note NOT 27xx)
Ultrastore 14f (works for 34f (VESA version))				
Ultrastore 24f RSN (Beta version included here)
----------------------------------------------------------------


################## Using the scsi system ##################
------------minor numbers---------------
This scsi system does not allocate minor numbers to devices depending
on their SCSI IDs is any way. A devices minor number is dependant
on the order in which it was found.
e.g. the first tape found will become st0 (minor number 0)
	the second found will become st1 (minor number 16)
	the third will become st2 (minor 32) 
	etc.

These devices could be on the same scsi bus or different scsi busses.
That would not change their minor numbers.

THE EXCEPTION  TO THIS IS IN THE GENERIC SCSI DRIVER. in which case
the following mapping applies:

BB TTT LLL  B= scsi bus number, T = target number, L = LUN.

It is possible to run two different TYPES of scsi adapters at the 
same time and have st0 on one and st1 on another. (for example)

There is a scheme supported in which scsi devices can be 'wired in' even
if they are not present or powered on at probe time. (see scsiconf.c)
In addition, the scsi(1) command allows the operator ask for a
reprobe at any time.  Newly found devices will be configured in. Any
device that does not map to a known device type is attached to the
'unknown' (uk) driver.


--------------making devices------------
A changed version of /dev/MAKEDEV is supplied that
can be used to make devices sd[01234] and st[01234]

e.g. 
cd /dev
sh MAKEDEV sd0 sd1 sd2 st0 st1 cd0

see st(1) and st(4) for info on tape devices.

--------------file layout-------------------
Originally I had all scsi definitions in one file: scsi.h
I have since moved definitions of commands so that all
definitions needed for a particular type of device are
found together in the include file of that name.
This approximatly follows the layout of their definition 
in the SCSI-2 spec. 
As such they are:

scsi_all.h  		general commands for all devices --- CHAPTER 7
scsi-disk.h  		commands relevant to disk        --- CHAPTER 8
scsi-tape.h  		commands for scsi tapes          --- CHAPTER 9
scsi-cd.h    		commands for cd-roms (and audio) --- CHAPTER 13
scsi-changer.h    	commands medium changer devices  --- CHAPTER 16

---------ioctl definitions-------------
User accessable structures (e.g. ioctl definitions) have been
placed in sys/cdio, sys/sgio and sys/chio (based after sys/mtio for
the ioctls for mag tapes (including st).
General scsi ioctls are found in sys/scsiio.h.

-----------cd-rom-----------------
The cd rom driver ha been tested by a number of people and
grefen@convex.com has completed the audio play
functions.
(xcdplayer was available from the 'from_ref' directory on agate)

At this time it is possible audio play is broken on cdroms and I will
be unable to fix it until I get one to test.
***IMPORTANT***
Cdrom audio is only suported at all for cdroms that use SCSI2 audio
definitions.

-------------media changer---------------
Once again courtesy of grefen@convex.com (in germany)
I have not tested this but he assures me it's ready for testing.
If anyone has an exabyte tape changer or similar, 
contact the author for information regarding the control interface
and program.

WARNING: This has not been tested for a LONG TIME!


---------recent changes-----------
Removed all bitfields from machine independent sections to make
it possible for them to be used on big-endian architectures.

Removed scsi specific timeouts in favour of system timeout handling.

Many structures (getting more all the time) now dynamically allocated.

Addition of code in the tape driver to recognise models of drive that
have particular problems so they can be handled specially.

many bug-fixes and cleanups.

---------even more recent changes:--------

rewrote almost the entire thing..



------Mon Oct 11 22:20:25 WST 1993------

Code is now all KNF (or close to it).

A new structure has been introduced..
Called scsi_link, one of these exists for every bus/target/lun
that has a driver attached to it.
It has links to the adapter and to the driver, as well as status
information of global interest. (e.g. if the device is in use).
The use of this new structure has allowed the compaction of a
lot of duplicated code into a single copy (now in scsi_base.c)
and makes more simple the USER level scsi implimentation.

------Tue Feb 28 07:43:17 EST 1995-----
dufault@hda.com: Redid configuration to support wired devices.
All driver entries now get bounced directly into the routines in
"scsi_driver" via a set of functions generated by the SCSI_ENTRIES macro
in scsi_conf.h.  This lets us put the common code in a single place.