1.\" $NetBSD: scsi.4,v 1.30 2011/04/28 16:20:20 wiz Exp $ 2.\" Copyright (c) 1996 3.\" Julian Elischer <julian@freebsd.org>. All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" SUCH DAMAGE. 26.\" 27.Dd July 26, 2006 28.Dt SCSI 4 29.Os 30.Sh NAME 31.Nm scsi , 32.Nm scsibus 33.Nd Small Computer Systems Interface (SCSI) bus driver 34.Sh SYNOPSIS 35.Cd "scsibus* at scsi?" 36.Cd "atapibus* at atapi?" 37.Cd options SCSIDEBUG 38.Cd options SCSIVERBOSE 39.Sh DESCRIPTION 40The 41.Nm 42driver is the top, machine-independent layer of the two-layer 43software system that provides an interface for the 44implementation of drivers to control various 45.Tn SCSI 46or 47.Tn ATAPI 48bus devices, and to use different 49.Tn SCSI 50bus host adapters or 51.Tn EIDE 52controllers. 53.Tn SCSI 54bus is capable of supporting a wide variety of peripherals, including 55hard disks, removable disks, 56.Tn CD-ROMs , 57scanners, tape drives, and other miscellaneous high-speed devices. 58.Pp 59The bottom layer is composed of the drivers for individual 60.Tn EIDE 61or 62.Tn SCSI 63bus controller chips (e.g. NCR 5380), accessed through various host bus 64interfaces, including, but not limited to 65.Tn PCI , 66.Tn ISA , 67.Tn Sbus , 68.Tn TURBOchannel , 69and 70.Tn NuBus . 71These individual devices are referred to as 72.Qq host adaptors 73in 74.Tn SCSI 75terminology, 76because they connect the 77.Tn SCSI 78bus to the host computer. 79.Pp 80When 81.Nx 82probes the 83.Tn SCSI 84busses, it 85.Qq attaches 86any devices it finds to the appropriate drivers. 87.Pp 88.Bl -tag -compact -width "sd(4)" 89.It Xr sd 4 90hard disks 91.It Xr cd 4 92.Tn CD-ROM 93drives 94.It Xr st 4 95tape drives 96.It Xr ch 4 97media changers 98.It Xr ss 4 99scanners 100.El 101.Pp 102If no specific driver matches the device, 103then 104.Nm 105attaches the device to the 106.Xr uk 4 107driver so that user level 108.Tn SCSI 109.Xr ioctl 2 110calls may still be performed against the device. 111Currently, only 112.Xr sd 4 , 113.Xr cd 4 , 114.Xr st 4 , 115and 116.Xr uk 4 117can attach to an atapi bus. 118.Pp 119Please see the 120.Xr intro 4 121manual page to see which 122.Tn SCSI 123bus host adaptors are supported by 124.Nx 125on your computer system. 126.Sh KERNEL CONFIGURATION 127The 128.Nm 129software supports some 130.Nx 131kernel 132.Xr config 1 133options. 134They are: 135.Bl -tag -width SCSIVERBOSE 136.It Dv SCSIDEBUG 137Compile in a wide variety of 138.Fn printf 139statements that can be turned on by 140.Xr ioctl 2 . 141.It Dv SCSIVERBOSE 142Enable additional and more descriptive error and status messages 143from the 144.Nm 145software. 146.El 147.Pp 148All devices and the 149.Tn SCSI 150busses support boot time allocation so that an upper number of 151devices and controllers does not need to be configured. 152.Pp 153The devices are either 154.Em wired 155so they appear at a particular device unit number or 156.Em counted 157so that they appear as the next available unused unit number. 158.Pp 159To configure a driver in the kernel without wiring down the device use a 160config line similar to 161.Pp 162.Cd "ch* at scsibus? target ? lun ?" 163.Pp 164to include the 165.Xr ch 4 166changer driver. 167.Pp 168To wire down a unit use a config line similar to 169.Pp 170.Cd "ch1 at scsibus0 target 4 lun 0" 171.Pp 172to assign changer 1 as the changer with 173.Tn SCSI 174ID 4, logical unit 0, on bus 0. 175Individual 176.Tn SCSI 177busses can be wired down to specific controllers with a config line 178similar to 179.Pp 180.Cd "scsibus0 at ahc0" 181.Pp 182which assigns 183.Tn SCSI 184bus 0 to the first unit using the 185.Xr ahc 4 186driver. 187.Pp 188When you have a mixture of wired down and counted devices then the counting 189begins with the first non-wired down unit for a particular type. 190That is, if you have a disk wired down as 191.Pp 192.Cd "sd1 at scsibus0 target 1 lun 0" 193.Pp 194then the first non-wired disk shall come on line as 195.Em sd2 . 196.Sh IOCTLS 197There are a number of 198.Xr ioctl 2 199calls that work on any 200.Tn SCSI 201device. 202They are defined in 203.Pa sys/scsiio.h 204and can be applied against any 205.Tn SCSI 206device that permits them. 207For the tape, it must be applied against the control device. 208See the manual page for each device type for more information about 209how generic 210.Tn SCSI 211.Xr ioctl 2 212calls may be applied to a specific device. 213.Bl -tag -width DIOCSDINFO____ 214.It Dv SCIOCRESET 215Reset a 216.Tn SCSI 217device. 218.It Dv SCIOCDEBUG 219Turn on debugging. 220All 221.Tn SCSI 222operations originating from this device's driver 223will be traced to the console, along with other information. 224Debugging is controlled by four bits, described in the header file. 225If no debugging is configured into the kernel, debugging will have 226no effect. 227.Tn SCSI 228debugging is controlled by the configuration option 229.Dv SCSIDEBUG . 230.It Dv SCIOCCOMMAND 231Take a 232.Tn SCSI 233command and data from a user process and apply them to the 234.Tn SCSI 235device. 236Return all status information and return data to the process. 237The 238.Xr ioctl 2 239call will return a successful status even if the device rejected the command. 240As all status is returned to the user, it is up to the user 241process to examine this information to decide the success of the command. 242.It Dv SCIOCREPROBE 243Ask the system to probe the 244.Tn SCSI 245busses for any new devices. 246If it finds any, they will be attached to the appropriate drivers. 247The search can be narrowed to a specific bus, target or Logical 248Unit Number (LUN). 249The new device may or may not be related to the device on which 250the ioctl was performed. 251.It Dv SCIOCIDENTIFY 252Ask the driver what its bus, target and LUN are. 253.It Dv SCIOCDECONFIG 254Ask the device to disappear. 255This may not happen if the device is in use. 256.El 257.Sh ADAPTERS 258The system allows common device drivers to work through many different 259types of adapters. 260The adapters take requests from the upper layers and do all IO between the 261.Tn SCSI 262bus and the system. 263The maximum size of a transfer is governed by the adapter. 264Most adapters can transfer 64KB in a single operation, however 265many can transfer larger amounts. 266.Sh TARGET MODE 267Some adapters support 268.Em Target Mode 269in which the system is capable of operating as a device, responding to 270operations initiated by another system. 271Target Mode will be supported for 272some host adapters, but is not yet complete for this version of the 273.Tn SCSI 274system. 275.Sh DIAGNOSTICS 276When the kernel is compiled with option 277.Dv SCSIDEBUG , 278the 279.Dv SCIOCDEBUG 280.Xr ioctl 2 281can be used to enable various amounts of tracing information on any 282specific device. 283Devices not being traced will not produce trace information. 284The four bits that make up the debug level, each control certain types 285of debugging information. 286.Bl -tag -width "Bit 0" 287.It Dv Bit 0 288shows all 289.Tn SCSI 290bus operations including 291.Tn SCSI 292commands, 293error information and the first 48 bytes of any data transferred. 294.It Dv Bit 1 295shows routines called. 296.It Dv Bit 2 297shows information about what branches are taken and often some 298of the return values of functions. 299.It Dv Bit 3 300shows more detailed information including 301.Tn DMA 302scatter-gather logs. 303.El 304.Sh SEE ALSO 305.Xr config 1 , 306.Xr ioctl 2 , 307.Xr ata 4 , 308.Xr cd 4 , 309.Xr ch 4 , 310.Xr intro 4 , 311.Xr sd 4 , 312.Xr se 4 , 313.Xr ss 4 , 314.Xr st 4 , 315.Xr uk 4 316.Sh HISTORY 317This 318.Nm 319system appeared in MACH 2.5 at TRW. 320.Pp 321This man page was originally written by Julian Elischer 322.Aq julian@freebsd.org 323for 324.Fx 325and extensively modified by 326.An Erik Fair 327.Aq fair@NetBSD.org 328for 329.Nx . 330.Sh BUGS 331Not every device obeys the 332.Tn SCSI 333specification as faithfully as it should. 334As such devices are discovered by the 335.Nx 336Project, their names are added to a 337.Em quirk list 338compiled into the 339.Nm 340driver along a list of flags indicating which particular bad behaviors the 341device exhibits (and that the driver should be prepared to work around). 342