The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/ic/ihavar.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: ihavar.h,v 1.13 2008/05/14 13:29:28 tsutsui Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 2001, 2002 Izumi Tsutsui
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   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 ``AS IS'' AND ANY EXPRESS OR
   16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   25  */
   26 
   27 /*-
   28  * Device driver for the INI-9XXXU/UW or INIC-940/950 PCI SCSI Controller.
   29  *
   30  *  Written for 386bsd and FreeBSD by
   31  *      Winston Hung            <winstonh@initio.com>
   32  *
   33  * Copyright (c) 1997-1999 Initio Corp.
   34  * Copyright (c) 2000 Ken Westerback
   35  * All rights reserved.
   36  *
   37  * Redistribution and use in source and binary forms, with or without
   38  * modification, are permitted provided that the following conditions
   39  * are met:
   40  * 1. Redistributions of source code must retain the above copyright
   41  *    notice, this list of conditions and the following disclaimer,
   42  *    without modification, immediately at the beginning of the file.
   43  * 2. The name of the author may not be used to endorse or promote products
   44  *    derived from this software without specific prior written permission.
   45  *
   46  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   47  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   48  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   49  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
   50  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   51  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   52  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   53  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   54  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   55  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
   56  * THE POSSIBILITY OF SUCH DAMAGE.
   57  */
   58 
   59 /*
   60  * Ported to NetBSD by Izumi Tsutsui <tsutsui@NetBSD.org> from OpenBSD:
   61  * $OpenBSD: iha.h,v 1.2 2001/02/08 17:35:05 krw Exp $
   62  */
   63 
   64 #define IHA_MAX_SG_ENTRIES      (MAXPHYS / PAGE_SIZE + 1)
   65 #define IHA_MAX_TARGETS         16
   66 #define IHA_MAX_SCB             32
   67 #define IHA_MAX_EXTENDED_MSG     4 /* SDTR(3) and WDTR(4) only */
   68 #define IHA_MAX_OFFSET          15
   69 
   70 #define SCSI_CONDITION_MET    0x04 /* SCSI Status codes not defined */
   71 #define SCSI_INTERM_COND_MET  0x14 /*     in scsi_all.h             */
   72 
   73 /*
   74  *   Scatter-Gather Element Structure
   75  */
   76 struct iha_sg_element {
   77         uint32_t sg_addr;       /* Data Pointer */
   78         uint32_t sg_len;        /* Data Length  */
   79 };
   80 
   81 #define IHA_SG_SIZE (sizeof(struct iha_sg_element) * IHA_MAX_SG_ENTRIES)
   82 
   83 /*
   84  * iha_scb - SCSI Request structure used by the
   85  *                  Tulip (aka inic-940/950).
   86  */
   87 
   88 struct iha_scb {
   89         TAILQ_ENTRY(iha_scb) chain;
   90 
   91         bus_dmamap_t dmap;              /* maps xs->buf xfer buffer     */
   92 
   93         int status;                     /* Current status of the SCB    */
   94 #define  STATUS_QUEUED  0               /*  SCB one of Free/Done/Pend   */
   95 #define  STATUS_RENT    1               /*  SCB allocated, not queued   */
   96 #define  STATUS_SELECT  2               /*  SCB being selected          */
   97 #define  STATUS_BUSY    3               /*  SCB I/O is active           */
   98         int nextstat;                   /* Next state function to apply */
   99         int sg_index;                   /* Scatter/Gather Index         */
  100         int sg_max;                     /* Scatter/Gather # valid entries */
  101         int flags;                      /* SCB Flags                    */
  102 #define  FLAG_DATAIN    0x00000001      /*  Data In                     */
  103 #define  FLAG_DATAOUT   0x00000002      /*  Data Out                    */
  104 #define  FLAG_RSENS     0x00000004      /*  Request Sense sent          */
  105 #define  FLAG_SG        0x00000008      /*  Scatter/Gather used         */
  106         int target;                     /* Target Id                    */
  107         int lun;                        /* Lun                          */
  108 
  109         uint32_t bufaddr;               /* Data Buffer Physical Addr    */
  110         uint32_t buflen;                /* Data Allocation Length       */
  111         int ha_stat;                    /* Status of Host Adapter       */
  112 #define  HOST_OK        0x00            /*  OK - operation a success    */
  113 #define  HOST_TIMED_OUT 0x01            /*  Request timed out           */
  114 #define  HOST_SPERR     0x10            /*  SCSI parity error           */
  115 #define  HOST_SEL_TOUT  0x11            /*  Selection Timeout           */
  116 #define  HOST_DO_DU     0x12            /*  Data Over/Underrun          */
  117 #define  HOST_BAD_PHAS  0x14            /*  Unexpected SCSI bus phase   */
  118 #define  HOST_SCSI_RST  0x1B            /*  SCSI bus was reset          */
  119 #define  HOST_DEV_RST   0x1C            /*  Device was reset            */
  120         int ta_stat;                    /* SCSI Status Byte             */
  121 
  122         struct scsipi_xfer *xs;         /* xs this SCB is executing     */
  123         struct tcs *tcs;                /* tcs for SCB_Target           */
  124         struct iha_sg_element *sglist;
  125         bus_size_t sgoffset;            /* xfer buf offset              */
  126 
  127         int sg_size;                    /* # of valid entries in sg_list */
  128         uint32_t sg_addr;               /* SGList Physical Address      */
  129 
  130         int cmdlen;                     /* CDB Length                   */
  131         uint8_t cmd[12];                /* SCSI Command                 */
  132 
  133         uint8_t scb_id;                 /* Identity Message             */
  134         uint8_t scb_tagmsg;             /* Tag Message                  */
  135         uint8_t scb_tagid;              /* Queue Tag                    */
  136 };
  137 
  138 /*
  139  *   Target Device Control Structure
  140  */
  141 struct tcs {
  142         int flags;
  143 #define               FLAG_SCSI_RATE     0x0007 /* Index into iha_rate_tbl[] */
  144 #define               FLAG_EN_DISC       0x0008 /* Enable disconnect         */
  145 #define               FLAG_NO_SYNC       0x0010 /* No sync data transfer     */
  146 #define               FLAG_NO_WIDE       0x0020 /* No wide data transfer     */
  147 #define               FLAG_1GIGA         0x0040 /* 255 hd/63 sec (64/32)     */
  148 #define               FLAG_SPINUP        0x0080 /* Start disk drive          */
  149 #define               FLAG_WIDE_DONE     0x0100 /* WDTR msg has been sent    */
  150 #define               FLAG_SYNC_DONE     0x0200 /* SDTR msg has been sent    */
  151 #define               FLAG_NO_NEG_SYNC   (FLAG_NO_SYNC | FLAG_SYNC_DONE)
  152 #define               FLAG_NO_NEG_WIDE   (FLAG_NO_WIDE | FLAG_WIDE_DONE)
  153         int period;
  154         int offset;
  155         int tagcnt;
  156 
  157         struct iha_scb *ntagscb;
  158 
  159         uint8_t syncm;
  160         uint8_t sconfig0;
  161 };
  162 
  163 struct iha_softc {
  164         device_t sc_dev;
  165 
  166         bus_space_tag_t sc_iot;
  167         bus_space_handle_t sc_ioh;
  168 
  169         bus_dma_tag_t sc_dmat;
  170         bus_dmamap_t sc_dmamap;
  171 
  172         struct scsipi_adapter sc_adapter;
  173         struct scsipi_channel sc_channel;
  174 
  175         int sc_id;
  176         void *sc_ih;
  177 
  178         /*
  179          *   Initio specific fields
  180          */
  181         int sc_flags;
  182 #define               FLAG_EXPECT_DISC       0x01
  183 #define               FLAG_EXPECT_SELECT     0x02
  184 #define               FLAG_EXPECT_RESET      0x10
  185 #define               FLAG_EXPECT_DONE_DISC  0x20
  186         int sc_semaph;
  187 #define               SEMAPH_IN_MAIN         0x00   /* Already in tulip_main */
  188         int sc_phase;                               /* MSG  C/D  I/O         */
  189 #define               PHASE_DATA_OUT         0x00   /*  0    0    0          */
  190 #define               PHASE_DATA_IN          0x01   /*  0    0    1          */
  191 #define               PHASE_CMD_OUT          0x02   /*  0    1    0          */
  192 #define               PHASE_STATUS_IN        0x03   /*  0    1    1          */
  193 #define               PHASE_MSG_OUT          0x06   /*  1    1    0          */
  194 #define               PHASE_MSG_IN           0x07   /*  1    1    1          */
  195 
  196         struct iha_scb *sc_scb;                     /* SCB array             */
  197         struct iha_scb *sc_actscb;                  /* SCB using SCSI bus    */
  198         struct iha_sg_element *sc_sglist;
  199 
  200         TAILQ_HEAD(, iha_scb) sc_freescb,
  201                               sc_pendscb,
  202                               sc_donescb;
  203 
  204         struct tcs sc_tcs[IHA_MAX_TARGETS];
  205 
  206         uint8_t sc_msg[IHA_MAX_EXTENDED_MSG];       /* [0] len, [1] Msg Code */
  207         uint8_t sc_sistat;
  208         uint8_t sc_status0;
  209         uint8_t sc_status1;
  210         uint8_t sc_sconf1;
  211 };
  212 
  213 /*
  214  *   EEPROM for one SCSI Channel
  215  */
  216 
  217 #define EEPROM_SIZE     32
  218 #define EEP_LBYTE(x)    ((x) & 0xff)
  219 #define EEP_HBYTE(x)    ((x) >> 8)
  220 #define EEP_WORD(l, h)  (((h) & 0xff) << 8 | ((l) && 0xff))
  221 #define EEP_WAIT()      DELAY(5)
  222 
  223 struct eeprom_adapter {
  224         uint16_t config1;               /* 0x00 Channel Adapter SCSI Id  */
  225 #define  CFG_ID_MASK    0x000f
  226 #define  CFG_ID(cfg)    ((cfg) & CFG_ID_MASK)
  227 #define  CFG_SCSI_RESET 0x0100          /*     Reset bus at power up     */
  228 #define  CFG_EN_PAR     0x0200          /*     SCSI parity enable        */
  229 #define  CFG_ACT_TERM1  0x0400          /*     Enable active term 1      */
  230 #define  CFG_ACT_TERM2  0x0800          /*     Enable active term 2      */
  231 #define  CFG_AUTO_TERM  0x1000          /*     Enable auto terminator    */
  232 #define  CFG_EN_PWR     0x8000          /*     Enable power mgmt         */
  233 #define  CFG_DEFAULT    (CFG_SCSI_RESET | CFG_AUTO_TERM | CFG_EN_PAR)
  234         uint16_t config2;
  235 #define  CFG_CFG2(x)    EEP_LBYTE(x)    /* 0x02 Unused Channel Cfg byte 2*/
  236 #define  CFG_TARGET(x)  EEP_HBYTE(x)    /* 0x03 Number of SCSI targets   */
  237                                         /* 0x04 Lower bytes of targ flags*/
  238         uint16_t tflags[IHA_MAX_TARGETS / sizeof(uint16_t)];
  239 #define  FLAG_DEFAULT   (FLAG_NO_WIDE | FLAG_1GIGA | FLAG_EN_DISC)
  240 };
  241 
  242 /*
  243  * Tulip (aka ini-940/950) Serial EEPROM Layout
  244  */
  245 struct iha_eeprom {
  246         /* ---------- Header ------------------------------------------------*/
  247         uint16_t signature;                    /* 0x00 NVRAM Signature       */
  248 #define EEP_SIGNATURE   0xC925
  249         uint16_t revision;
  250 #define EEP_SIZE(x)     EEP_LBYTE(x)           /* 0x02 Size of data structure*/
  251 #define EEP_REV(x)      EEP_HBYTE(x)           /* 0x03 Rev. of data structure*/
  252         /* ---------- Host Adapter Structure --------------------------------*/
  253         uint16_t model;                        /* 0x04 Model number          */
  254         uint16_t modelinfo;
  255 #define EEP_INFO(x)     EEP_LBYTE(x)           /* 0x06 Model information     */
  256 #define EEP_CHAN(x)     EEP_HBYTE(x)           /* 0x07 Number of SCSI channel*/
  257         uint16_t bioscfg;                      /* 0x08 BIOS configuration 1  */
  258 #define EEP_BIOSCFG_ENABLE      0x0001         /*      BIOS enable           */
  259 #define EEP_BIOSCFG_8DRIVE      0x0002         /*      Support > 2 drives    */
  260 #define EEP_BIOSCFG_REMOVABLE   0x0004         /*      Support removable drv */
  261 #define EEP_BIOSCFG_INT19       0x0008         /*      Intercept int 19h     */
  262 #define EEP_BIOSCFG_BIOSSCAN    0x0010         /*      Dynamic BIOS scan     */
  263 #define EEP_BIOSCFG_LUNSUPPORT  0x0040         /*      Support LUN           */
  264 #define EEP_BIOSCFG_DEFAULT     EEP_BIOSCFG_ENABLE
  265         uint16_t hacfg;                        /* 0x0a Host adapter config 1 */
  266 #define EEP_HACFG_BOOTIDMASK    0x000F         /*      Boot ID number        */
  267 #define EEP_HACFG_LUNMASK       0x0070         /*      Boot LUN number       */
  268 #define EEP_HACFG_CHANMASK      0x0080         /*      Boot Channel number   */
  269         struct eeprom_adapter adapter[2];      /* 0x0c                       */
  270         uint16_t reserved[5];                  /* 0x34                       */
  271 
  272         /* --------- CheckSum -----------------------------------------------*/
  273         uint16_t checksum;                     /* 0x3E Checksum of NVRam     */
  274 };
  275 
  276 /* Functions used by higher SCSI layers, the kernel, or iha.c and iha_pci.c  */
  277 
  278 int iha_intr(void *);
  279 void iha_attach(struct iha_softc *);

Cache object: 1389d443f9340222fa40226598fd648b


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.