📄 scsiconf.h
字号:
/* $OpenBSD: scsiconf.h,v 1.31 2001/10/26 10:50:26 krw Exp $ *//* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ *//* * Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Charles Hannum. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *//* * Originally written by Julian Elischer (julian@tfs.com) * for TRW Financial Systems for use under the MACH(2.5) operating system. * * TRW Financial Systems, in accordance with their agreement with Carnegie * Mellon University, makes this software available to CMU to distribute * or use in any manner that they see fit as long as this message is kept with * the software. For this reason TFS also grants any other persons or * organisations permission to use or modify this software. * * TFS supplies this software to be publicly redistributed * on the understanding that TFS is not responsible for the correct * functioning of this software in any circumstances. * * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 */#ifndef SCSI_SCSICONF_H#define SCSI_SCSICONF_H 1typedef int boolean;#include <sys/queue.h>#include <machine/cpu.h>#include <scsi/scsi_debug.h>/* * The following documentation tries to describe the relationship between the * various structures defined in this file: * * each adapter type has a scsi_adapter struct. This describes the adapter and * identifies routines that can be called to use the adapter. * each device type has a scsi_device struct. This describes the device and * identifies routines that can be called to use the device. * each existing device position (scsibus + target + lun) * can be described by a scsi_link struct. * Only scsi positions that actually have devices, have a scsi_link * structure assigned. so in effect each device has scsi_link struct. * The scsi_link structure contains information identifying both the * device driver and the adapter driver for that position on that scsi bus, * and can be said to 'link' the two. * each individual scsi bus has an array that points to all the scsi_link * structs associated with that scsi bus. Slots with no device have * a NULL pointer. * each individual device also knows the address of it's own scsi_link * structure. * * ------------- * * The key to all this is the scsi_link structure which associates all the * other structures with each other in the correct configuration. The * scsi_link is the connecting information that allows each part of the * scsi system to find the associated other parts. */struct buf;struct scsi_xfer;struct scsi_link;/* * Temporary hack */extern int scsi_autoconf;/* * These entrypoints are called by the high-end drivers to get services from * whatever low-end drivers they are attached to each adapter type has one of * these statically allocated. */struct scsi_adapter { int (*scsi_cmd) __P((struct scsi_xfer *)); void (*scsi_minphys) __P((struct buf *)); int (*open_target_lu) __P((void)); int (*close_target_lu) __P((void)); int (*ioctl) __P((struct scsi_link *, u_long cmd, caddr_t addrp, int flag));};/* * return values for scsi_cmd() */#define SUCCESSFULLY_QUEUED 0#define TRY_AGAIN_LATER 1#define COMPLETE 2#define ESCAPE_NOT_SUPPORTED 3/* * Device Specific Sense Handlers return either an errno * or one of these three items. */#define SCSIRET_NOERROR 0 /* No Error */#define SCSIRET_RETRY -1 /* Retry the command that got this sense */#define SCSIRET_CONTINUE -2 /* Continue with standard sense processing *//* * These entry points are called by the low-end drivers to get services from * whatever high-end drivers they are attached to. Each device type has one * of these statically allocated. */struct scsi_device { int (*err_handler) __P((struct scsi_xfer *)); /* returns -1 to say err processing done */ void (*start) __P((void *)); int (*async) __P((void)); /* * When called with `0' as the second argument, we expect status * back from the upper-level driver. When called with a `1', * we're simply notifying the upper-level driver that the command * is complete and expect no status back. */ void (*done) __P((struct scsi_xfer *));};/* * This structure describes the connection between an adapter driver and * a device driver, and is used by each to call services provided by * the other, and to allow generic scsi glue code to call these services * as well. */struct scsi_link { u_int8_t scsi_version; /* SCSI-I, SCSI-II, etc. */ u_int8_t scsibus; /* the Nth scsibus */ u_int16_t target; /* targ of this dev */ u_int16_t lun; /* lun of this dev */ u_int16_t adapter_target; /* what are we on the scsi bus */ u_int16_t adapter_buswidth; /* 8 (regular) or 16 (wide). (0 becomes 8) */ u_int16_t openings; /* available operations */ u_int16_t active; /* operations in progress */ u_int16_t flags; /* flags that all devices have */#define SDEV_REMOVABLE 0x0001 /* media is removable */#define SDEV_MEDIA_LOADED 0x0002 /* device figures are still valid */#define SDEV_WAITING 0x0004 /* a process is waiting for this */#define SDEV_OPEN 0x0008 /* at least 1 open session */#define SDEV_DBX 0x00f0 /* debuging flags (scsi_debug.h) */#define SDEV_EJECTING 0x0100 /* eject on device close */#define SDEV_ATAPI 0x0200 /* device is ATAPI */#define SDEV_2NDBUS 0x0400 /* device is a 'second' bus device */ u_int16_t quirks; /* per-device oddities */#define SDEV_AUTOSAVE 0x0001 /* do implicit SAVEDATAPOINTER on disconnect */#define SDEV_NOSYNC 0x0002 /* does not grok SDTR */#define SDEV_NOWIDE 0x0004 /* does not grok WDTR */#define SDEV_NOTAGS 0x0008 /* lies about having tagged queueing */#define SDEV_NOLUNS 0x0010 /* does not grok LUNs */#define SDEV_FORCELUNS 0x0020 /* prehistoric drive/ctlr groks LUNs */#define SDEV_NOMODESENSE 0x0040 /* removable media/optical drives */#define SDEV_NOSTARTUNIT 0x0080 /* do not issue start unit requests in sd.c */#define SDEV_NOSYNCCACHE 0x0100 /* no SYNCHRONIZE_CACHE */#define ADEV_NOSENSE 0x0200 /* No request sense - ATAPI */#define ADEV_LITTLETOC 0x0400 /* little-endian TOC - ATAPI */#define ADEV_NOCAPACITY 0x0800#define ADEV_NOTUR 0x1000#define ADEV_NODOORLOCK 0x2000#define SDEV_NOCDB6 0x4000 /* does not support 6 byte CDB */ u_int8_t inquiry_flags; /* copy of flags from probe INQUIRY */ u_int8_t inquiry_flags2; /* copy of flags2 from probe INQUIRY */ struct scsi_device *device; /* device entry points etc. */ void *device_softc; /* needed for call to foo_start */ struct scsi_adapter *adapter; /* adapter entry points etc. */ void *adapter_softc; /* needed for call to foo_scsi_cmd */ u_char luns;};int scsiprint __P((void *, const char *));/* * This describes matching information for scsi_inqmatch(). The more things * match, the higher the configuration priority. */struct scsi_inquiry_pattern { u_int8_t type; boolean removable; char *vendor; char *product; char *revision;};/* * One of these is allocated and filled in for each scsi bus. * it holds pointers to allow the scsi bus to get to the driver * That is running each LUN on the bus * it also has a template entry which is the prototype struct * supplied by the adapter driver, this is used to initialise * the others, before they have the rest of the fields filled in */struct scsibus_softc { struct device sc_dev; struct scsi_link *adapter_link; /* prototype supplied by adapter */ struct scsi_link ***sc_link; u_int16_t moreluns; u_int16_t sc_buswidth;};/* * This is used to pass information from the high-level configuration code * to the device-specific drivers. */struct scsibus_attach_args { struct scsi_link *sa_sc_link; struct scsi_inquiry_data *sa_inqbuf;};/* * Each scsi transaction is fully described by one of these structures * It includes information about the source of the command and also the * device and adapter for which the command is destined. * (via the scsi_link structure) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -