root/drivers/scsi/eata.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. wait_on_busy
  2. do_dma
  3. read_pio
  4. port_detect
  5. eata2x_detect
  6. build_sg_list
  7. eata2x_queuecommand
  8. eata2x_abort
  9. eata2x_reset
  10. eata2x_interrupt_handler

   1 /*
   2  *      eata.c - Low-level driver for EATA/DMA SCSI host adapters.
   3  *
   4  *      16 Apr 1996 rev. 2.10 for linux 1.3.90
   5  *          New argument "reset_flags" to the reset routine.
   6  *
   7  *       6 Jul 1995 rev. 2.01 for linux 1.3.7
   8  *          Update required by the new /proc/scsi support.
   9  *
  10  *      11 Mar 1995 rev. 2.00 for linux 1.2.0
  11  *          Fixed a bug which prevented media change detection for removable
  12  *          disk drives.
  13  *
  14  *      23 Feb 1995 rev. 1.18 for linux 1.1.94
  15  *          Added a check for scsi_register returning NULL.
  16  *
  17  *      11 Feb 1995 rev. 1.17 for linux 1.1.91
  18  *          Now DEBUG_RESET is disabled by default.
  19  *          Register a board even if it does not assert DMA protocol support
  20  *          (DPT SK2011B does not report correctly the dmasup bit).
  21  *
  22  *       9 Feb 1995 rev. 1.16 for linux 1.1.90
  23  *          Use host->wish_block instead of host->block.
  24  *          New list of Data Out SCSI commands.
  25  *
  26  *       8 Feb 1995 rev. 1.15 for linux 1.1.89
  27  *          Cleared target_time_out counter while performing a reset.
  28  *          All external symbols renamed to avoid possible name conflicts.
  29  *
  30  *      28 Jan 1995 rev. 1.14 for linux 1.1.86
  31  *          Added module support.
  32  *          Log and do a retry when a disk drive returns a target status 
  33  *          different from zero on a recovered error.
  34  *
  35  *      24 Jan 1995 rev. 1.13 for linux 1.1.85
  36  *          Use optimized board configuration, with a measured performance
  37  *          increase in the range 10%-20% on i/o throughput.
  38  *
  39  *      16 Jan 1995 rev. 1.12 for linux 1.1.81
  40  *          Fix mscp structure comments (no functional change).
  41  *          Display a message if check_region detects a port address
  42  *          already in use.
  43  *
  44  *      17 Dec 1994 rev. 1.11 for linux 1.1.74
  45  *          Use the scsicam_bios_param routine. This allows an easy
  46  *          migration path from disk partition tables created using 
  47  *          different SCSI drivers and non optimal disk geometry.
  48  *
  49  *      15 Dec 1994 rev. 1.10 for linux 1.1.74
  50  *          Added support for ISA EATA boards (DPT PM2011, DPT PM2021).
  51  *          The host->block flag is set for all the detected ISA boards.
  52  *          The detect routine no longer enforces LEVEL triggering
  53  *          for EISA boards, it just prints a warning message.
  54  *
  55  *      30 Nov 1994 rev. 1.09 for linux 1.1.68
  56  *          Redo i/o on target status CHECK_CONDITION for TYPE_DISK only.
  57  *          Added optional support for using a single board at a time.
  58  *
  59  *      18 Nov 1994 rev. 1.08 for linux 1.1.64
  60  *          Forces sg_tablesize = 64 and can_queue = 64 if these
  61  *          values are not correctly detected (DPT PM2012).
  62  *
  63  *      14 Nov 1994 rev. 1.07 for linux 1.1.63  Final BETA release.
  64  *      04 Aug 1994 rev. 1.00 for linux 1.1.39  First BETA release.
  65  *
  66  *
  67  *          This driver is based on the CAM (Common Access Method Committee)
  68  *          EATA (Enhanced AT Bus Attachment) rev. 2.0A, using DMA protocol.
  69  *
  70  *  Copyright (C) 1994, 1995, 1996 Dario Ballabio (dario@milano.europe.dg.com)
  71  *
  72  */
  73 
  74 /*
  75  *
  76  *  Here is a brief description of the DPT SCSI host adapters.
  77  *  All these boards provide an EATA/DMA compatible programming interface
  78  *  and are fully supported by this driver:
  79  *
  80  *  PM2011B/9X -  Entry Level ISA
  81  *  PM2021A/9X -  High Performance ISA
  82  *  PM2012A       Old EISA
  83  *  PM2012B       Old EISA
  84  *  PM2022A/9X -  Entry Level EISA
  85  *  PM2122A/9X -  High Performance EISA
  86  *  PM2322A/9X -  Extra High Performance EISA
  87  *
  88  *  The DPT PM2001 provides only the EATA/PIO interface and hence is not
  89  *  supported by this driver.
  90  *
  91  *  This code has been tested with up to 3 Distributed Processing Technology 
  92  *  PM2122A/9X (DPT SCSI BIOS v002.D1, firmware v05E.0) eisa controllers,
  93  *  no on board cache and no RAID option. 
  94  *  BIOS must be enabled on the first board and must be disabled for all other 
  95  *  boards. 
  96  *  Support is provided for any number of DPT PM2122 eisa boards.
  97  *  All boards should be configured at the same IRQ level.
  98  *  Multiple IRQ configurations are supported too.
  99  *  Boards can be located in any eisa slot (1-15) and are named EATA0, 
 100  *  EATA1,... in increasing eisa slot number. ISA boards are detected
 101  *  after the eisa slot probes.
 102  *
 103  *  The IRQ for EISA boards should be _level_ triggered (not _edge_ triggered).
 104  *  This is a requirement in order to support multiple boards on the same IRQ.
 105  *
 106  *  Other eisa configuration parameters are:
 107  *
 108  *  COMMAND QUEUING   : ENABLED
 109  *  COMMAND TIMEOUT   : ENABLED
 110  *  CACHE             : DISABLED
 111  *
 112  *  In order to support multiple ISA boards in a reliable way,
 113  *  the driver sets host->wish_block = TRUE for all ISA boards.
 114  */
 115 
 116 #if defined(MODULE)
 117 #include <linux/module.h>
 118 #include <linux/version.h>
 119 #endif
 120 
 121 #include <linux/string.h>
 122 #include <linux/sched.h>
 123 #include <linux/kernel.h>
 124 #include <linux/ioport.h>
 125 #include <asm/io.h>
 126 #include <asm/system.h>
 127 #include <linux/proc_fs.h>
 128 #include <linux/blk.h>
 129 #include "scsi.h"
 130 #include "hosts.h"
 131 #include "sd.h"
 132 #include <asm/dma.h>
 133 #include <asm/irq.h>
 134 #include "linux/in.h"
 135 #include "eata.h"
 136 #include<linux/stat.h>
 137 
 138 struct proc_dir_entry proc_scsi_eata2x = {
 139     PROC_SCSI_EATA2X, 6, "eata2x",
 140     S_IFDIR | S_IRUGO | S_IXUGO, 2
 141 };
 142 
 143 /* Subversion values */
 144 #define ISA  0
 145 #define ESA 1
 146 
 147 #undef FORCE_CONFIG
 148 
 149 #undef  DEBUG_DETECT
 150 #undef  DEBUG_INTERRUPT
 151 #undef  DEBUG_STATISTICS
 152 #undef  DEBUG_RESET
 153 
 154 #define MAX_TARGET 8
 155 #define MAX_IRQ 16
 156 #define MAX_BOARDS 18
 157 #define MAX_MAILBOXES 64
 158 #define MAX_SGLIST 64
 159 #define MAX_CMD_PER_LUN 2
 160 
 161 #define FALSE 0
 162 #define TRUE 1
 163 #define FREE 0
 164 #define IN_USE   1
 165 #define LOCKED   2
 166 #define IN_RESET 3
 167 #define IGNORE   4
 168 #define NO_IRQ  0xff
 169 #define NO_DMA  0xff
 170 #define MAXLOOP 200000
 171 
 172 #define REG_CMD         7
 173 #define REG_STATUS      7
 174 #define REG_AUX_STATUS  8
 175 #define REG_DATA        0
 176 #define REG_DATA2       1
 177 #define REG_SEE         6
 178 #define REG_LOW         2
 179 #define REG_LM          3
 180 #define REG_MID         4
 181 #define REG_MSB         5
 182 #define REGION_SIZE     9
 183 #define EISA_RANGE      0xf000
 184 #define BSY_ASSERTED      0x80
 185 #define DRQ_ASSERTED      0x08
 186 #define ABSY_ASSERTED     0x01
 187 #define IRQ_ASSERTED      0x02
 188 #define READ_CONFIG_PIO   0xf0
 189 #define SET_CONFIG_PIO    0xf1
 190 #define SEND_CP_PIO       0xf2
 191 #define RECEIVE_SP_PIO    0xf3
 192 #define TRUNCATE_XFR_PIO  0xf4
 193 #define RESET_PIO         0xf9
 194 #define READ_CONFIG_DMA   0xfd
 195 #define SET_CONFIG_DMA    0xfe
 196 #define SEND_CP_DMA       0xff
 197 #define ASOK              0x00
 198 #define ASST              0x01
 199 
 200 #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr)[0])
 201 
 202 /* "EATA", in Big Endian format */
 203 #define EATA_SIGNATURE 0x41544145
 204 
 205 /* Number of valid bytes in the board config structure for EATA 2.0x */
 206 #define EATA_2_0A_SIZE 28
 207 #define EATA_2_0B_SIZE 30
 208 
 209 /* Board info structure */
 210 struct eata_info {
 211    ulong  data_len;     /* Number of valid bytes after this field */
 212    ulong  sign;         /* ASCII "EATA" signature */
 213    unchar        :4,    /* unused low nibble */
 214           version:4;    /* EATA version, should be 0x1 */
 215    unchar  ocsena:1,    /* Overlap Command Support Enabled */
 216            tarsup:1,    /* Target Mode Supported */
 217                  :2,
 218            dmasup:1,    /* DMA Supported */
 219            drqvld:1,    /* DRQ Index (DRQX) is valid */
 220               ata:1,    /* This is an ATA device */
 221            haaval:1;    /* Host Adapter Address Valid */
 222    ushort cp_pad_len;   /* Number of pad bytes after cp_len */
 223    unchar host_addr[3]; /* Host Adapter SCSI ID for channels 2, 1, 0 */
 224    unchar reserved;
 225    ulong  cp_len;       /* Number of valid bytes in cp */
 226    ulong  sp_len;       /* Number of valid bytes in sp */
 227    ushort queue_size;   /* Max number of cp that can be queued */
 228    ushort unused;
 229    ushort scatt_size;   /* Max number of entries in scatter/gather table */
 230    unchar     irq:4,    /* Interrupt Request assigned to this controller */
 231            irq_tr:1,    /* 0 for edge triggered, 1 for level triggered */
 232            second:1,    /* 1 if this is a secondary (not primary) controller */
 233              drqx:2;    /* DRQ Index (0=DMA0, 1=DMA7, 2=DMA6, 3=DMA5) */
 234    unchar  sync;        /* 1 if scsi target id 7...0 is running sync scsi */
 235 
 236    /* Structure extension defined in EATA 2.0B */
 237    unchar  isaena:1,    /* ISA i/o addressing is disabled/enabled */
 238          forcaddr:1,    /* Port address has been forced */
 239                  :6;
 240    unchar  max_id:5,    /* Max number of SCSI target IDs */
 241          max_chan:3;    /* Max SCSI channel number on this board */
 242 
 243    ushort ipad[249];
 244    };
 245 
 246 /* Board config structure */
 247 struct eata_config {
 248    ushort len;          /* Number of bytes following this field */
 249    unchar edis:1,       /* Disable EATA interface after config command */
 250          ocena:1,       /* Overlapped Commands Enabled */
 251         mdpena:1,       /* Transfer all Modified Data Pointer Messages */
 252         tarena:1,       /* Target Mode Enabled for this controller */
 253               :4;
 254    unchar cpad[511];
 255    };
 256 
 257 /* Returned status packet structure */
 258 struct mssp {
 259    unchar adapter_status:7,    /* State related to current command */
 260                      eoc:1;    /* End Of Command (1 = command completed) */
 261    unchar target_status;       /* SCSI status received after data transfer */
 262    unchar unused[2];
 263    ulong inv_res_len;          /* Number of bytes not transferred */
 264    Scsi_Cmnd *SCpnt;           /* Address set in cp */
 265    char mess[12];
 266    };
 267 
 268 /* MailBox SCSI Command Packet */
 269 struct mscp {
 270    unchar  sreset:1,     /* SCSI Bus Reset Signal should be asserted */
 271              init:1,     /* Re-initialize controller and self test */
 272            reqsen:1,     /* Transfer Request Sense Data to addr using DMA */
 273                sg:1,     /* Use Scatter/Gather */
 274                  :1,
 275            interp:1,     /* The controller interprets cp, not the target */ 
 276              dout:1,     /* Direction of Transfer is Out (Host to Target) */
 277               din:1;     /* Direction of Transfer is In (Target to Host) */
 278    unchar sense_len;     /* Request Sense Length */
 279    unchar unused[4];
 280    unchar phsunit:1,     /* Send to Target Physical Unit (bypass RAID) */
 281           notused:7;
 282    unchar target;        /* SCSI Target ID */
 283    unchar     lun:3,     /* LUN */
 284                  :2,
 285            luntar:1,     /* This cp is for Target (not LUN) */
 286            dispri:1,     /* Disconnect Privilege granted */
 287               one:1;     /* 1 */
 288    unchar mess[3];       /* Massage to/from Target */
 289    unchar cdb[12];       /* Command Descriptor Block */
 290    ulong  data_len;      /* If sg=0 Data Length, if sg=1 sglist length */
 291    Scsi_Cmnd *SCpnt;     /* Address to be returned is sp */
 292    ulong  data_address;  /* If sg=0 Data Address, if sg=1 sglist address */
 293    ulong  sp_addr;       /* Address where sp is DMA'ed when cp completes */
 294    ulong  sense_addr;    /* Address where Sense Data is DMA'ed on error */
 295 
 296    struct sg_list {
 297       unsigned int address;     /* Segment Address */
 298       unsigned int num_bytes;   /* Segment Length */
 299       } sglist[MAX_SGLIST];
 300 
 301    unsigned int index;   /* cp index */
 302    };
 303 
 304 struct hostdata {
 305    struct mscp cp[MAX_MAILBOXES];       /* Mailboxes for this board */
 306    unsigned int cp_stat[MAX_MAILBOXES]; /* FREE, IN_USE, LOCKED, IN_RESET */
 307    unsigned int last_cp_used;           /* Index of last mailbox used */
 308    unsigned int iocount;                /* Total i/o done for this board */
 309    unsigned int multicount;             /* Total ... in second ihdlr loop */
 310    int board_number;                    /* Number of this board */
 311    char board_name[16];                 /* Name of this board */
 312    char board_id[256];                  /* data from INQUIRY on this board */
 313    int in_reset;                        /* True if board is doing a reset */
 314    int target_time_out[MAX_TARGET];     /* N. of timeout errors on target */
 315    int target_reset[MAX_TARGET];        /* If TRUE redo operation on target */
 316    unsigned char subversion;            /* Bus type, either ISA or ESA */
 317    unsigned char protocol_rev;          /* EATA 2.0 rev., 'A' or 'B' or 'C' */
 318    struct mssp sp[MAX_MAILBOXES];       /* Returned status for this board */
 319    };
 320 
 321 static struct Scsi_Host * sh[MAX_BOARDS + 1];
 322 static const char* driver_name = "EATA";
 323 static unsigned int irqlist[MAX_IRQ], calls[MAX_IRQ];
 324 
 325 #define HD(board) ((struct hostdata *) &sh[board]->hostdata)
 326 #define BN(board) (HD(board)->board_name)
 327 
 328 static void eata2x_interrupt_handler(int, void *, struct pt_regs *);
 329 static int do_trace = FALSE;
 330 
 331 static inline unchar wait_on_busy(ushort iobase) {
     /* [previous][next][first][last][top][bottom][index][help] */
 332    unsigned int loop = MAXLOOP;
 333 
 334    while (inb(iobase + REG_AUX_STATUS) & ABSY_ASSERTED)
 335       if (--loop == 0) return TRUE;
 336 
 337    return FALSE;
 338 }
 339 
 340 static inline unchar do_dma (ushort iobase, unsigned int addr, unchar cmd) {
     /* [previous][next][first][last][top][bottom][index][help] */
 341 
 342    if (wait_on_busy(iobase)) return TRUE;
 343 
 344    if (addr) {
 345       outb((char)  addr,        iobase + REG_LOW);
 346       outb((char) (addr >> 8),  iobase + REG_LM);
 347       outb((char) (addr >> 16), iobase + REG_MID);
 348       outb((char) (addr >> 24), iobase + REG_MSB);
 349       }
 350 
 351    outb(cmd, iobase + REG_CMD);
 352    return FALSE;
 353 }
 354 
 355 static inline unchar read_pio (ushort iobase, ushort *start, ushort *end) {
     /* [previous][next][first][last][top][bottom][index][help] */
 356    unsigned int loop = MAXLOOP;
 357    ushort *p;
 358 
 359    for (p = start; p <= end; p++) {
 360 
 361       while (!(inb(iobase + REG_STATUS) & DRQ_ASSERTED)) 
 362          if (--loop == 0) return TRUE;
 363 
 364       loop = MAXLOOP;
 365       *p = inw(iobase);
 366       }
 367 
 368    return FALSE;
 369 }
 370 
 371 static inline int port_detect(ushort *port_base, unsigned int j, 
     /* [previous][next][first][last][top][bottom][index][help] */
 372                               Scsi_Host_Template * tpnt) {
 373    unsigned char irq, dma_channel, subversion;
 374    unsigned char protocol_rev;
 375    struct eata_info info;
 376    const char *board_status;
 377 
 378    /* Allowed DMA channels for ISA (0 indicates reserved) */
 379    unsigned char dma_channel_table[4] = { 5, 6, 7, 0 };
 380 
 381    char name[16];
 382 
 383    sprintf(name, "%s%d", driver_name, j);
 384 
 385    if(check_region(*port_base, REGION_SIZE)) {
 386       printk("%s: address 0x%03x in use, skipping probe.\n", 
 387              name, *port_base);
 388       return FALSE;
 389       }
 390 
 391    if (do_dma(*port_base, 0, READ_CONFIG_PIO)) return FALSE;
 392 
 393    /* Read the info structure */
 394    if (read_pio(*port_base, (ushort *)&info, (ushort *)&info.ipad[0])) 
 395       return FALSE;
 396 
 397    /* Check the controller "EATA" signature */
 398    if (info.sign != EATA_SIGNATURE) return FALSE;
 399 
 400    if (ntohl(info.data_len) < EATA_2_0A_SIZE) {
 401       printk("%s: config structure size (%ld bytes) too short, detaching.\n", 
 402              name, ntohl(info.data_len));
 403       return FALSE;
 404       }
 405    else if (ntohl(info.data_len) == EATA_2_0A_SIZE)
 406       protocol_rev = 'A';
 407    else if (ntohl(info.data_len) == EATA_2_0B_SIZE)
 408       protocol_rev = 'B';
 409    else
 410       protocol_rev = 'C';
 411 
 412    if (protocol_rev != 'A' && info.max_chan > 0)
 413       printk("%s: warning, only scsi channel 0 is supported.\n", name);
 414 
 415    irq = info.irq;
 416 
 417    if (*port_base & EISA_RANGE) {
 418 
 419       if (!info.haaval || info.ata || info.drqvld) {
 420          printk("%s: unusable EISA board found (%d%d%d), detaching.\n", 
 421                 name, info.haaval, info.ata, info.drqvld);
 422          return FALSE;
 423          }
 424 
 425       subversion = ESA;
 426       dma_channel = NO_DMA;
 427       }
 428    else {
 429 
 430       if (!info.haaval || info.ata || !info.drqvld) {
 431          printk("%s: unusable ISA board found (%d%d%d), detaching.\n",
 432                 name, info.haaval, info.ata, info.drqvld);
 433          return FALSE;
 434          }
 435 
 436       subversion = ISA;
 437       dma_channel = dma_channel_table[3 - info.drqx];
 438       }
 439 
 440    if (!info.dmasup)
 441       printk("%s: warning, DMA protocol support not asserted.\n", name);
 442 
 443    if (subversion == ESA && !info.irq_tr)
 444       printk("%s: warning, LEVEL triggering is suggested for IRQ %u.\n",
 445              name, irq);
 446 
 447    if (info.second)
 448       board_status = "Sec.";
 449    else
 450       board_status = "Prim.";
 451 
 452    /* Board detected, allocate its IRQ if not already done */
 453    if ((irq >= MAX_IRQ) || ((irqlist[irq] == NO_IRQ) && request_irq
 454        (irq, eata2x_interrupt_handler, SA_INTERRUPT, driver_name, NULL))) {
 455       printk("%s: unable to allocate IRQ %u, detaching.\n", name, irq);
 456       return FALSE;
 457       }
 458 
 459    if (subversion == ISA && request_dma(dma_channel, driver_name)) {
 460       printk("%s: unable to allocate DMA channel %u, detaching.\n",
 461              name, dma_channel);
 462       free_irq(irq, NULL);
 463       return FALSE;
 464       }
 465 
 466 #if defined (FORCE_CONFIG)
 467    {
 468    struct eata_config config;
 469 
 470    /* Set board configuration */
 471    memset((char *)&config, 0, sizeof(struct eata_config));
 472    config.len = (ushort) htons((ushort)510);
 473    config.ocena = TRUE;
 474 
 475    if (do_dma(*port_base, (unsigned int)&config, SET_CONFIG_DMA)) {
 476       printk("%s: busy timeout sending configuration, detaching.\n", name);
 477       return FALSE;
 478       }
 479    }
 480 #endif
 481 
 482    sh[j] = scsi_register(tpnt, sizeof(struct hostdata));
 483 
 484    if (sh[j] == NULL) {
 485       printk("%s: unable to register host, detaching.\n", name);
 486 
 487       if (irqlist[irq] == NO_IRQ) free_irq(irq, NULL);
 488 
 489       if (subversion == ISA) free_dma(dma_channel);
 490 
 491       return FALSE;
 492       }
 493 
 494    sh[j]->io_port = *port_base;
 495    sh[j]->n_io_port = REGION_SIZE;
 496    sh[j]->dma_channel = dma_channel;
 497    sh[j]->irq = irq;
 498    sh[j]->sg_tablesize = (ushort) ntohs(info.scatt_size);
 499    sh[j]->this_id = (ushort) info.host_addr[3];
 500    sh[j]->can_queue = (ushort) ntohs(info.queue_size);
 501    sh[j]->cmd_per_lun = MAX_CMD_PER_LUN;
 502 
 503    /* Register the I/O space that we use */
 504    request_region(sh[j]->io_port, REGION_SIZE, driver_name);
 505 
 506    memset(HD(j), 0, sizeof(struct hostdata));
 507    HD(j)->subversion = subversion;
 508    HD(j)->protocol_rev = protocol_rev;
 509    HD(j)->board_number = j;
 510    irqlist[irq] = j;
 511 
 512    if (HD(j)->subversion == ESA)
 513       sh[j]->unchecked_isa_dma = FALSE;
 514    else {
 515       sh[j]->wish_block = TRUE;
 516       sh[j]->unchecked_isa_dma = TRUE;
 517       disable_dma(dma_channel);
 518       clear_dma_ff(dma_channel);
 519       set_dma_mode(dma_channel, DMA_MODE_CASCADE);
 520       enable_dma(dma_channel);
 521       }
 522 
 523    strcpy(BN(j), name);
 524 
 525    printk("%s: 2.0%c, %s, ID %d, PORT 0x%03x, IRQ %u, DMA %u, SG %d, "\
 526           "Mbox %d, CmdLun %d.\n", BN(j), HD(j)->protocol_rev, board_status, 
 527            sh[j]->this_id, sh[j]->io_port, sh[j]->irq, sh[j]->dma_channel,
 528            sh[j]->sg_tablesize, sh[j]->can_queue, sh[j]->cmd_per_lun);
 529 
 530    /* DPT PM2012 does not allow to detect sg_tablesize correctly */
 531    if (sh[j]->sg_tablesize > MAX_SGLIST || sh[j]->sg_tablesize < 2) {
 532       printk("%s: detect, forcing to use %d SG lists.\n", BN(j), MAX_SGLIST);
 533       sh[j]->sg_tablesize = MAX_SGLIST;
 534       }
 535 
 536    /* DPT PM2012 does not allow to detect can_queue correctly */
 537    if (sh[j]->can_queue > MAX_MAILBOXES || sh[j]->can_queue  < 2) {
 538       printk("%s: detect, forcing to use %d Mbox.\n", BN(j), MAX_MAILBOXES);
 539       sh[j]->can_queue = MAX_MAILBOXES;
 540       }
 541 
 542 #if defined (DEBUG_DETECT)
 543    if (protocol_rev != 'A')
 544       printk("%s: EATA 2.0%c, isaena %u, forcaddr %u, max_id %u,"\
 545              " max_chan %u.\n", name, protocol_rev, info.isaena, 
 546              info.forcaddr, info.max_id, info.max_chan);
 547 
 548    printk("%s: Version 0x%x, SYNC 0x%x, infol %ld, cpl %ld spl %ld.\n", 
 549           name, info.version, info.sync, ntohl(info.data_len), 
 550           ntohl(info.cp_len), ntohl(info.sp_len));
 551 #endif
 552 
 553    return TRUE;
 554 }
 555 
 556 int eata2x_detect (Scsi_Host_Template * tpnt) {
     /* [previous][next][first][last][top][bottom][index][help] */
 557    unsigned int j = 0, k, flags;
 558 
 559    ushort io_port[] = { 
 560       0x1c88, 0x2c88, 0x3c88, 0x4c88, 0x5c88, 0x6c88, 0x7c88, 0x8c88,
 561       0x9c88, 0xac88, 0xbc88, 0xcc88, 0xdc88, 0xec88, 0xfc88, 
 562       0x1f0,  0x170,  0x330,  0x230,  0x0
 563       };
 564 
 565    ushort *port_base = io_port;
 566 
 567    tpnt->proc_dir = &proc_scsi_eata2x;
 568 
 569    save_flags(flags);
 570    cli();
 571 
 572    for (k = 0; k < MAX_IRQ; k++) {
 573       irqlist[k] = NO_IRQ;
 574       calls[k] = 0;
 575       }
 576 
 577    for (k = 0; k < MAX_BOARDS + 1; k++) sh[k] = NULL;
 578 
 579    while (*port_base) {
 580 
 581       if (j < MAX_BOARDS && port_detect(port_base, j, tpnt)) j++;
 582 
 583       port_base++;
 584       }
 585 
 586    if (j > 0) 
 587       printk("EATA/DMA 2.0x: Copyright (C) 1994, 1995, 1996 Dario Ballabio.\n");
 588 
 589    restore_flags(flags);
 590    return j;
 591 }
 592 
 593 static inline void build_sg_list(struct mscp *cpp, Scsi_Cmnd *SCpnt) {
     /* [previous][next][first][last][top][bottom][index][help] */
 594    unsigned int k;
 595    struct scatterlist * sgpnt;
 596 
 597    sgpnt = (struct scatterlist *) SCpnt->request_buffer;
 598 
 599    for (k = 0; k < SCpnt->use_sg; k++) {
 600       cpp->sglist[k].address = htonl((unsigned int) sgpnt[k].address);
 601       cpp->sglist[k].num_bytes = htonl((unsigned int) sgpnt[k].length);
 602       }
 603 
 604    cpp->data_address = htonl((unsigned int) cpp->sglist);
 605    cpp->data_len = htonl((SCpnt->use_sg * sizeof(struct sg_list)));
 606 }
 607 
 608 int eata2x_queuecommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) {
     /* [previous][next][first][last][top][bottom][index][help] */
 609    unsigned int i, j, k, flags;
 610    struct mscp *cpp;
 611    struct mssp *spp;
 612 
 613    static const unsigned char data_out_cmds[] = {
 614       0x0a, 0x2a, 0x15, 0x55, 0x04, 0x07, 0x0b, 0x10, 0x16, 0x18, 0x1d, 
 615       0x24, 0x2b, 0x2e, 0x30, 0x31, 0x32, 0x38, 0x39, 0x3a, 0x3b, 0x3d, 
 616       0x3f, 0x40, 0x41, 0x4c, 0xaa, 0xae, 0xb0, 0xb1, 0xb2, 0xb6, 0xea
 617       };
 618 
 619    save_flags(flags);
 620    cli();
 621    /* j is the board number */
 622    j = ((struct hostdata *) SCpnt->host->hostdata)->board_number;
 623 
 624    if (!done) panic("%s: qcomm, pid %ld, null done.\n", BN(j), SCpnt->pid);
 625 
 626    /* i is the mailbox number, look for the first free mailbox 
 627       starting from last_cp_used */
 628    i = HD(j)->last_cp_used + 1;
 629 
 630    for (k = 0; k < sh[j]->can_queue; k++, i++) {
 631 
 632       if (i >= sh[j]->can_queue) i = 0;
 633 
 634       if (HD(j)->cp_stat[i] == FREE) {
 635          HD(j)->last_cp_used = i;
 636          break;
 637          }
 638       }
 639 
 640    if (k == sh[j]->can_queue) {
 641       printk("%s: qcomm, no free mailbox, resetting.\n", BN(j));
 642 
 643       if (HD(j)->in_reset) 
 644          printk("%s: qcomm, already in reset.\n", BN(j));
 645       else if (eata2x_reset(SCpnt, SCSI_RESET_SUGGEST_BUS_RESET)
 646                == SCSI_RESET_SUCCESS) 
 647          panic("%s: qcomm, SCSI_RESET_SUCCESS.\n", BN(j));
 648 
 649       SCpnt->result = DID_BUS_BUSY << 16; 
 650       SCpnt->host_scribble = NULL;
 651       printk("%s: qcomm, pid %ld, DID_BUS_BUSY, done.\n", BN(j), SCpnt->pid);
 652       restore_flags(flags);
 653       done(SCpnt);    
 654       return 0;
 655       }
 656 
 657    /* Set pointer to control packet structure */
 658    cpp = &HD(j)->cp[i];
 659 
 660    memset(cpp, 0, sizeof(struct mscp));
 661 
 662    /* Set pointer to status packet structure */
 663    spp = &HD(j)->sp[i];
 664 
 665    memset(spp, 0, sizeof(struct mssp));
 666 
 667    /* The EATA protocol uses Big Endian format, while Intel is Little Endian */
 668    cpp->sp_addr = htonl((unsigned int) spp);
 669 
 670    SCpnt->scsi_done = done;
 671    cpp->index = i;
 672    SCpnt->host_scribble = (unsigned char *) &cpp->index;
 673 
 674    if (do_trace) printk("%s: qcomm, mbox %d, target %d, pid %ld.\n",
 675                         BN(j), i, SCpnt->target, SCpnt->pid);
 676 
 677    for (k = 0; k < ARRAY_SIZE(data_out_cmds); k++)
 678      if (SCpnt->cmnd[0] == data_out_cmds[k]) {
 679         cpp->dout = TRUE;
 680         break;
 681         }
 682 
 683    cpp->din = !cpp->dout;
 684    cpp->reqsen = TRUE;
 685    cpp->dispri = TRUE;
 686    cpp->one = TRUE;
 687    cpp->target = SCpnt->target;
 688    cpp->lun = SCpnt->lun;  
 689    cpp->SCpnt = SCpnt;
 690    cpp->sense_addr = htonl((unsigned int) SCpnt->sense_buffer); 
 691    cpp->sense_len = sizeof SCpnt->sense_buffer;
 692 
 693    if (SCpnt->use_sg) {
 694       cpp->sg = TRUE;
 695       build_sg_list(cpp, SCpnt);
 696       }
 697    else {
 698       cpp->data_address = htonl((unsigned int) SCpnt->request_buffer);
 699       cpp->data_len = htonl(SCpnt->request_bufflen);
 700       }
 701 
 702    memcpy(cpp->cdb, SCpnt->cmnd, SCpnt->cmd_len);
 703 
 704    /* Send control packet to the board */
 705    if (do_dma(sh[j]->io_port, (unsigned int) cpp, SEND_CP_DMA)) {
 706       SCpnt->result = DID_ERROR << 16; 
 707       SCpnt->host_scribble = NULL;
 708       printk("%s: qcomm, target %d, pid %ld, adapter busy, DID_ERROR, done.\n", 
 709              BN(j), SCpnt->target, SCpnt->pid);
 710       restore_flags(flags);
 711       done(SCpnt);    
 712       return 0;
 713       }
 714 
 715    HD(j)->cp_stat[i] = IN_USE;
 716    restore_flags(flags);
 717    return 0;
 718 }
 719 
 720 int eata2x_abort (Scsi_Cmnd *SCarg) {
     /* [previous][next][first][last][top][bottom][index][help] */
 721    unsigned int i, j, flags;
 722 
 723    save_flags(flags);
 724    cli();
 725    j = ((struct hostdata *) SCarg->host->hostdata)->board_number;
 726 
 727    if (SCarg->host_scribble == NULL) {
 728       printk("%s: abort, target %d, pid %ld inactive.\n",
 729              BN(j), SCarg->target, SCarg->pid);
 730       restore_flags(flags);
 731       return SCSI_ABORT_NOT_RUNNING;
 732       }
 733 
 734    i = *(unsigned int *)SCarg->host_scribble;
 735    printk("%s: abort, mbox %d, target %d, pid %ld.\n", 
 736           BN(j), i, SCarg->target, SCarg->pid);
 737 
 738    if (i >= sh[j]->can_queue)
 739       panic("%s: abort, invalid SCarg->host_scribble.\n", BN(j));
 740 
 741    if (wait_on_busy(sh[j]->io_port)) {
 742       printk("%s: abort, timeout error.\n", BN(j));
 743       restore_flags(flags);
 744       return SCSI_ABORT_ERROR;
 745       }
 746 
 747    if (HD(j)->cp_stat[i] == FREE) {
 748       printk("%s: abort, mbox %d is free.\n", BN(j), i);
 749       restore_flags(flags);
 750       return SCSI_ABORT_NOT_RUNNING;
 751       }
 752 
 753    if (HD(j)->cp_stat[i] == IN_USE) {
 754       printk("%s: abort, mbox %d is in use.\n", BN(j), i);
 755 
 756       if (SCarg != HD(j)->cp[i].SCpnt)
 757          panic("%s: abort, mbox %d, SCarg %p, cp SCpnt %p.\n",
 758                BN(j), i, SCarg, HD(j)->cp[i].SCpnt);
 759 
 760       restore_flags(flags);
 761       return SCSI_ABORT_SNOOZE;
 762       }
 763 
 764    if (HD(j)->cp_stat[i] == IN_RESET) {
 765       printk("%s: abort, mbox %d is in reset.\n", BN(j), i);
 766       restore_flags(flags);
 767       return SCSI_ABORT_ERROR;
 768       }
 769 
 770    if (HD(j)->cp_stat[i] == LOCKED) {
 771       printk("%s: abort, mbox %d is locked.\n", BN(j), i);
 772       restore_flags(flags);
 773       return SCSI_ABORT_NOT_RUNNING;
 774       }
 775    restore_flags(flags);
 776    panic("%s: abort, mbox %d, invalid cp_stat.\n", BN(j), i);
 777 }
 778 
 779 int eata2x_reset (Scsi_Cmnd *SCarg, unsigned int reset_flags) {
     /* [previous][next][first][last][top][bottom][index][help] */
 780    unsigned int i, j, flags, time, k, limit = 0;
 781    int arg_done = FALSE;
 782    Scsi_Cmnd *SCpnt;
 783 
 784    save_flags(flags);
 785    cli();
 786    j = ((struct hostdata *) SCarg->host->hostdata)->board_number;
 787    printk("%s: reset, enter, target %d, pid %ld, reset_flags %u.\n", 
 788           BN(j), SCarg->target, SCarg->pid, reset_flags);
 789 
 790    if (SCarg->host_scribble == NULL)
 791       printk("%s: reset, pid %ld inactive.\n", BN(j), SCarg->pid);
 792 
 793    if (HD(j)->in_reset) {
 794       printk("%s: reset, exit, already in reset.\n", BN(j));
 795       restore_flags(flags);
 796       return SCSI_RESET_ERROR;
 797       }
 798 
 799    if (wait_on_busy(sh[j]->io_port)) {
 800       printk("%s: reset, exit, timeout error.\n", BN(j));
 801       restore_flags(flags);
 802       return SCSI_RESET_ERROR;
 803       }
 804 
 805    for (k = 0; k < MAX_TARGET; k++) HD(j)->target_reset[k] = TRUE;
 806 
 807    for (k = 0; k < MAX_TARGET; k++) HD(j)->target_time_out[k] = 0;
 808 
 809    for (i = 0; i < sh[j]->can_queue; i++) {
 810 
 811       if (HD(j)->cp_stat[i] == FREE) continue;
 812 
 813       if (HD(j)->cp_stat[i] == LOCKED) {
 814          HD(j)->cp_stat[i] = FREE;
 815          printk("%s: reset, locked mbox %d forced free.\n", BN(j), i);
 816          continue;
 817          }
 818 
 819       SCpnt = HD(j)->cp[i].SCpnt;
 820       HD(j)->cp_stat[i] = IN_RESET;
 821       printk("%s: reset, mbox %d in reset, pid %ld.\n",
 822              BN(j), i, SCpnt->pid);
 823 
 824       if (SCpnt == NULL)
 825          panic("%s: reset, mbox %d, SCpnt == NULL.\n", BN(j), i);
 826 
 827       if (SCpnt->host_scribble == NULL)
 828          panic("%s: reset, mbox %d, garbled SCpnt.\n", BN(j), i);
 829 
 830       if (*(unsigned int *)SCpnt->host_scribble != i) 
 831          panic("%s: reset, mbox %d, index mismatch.\n", BN(j), i);
 832 
 833       if (SCpnt->scsi_done == NULL) 
 834          panic("%s: reset, mbox %d, SCpnt->scsi_done == NULL.\n", BN(j), i);
 835 
 836       if (SCpnt == SCarg) arg_done = TRUE;
 837       }
 838 
 839    if (do_dma(sh[j]->io_port, 0, RESET_PIO)) {
 840       printk("%s: reset, cannot reset, timeout error.\n", BN(j));
 841       restore_flags(flags);
 842       return SCSI_RESET_ERROR;
 843       }
 844 
 845    printk("%s: reset, board reset done, enabling interrupts.\n", BN(j));
 846 
 847 #if defined (DEBUG_RESET)
 848    do_trace = TRUE;
 849 #endif
 850 
 851    HD(j)->in_reset = TRUE;
 852    sti();
 853    time = jiffies;
 854    while ((jiffies - time) < HZ && limit++ < 100000000);
 855    cli();
 856    printk("%s: reset, interrupts disabled, loops %d.\n", BN(j), limit);
 857 
 858    for (i = 0; i < sh[j]->can_queue; i++) {
 859 
 860       /* Skip mailboxes already set free by interrupt */
 861       if (HD(j)->cp_stat[i] != IN_RESET) continue;
 862 
 863       SCpnt = HD(j)->cp[i].SCpnt;
 864       SCpnt->result = DID_RESET << 16;
 865       SCpnt->host_scribble = NULL;
 866 
 867       /* This mailbox is still waiting for its interrupt */
 868       HD(j)->cp_stat[i] = LOCKED;
 869 
 870       printk("%s, reset, mbox %d locked, DID_RESET, pid %ld done.\n",
 871              BN(j), i, SCpnt->pid);
 872       restore_flags(flags);
 873       SCpnt->scsi_done(SCpnt);
 874       cli();
 875       }
 876 
 877    HD(j)->in_reset = FALSE;
 878    do_trace = FALSE;
 879    restore_flags(flags);
 880 
 881    if (arg_done) {
 882       printk("%s: reset, exit, success.\n", BN(j));
 883       return SCSI_RESET_SUCCESS;
 884       }
 885    else {
 886       printk("%s: reset, exit, wakeup.\n", BN(j));
 887       return SCSI_RESET_PUNT;
 888       }
 889 }
 890 
 891 static void eata2x_interrupt_handler(int irq, void *dev_id, struct pt_regs * regs) {
     /* [previous][next][first][last][top][bottom][index][help] */
 892    Scsi_Cmnd *SCpnt;
 893    unsigned int i, j, k, flags, status, tstatus, loops, total_loops = 0;
 894    struct mssp *spp;
 895    struct mscp *cpp;
 896 
 897    save_flags(flags);
 898    cli();
 899 
 900    if (irqlist[irq] == NO_IRQ) {
 901       printk("%s, ihdlr, irq %d, unexpected interrupt.\n", driver_name, irq);
 902       restore_flags(flags);
 903       return;
 904       }
 905 
 906    if (do_trace) printk("%s: ihdlr, enter, irq %d, calls %d.\n", 
 907                         driver_name, irq, calls[irq]);
 908 
 909    /* Service all the boards configured on this irq */
 910    for (j = 0; sh[j] != NULL; j++) {
 911 
 912       if (sh[j]->irq != irq) continue;
 913 
 914       loops = 0;
 915 
 916       /* Loop until all interrupts for a board are serviced */
 917       while (inb(sh[j]->io_port + REG_AUX_STATUS) & IRQ_ASSERTED) {
 918          total_loops++;
 919          loops++;
 920 
 921          if (do_trace) printk("%s: ihdlr, start service, count %d.\n",
 922                               BN(j), HD(j)->iocount);
 923    
 924          /* Read the status register to clear the interrupt indication */
 925          inb(sh[j]->io_port + REG_STATUS);
 926    
 927          /* Service all mailboxes of this board */
 928          for (i = 0; i < sh[j]->can_queue; i++) {
 929             spp = &HD(j)->sp[i];
 930    
 931             /* Check if this mailbox has completed the operation */
 932             if (spp->eoc == FALSE) continue;
 933    
 934             spp->eoc = FALSE;
 935    
 936             if (HD(j)->cp_stat[i] == IGNORE) {
 937                HD(j)->cp_stat[i] = FREE;
 938                continue;
 939                }
 940             else if (HD(j)->cp_stat[i] == LOCKED) {
 941                HD(j)->cp_stat[i] = FREE;
 942                printk("%s: ihdlr, mbox %d unlocked, count %d.\n",
 943                       BN(j), i, HD(j)->iocount);
 944                continue;
 945                }
 946             else if (HD(j)->cp_stat[i] == FREE) {
 947                printk("%s: ihdlr, mbox %d is free, count %d.\n", 
 948                       BN(j), i, HD(j)->iocount);
 949                continue;
 950                }
 951             else if (HD(j)->cp_stat[i] == IN_RESET)
 952                printk("%s: ihdlr, mbox %d is in reset.\n", BN(j), i);
 953             else if (HD(j)->cp_stat[i] != IN_USE) 
 954                panic("%s: ihdlr, mbox %d, invalid cp_stat.\n", BN(j), i);
 955    
 956             HD(j)->cp_stat[i] = FREE;
 957             cpp = &HD(j)->cp[i];
 958             SCpnt = spp->SCpnt;
 959    
 960             if (SCpnt == NULL)
 961                panic("%s: ihdlr, mbox %d, SCpnt == NULL.\n", BN(j), i);
 962    
 963             if (SCpnt != cpp->SCpnt)
 964                panic("%s: ihdlr, mbox %d, sp SCpnt %p, cp SCpnt %p.\n",
 965                      BN(j), i, SCpnt, cpp->SCpnt);
 966    
 967             if (SCpnt->host_scribble == NULL)
 968                panic("%s: ihdlr, mbox %d, pid %ld, SCpnt %p garbled.\n",
 969                      BN(j), i, SCpnt->pid, SCpnt);
 970    
 971             if (*(unsigned int *)SCpnt->host_scribble != i) 
 972                panic("%s: ihdlr, mbox %d, pid %ld, index mismatch %d,"\
 973                      " irq %d.\n", BN(j), i, SCpnt->pid, 
 974                      *(unsigned int *)SCpnt->host_scribble, irq);
 975    
 976             tstatus = status_byte(spp->target_status);
 977    
 978             switch (spp->adapter_status) {
 979                case ASOK:     /* status OK */
 980    
 981                   /* Forces a reset if a disk drive keeps returning BUSY */
 982                   if (tstatus == BUSY && SCpnt->device->type != TYPE_TAPE) 
 983                      status = DID_ERROR << 16;
 984    
 985                   /* If there was a bus reset, redo operation on each target */
 986                   else if (tstatus != GOOD
 987                            && SCpnt->device->type == TYPE_DISK
 988                            && HD(j)->target_reset[SCpnt->target])
 989                      status = DID_BUS_BUSY << 16;
 990    
 991                   /* Works around a flaw in scsi.c */
 992                   else if (tstatus == CHECK_CONDITION
 993                            && SCpnt->device->type == TYPE_DISK
 994                            && (SCpnt->sense_buffer[2] & 0xf) == RECOVERED_ERROR)
 995                      status = DID_BUS_BUSY << 16;
 996 
 997                   else
 998                      status = DID_OK << 16;
 999    
1000                   if (tstatus == GOOD)
1001                      HD(j)->target_reset[SCpnt->target] = FALSE;
1002    
1003                   if (spp->target_status && SCpnt->device->type == TYPE_DISK)
1004                      printk("%s: ihdlr, target %d:%d, pid %ld, target_status "\
1005                             "0x%x, sense key 0x%x.\n", BN(j), 
1006                             SCpnt->target, SCpnt->lun, SCpnt->pid,
1007                             spp->target_status, SCpnt->sense_buffer[2]);
1008    
1009                   HD(j)->target_time_out[SCpnt->target] = 0;
1010    
1011                   break;
1012                case ASST:     /* Selection Time Out */
1013                case 0x02:     /* Command Time Out   */
1014    
1015                   if (HD(j)->target_time_out[SCpnt->target] > 1)
1016                      status = DID_ERROR << 16;
1017                   else {
1018                      status = DID_TIME_OUT << 16;
1019                      HD(j)->target_time_out[SCpnt->target]++;
1020                      }
1021    
1022                   break;
1023                case 0x03:     /* SCSI Bus Reset Received */
1024                case 0x04:     /* Initial Controller Power-up */
1025    
1026                   if (SCpnt->device->type != TYPE_TAPE)
1027                      status = DID_BUS_BUSY << 16;
1028                   else
1029                      status = DID_ERROR << 16;
1030    
1031                   for (k = 0; k < MAX_TARGET; k++) 
1032                      HD(j)->target_reset[k] = TRUE;
1033    
1034                   break;
1035                case 0x07:     /* Bus Parity Error */
1036                case 0x0c:     /* Controller Ram Parity */
1037                case 0x05:     /* Unexpected Bus Phase */
1038                case 0x06:     /* Unexpected Bus Free */
1039                case 0x08:     /* SCSI Hung */
1040                case 0x09:     /* Unexpected Message Reject */
1041                case 0x0a:     /* SCSI Bus Reset Stuck */
1042                case 0x0b:     /* Auto Request-Sense Failed */
1043                default:
1044                   status = DID_ERROR << 16;
1045                   break;
1046                }
1047    
1048             SCpnt->result = status | spp->target_status;
1049             HD(j)->iocount++;
1050 
1051             if (loops > 1) HD(j)->multicount++;
1052 
1053 #if defined (DEBUG_INTERRUPT)
1054             if (SCpnt->result || do_trace)
1055 #else
1056             if ((spp->adapter_status != ASOK && HD(j)->iocount >  1000) ||
1057                 (spp->adapter_status != ASOK && 
1058                  spp->adapter_status != ASST && HD(j)->iocount <= 1000) ||
1059                 do_trace)
1060 #endif
1061                printk("%s: ihdlr, mbox %d, err 0x%x:%x,"\
1062                       " target %d:%d, pid %ld, count %d.\n",
1063                       BN(j), i, spp->adapter_status, spp->target_status,
1064                       SCpnt->target, SCpnt->lun, SCpnt->pid, HD(j)->iocount);
1065    
1066             /* Set the command state to inactive */
1067             SCpnt->host_scribble = NULL;
1068    
1069             restore_flags(flags);
1070             SCpnt->scsi_done(SCpnt);
1071             cli();
1072 
1073             }   /* Mailbox loop */
1074 
1075          }   /* Multiple command loop */
1076 
1077       }   /* Boards loop */
1078 
1079    calls[irq]++;
1080 
1081    if (total_loops == 0) 
1082      printk("%s: ihdlr, irq %d, no command completed, calls %d.\n",
1083             driver_name, irq, calls[irq]);
1084 
1085    if (do_trace) printk("%s: ihdlr, exit, irq %d, calls %d.\n", 
1086                         driver_name, irq, calls[irq]);
1087 
1088 #if defined (DEBUG_STATISTICS)
1089    if ((calls[irq] % 100000) == 10000)
1090       for (j = 0; sh[j] != NULL; j++)
1091          printk("%s: ihdlr, calls %d, count %d, multi %d.\n", BN(j),
1092                 calls[(sh[j]->irq)], HD(j)->iocount, HD(j)->multicount);
1093 #endif
1094 
1095    restore_flags(flags);
1096    return;
1097 }
1098 
1099 #if defined(MODULE)
1100 Scsi_Host_Template driver_template = EATA;
1101 
1102 #include "scsi_module.c"
1103 #endif

/* [previous][next][first][last][top][bottom][index][help] */