Annotation of Gnu-Mach/linux/dev/drivers/scsi/hosts.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *  hosts.c Copyright (C) 1992 Drew Eckhardt
                      3:  *          Copyright (C) 1993, 1994, 1995 Eric Youngdale
                      4:  *
                      5:  *  mid to lowlevel SCSI driver interface
                      6:  *      Initial versions: Drew Eckhardt
                      7:  *      Subsequent revisions: Eric Youngdale
                      8:  *
                      9:  *  <[email protected]>
                     10:  */
                     11: 
                     12: 
                     13: /*
                     14:  *  This file contains the medium level SCSI
                     15:  *  host interface initialization, as well as the scsi_hosts array of SCSI
                     16:  *  hosts currently present in the system.
                     17:  */
                     18: 
                     19: /*
                     20:  * Don't import our own symbols, as this would severely mess up our
                     21:  * symbol tables.
                     22:  */
                     23: #define _SCSI_SYMS_VER_
                     24: #define __NO_VERSION__
                     25: #include <linux/module.h>
                     26: 
                     27: #include <linux/config.h>
                     28: #include <linux/blk.h>
                     29: #include <linux/kernel.h>
                     30: #include <linux/string.h>
                     31: #include <linux/mm.h>
                     32: #include <linux/proc_fs.h>
                     33: 
                     34: #include "scsi.h"
                     35: 
                     36: #ifndef NULL
                     37: #define NULL 0L
                     38: #endif
                     39: 
                     40: #define HOSTS_C
                     41: 
                     42: #include "hosts.h"
                     43: 
                     44: #ifdef CONFIG_A3000_SCSI
                     45: #include "a3000.h"
                     46: #endif
                     47: 
                     48: #ifdef CONFIG_A2091_SCSI
                     49: #include "a2091.h"
                     50: #endif
                     51: 
                     52: #ifdef CONFIG_GVP11_SCSI
                     53: #include "gvp11.h"
                     54: #endif
                     55: 
                     56: #ifdef CONFIG_ATARI_SCSI
                     57: #include "atari_scsi.h"
                     58: #endif
                     59: 
                     60: #ifdef CONFIG_SCSI_ADVANSYS
                     61: #include "advansys.h"
                     62: #endif
                     63: 
                     64: #ifdef CONFIG_SCSI_AHA152X
                     65: #include "aha152x.h"
                     66: #endif
                     67: 
                     68: #ifdef CONFIG_SCSI_AHA1542
                     69: #include "aha1542.h"
                     70: #endif
                     71: 
                     72: #ifdef CONFIG_SCSI_AHA1740
                     73: #include "aha1740.h"
                     74: #endif
                     75: 
                     76: #ifdef CONFIG_SCSI_AIC7XXX
                     77: #include "aic7xxx.h"
                     78: #endif
                     79: 
                     80: #ifdef CONFIG_SCSI_BUSLOGIC
                     81: #include "BusLogic.h"
                     82: #endif
                     83: 
                     84: #ifdef CONFIG_SCSI_EATA_DMA
                     85: #include "eata_dma.h"
                     86: #endif
                     87: 
                     88: #ifdef CONFIG_SCSI_EATA_PIO
                     89: #include "eata_pio.h"
                     90: #endif
                     91: 
                     92: #ifdef CONFIG_SCSI_U14_34F
                     93: #include "u14-34f.h"
                     94: #endif
                     95: 
                     96: #ifdef CONFIG_SCSI_FUTURE_DOMAIN
                     97: #include "fdomain.h"
                     98: #endif
                     99: 
                    100: #ifdef CONFIG_SCSI_GENERIC_NCR5380
                    101: #include "g_NCR5380.h"
                    102: #endif
                    103: 
                    104: #ifdef CONFIG_SCSI_IN2000
                    105: #include "in2000.h"
                    106: #endif
                    107: 
                    108: #ifdef CONFIG_SCSI_PAS16
                    109: #include "pas16.h"
                    110: #endif
                    111: 
                    112: #ifdef CONFIG_SCSI_QLOGIC_FAS
                    113: #include "qlogicfas.h"
                    114: #endif
                    115: 
                    116: #ifdef CONFIG_SCSI_QLOGIC_ISP
                    117: #include "qlogicisp.h"
                    118: #endif
                    119: 
                    120: #ifdef CONFIG_SCSI_SEAGATE
                    121: #include "seagate.h"
                    122: #endif
                    123: 
                    124: #ifdef CONFIG_SCSI_T128
                    125: #include "t128.h"
                    126: #endif
                    127: 
                    128: #ifdef CONFIG_SCSI_DTC3280
                    129: #include "dtc.h"
                    130: #endif
                    131: 
                    132: #ifdef CONFIG_SCSI_NCR53C7xx
                    133: #include "53c7,8xx.h"
                    134: #endif
                    135: 
                    136: #ifdef CONFIG_SCSI_NCR53C8XX
                    137: #include "ncr53c8xx.h"
                    138: #endif
                    139: 
                    140: #ifdef CONFIG_SCSI_ULTRASTOR
                    141: #include "ultrastor.h"
                    142: #endif
                    143: 
                    144: #ifdef CONFIG_SCSI_7000FASST
                    145: #include "wd7000.h"
                    146: #endif
                    147: 
                    148: #ifdef CONFIG_SCSI_EATA
                    149: #include "eata.h"
                    150: #endif
                    151: 
                    152: #ifdef CONFIG_SCSI_NCR53C406A
                    153: #include "NCR53c406a.h"
                    154: #endif
                    155: 
                    156: #ifdef CONFIG_SCSI_DC390W
                    157: #include "dc390w.h"
                    158: #endif
                    159: 
                    160: #ifdef CONFIG_SCSI_DC390T
                    161: #include "dc390.h"
                    162: #endif
                    163: 
                    164: #ifdef CONFIG_SCSI_AM53C974
                    165: #include "AM53C974.h"
                    166: #endif
                    167: 
                    168: #ifdef CONFIG_SCSI_MEGARAID
                    169: #include "megaraid.h"
                    170: #endif
                    171: 
                    172: #ifdef CONFIG_SCSI_PPA
                    173: #include "ppa.h"
                    174: #endif
                    175: 
                    176: #ifdef CONFIG_SCSI_SUNESP
                    177: #include "esp.h"
                    178: #endif
                    179: 
                    180: #ifdef CONFIG_BLK_DEV_IDESCSI
                    181: #include "ide-scsi.h"
                    182: #endif
                    183: 
                    184: #ifdef CONFIG_SCSI_GDTH
                    185: #include "gdth.h"
                    186: #endif
                    187: 
                    188: #ifdef CONFIG_SCSI_DEBUG
                    189: #include "scsi_debug.h"
                    190: #endif
                    191: 
                    192: 
                    193: /*
                    194: static const char RCSid[] = "$Header: /afs/sipb.mit.edu/project/hurddev/cvsroot/gnumach/linux/dev/drivers/scsi/hosts.c,v 1.1 1999/04/26 05:44:25 tb Exp $";
                    195: */
                    196: 
                    197: /*
                    198:  *  The scsi host entries should be in the order you wish the
                    199:  *  cards to be detected.  A driver may appear more than once IFF
                    200:  *  it can deal with being detected (and therefore initialized)
                    201:  *  with more than one simultaneous host number, can handle being
                    202:  *  reentrant, etc.
                    203:  *
                    204:  *  They may appear in any order, as each SCSI host is told which host 
                    205:  *  number it is during detection.
                    206:  */
                    207: 
                    208: /* This is a placeholder for controllers that are not configured into
                    209:  * the system - we do this to ensure that the controller numbering is
                    210:  * always consistent, no matter how the kernel is configured. */
                    211: 
                    212: #define NO_CONTROLLER {NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
                    213:                           NULL, NULL, 0, 0, 0, 0, 0, 0}
                    214: 
                    215: /*
                    216:  *  When figure is run, we don't want to link to any object code.  Since
                    217:  *  the macro for each host will contain function pointers, we cannot
                    218:  *  use it and instead must use a "blank" that does no such
                    219:  *  idiocy.
                    220:  */
                    221: 
                    222: Scsi_Host_Template * scsi_hosts = NULL;
                    223: 
                    224: static Scsi_Host_Template builtin_scsi_hosts[] =
                    225: {
                    226: #ifdef CONFIG_AMIGA
                    227: #ifdef CONFIG_A3000_SCSI
                    228:        A3000_SCSI,
                    229: #endif
                    230: #ifdef CONFIG_A2091_SCSI
                    231:        A2091_SCSI,
                    232: #endif
                    233: #ifdef CONFIG_GVP11_SCSI
                    234:        GVP11_SCSI,
                    235: #endif
                    236: #endif
                    237: 
                    238: #ifdef CONFIG_ATARI
                    239: #ifdef CONFIG_ATARI_SCSI
                    240:        ATARI_SCSI,
                    241: #endif
                    242: #endif
                    243: 
                    244: #ifdef CONFIG_SCSI_ADVANSYS
                    245:        ADVANSYS,
                    246: #endif
                    247: /* BusLogic must come before aha1542.c */
                    248: #ifdef CONFIG_SCSI_BUSLOGIC
                    249:     BUSLOGIC,
                    250: #endif
                    251: #ifdef CONFIG_SCSI_U14_34F
                    252:     ULTRASTOR_14_34F,
                    253: #endif
                    254: #ifdef CONFIG_SCSI_ULTRASTOR
                    255:     ULTRASTOR_14F,
                    256: #endif
                    257: #ifdef CONFIG_SCSI_AHA152X
                    258:     AHA152X,
                    259: #endif
                    260: #ifdef CONFIG_SCSI_AHA1542
                    261:     AHA1542,
                    262: #endif
                    263: #ifdef CONFIG_SCSI_AHA1740
                    264:     AHA1740,
                    265: #endif
                    266: #ifdef CONFIG_SCSI_AIC7XXX
                    267:     AIC7XXX,
                    268: #endif
                    269: #ifdef CONFIG_SCSI_FUTURE_DOMAIN
                    270:     FDOMAIN_16X0,
                    271: #endif
                    272: #ifdef CONFIG_SCSI_IN2000
                    273:     IN2000,
                    274: #endif
                    275: #ifdef CONFIG_SCSI_GENERIC_NCR5380
                    276:     GENERIC_NCR5380,
                    277: #endif
                    278: #ifdef CONFIG_SCSI_NCR53C406A  /* 53C406A should come before QLOGIC */
                    279:     NCR53c406a,
                    280: #endif
                    281: #ifdef CONFIG_SCSI_QLOGIC_FAS
                    282:     QLOGICFAS,
                    283: #endif
                    284: #ifdef CONFIG_SCSI_QLOGIC_ISP
                    285:     QLOGICISP,
                    286: #endif
                    287: #ifdef CONFIG_SCSI_PAS16
                    288:     MV_PAS16,
                    289: #endif
                    290: #ifdef CONFIG_SCSI_SEAGATE
                    291:     SEAGATE_ST0X,
                    292: #endif
                    293: #ifdef CONFIG_SCSI_T128
                    294:     TRANTOR_T128,
                    295: #endif
                    296: #ifdef CONFIG_SCSI_DTC3280
                    297:         DTC3x80,
                    298: #endif
                    299: #ifdef CONFIG_SCSI_DC390T
                    300:     DC390_T,
                    301: #endif
                    302: #ifdef CONFIG_SCSI_NCR53C7xx
                    303:     NCR53c7xx,
                    304: #endif
                    305: #ifdef CONFIG_SCSI_NCR53C8XX
                    306:     NCR53C8XX,
                    307: #endif
                    308: #ifdef CONFIG_SCSI_EATA_DMA
                    309:     EATA_DMA,
                    310: #endif
                    311: #ifdef CONFIG_SCSI_EATA_PIO
                    312:     EATA_PIO,
                    313: #endif
                    314: #ifdef CONFIG_SCSI_7000FASST
                    315:     WD7000,
                    316: #endif
                    317: #ifdef CONFIG_SCSI_EATA
                    318:     EATA,
                    319: #endif
                    320: #ifdef CONFIG_SCSI_AM53C974
                    321:     AM53C974,
                    322: #endif
                    323: #ifdef CONFIG_SCSI_MEGARAID
                    324:     MEGARAID,
                    325: #endif
                    326: #ifdef CONFIG_SCSI_PPA
                    327:     PPA,
                    328: #endif
                    329: #ifdef CONFIG_SCSI_SUNESP
                    330:     SCSI_SPARC_ESP,
                    331: #endif
                    332: #ifdef CONFIG_SCSI_GDTH
                    333:     GDTH,
                    334: #endif
                    335: #ifdef CONFIG_BLK_DEV_IDESCSI
                    336:     IDESCSI,
                    337: #endif
                    338: #ifdef CONFIG_SCSI_DEBUG
                    339:     SCSI_DEBUG,
                    340: #endif
                    341: };
                    342: 
                    343: #define MAX_SCSI_HOSTS (sizeof(builtin_scsi_hosts) / sizeof(Scsi_Host_Template))
                    344: 
                    345: 
                    346: /*
                    347:  *  Our semaphores and timeout counters, where size depends on 
                    348:  *      MAX_SCSI_HOSTS here.
                    349:  */
                    350: 
                    351: struct Scsi_Host * scsi_hostlist = NULL;
                    352: struct Scsi_Device_Template * scsi_devicelist = NULL;
                    353: 
                    354: int max_scsi_hosts = 0;
                    355: int next_scsi_host = 0;
                    356: 
                    357: void
                    358: scsi_unregister(struct Scsi_Host * sh){
                    359:     struct Scsi_Host * shpnt;
                    360:     
                    361:     if(scsi_hostlist == sh)
                    362:        scsi_hostlist = sh->next;
                    363:     else {
                    364:        shpnt = scsi_hostlist;
                    365:        while(shpnt->next != sh) shpnt = shpnt->next;
                    366:        shpnt->next = shpnt->next->next;
                    367:     }
                    368:     
                    369:     /* If we are removing the last host registered, it is safe to reuse
                    370:      * its host number (this avoids "holes" at boot time) (DB) 
                    371:      * It is also safe to reuse those of numbers directly below which have
                    372:      * been released earlier (to avoid some holes in numbering).
                    373:      */
                    374:     if(sh->host_no == max_scsi_hosts - 1) {
                    375:        while(--max_scsi_hosts >= next_scsi_host) {
                    376:            shpnt = scsi_hostlist;
                    377:            while(shpnt && shpnt->host_no != max_scsi_hosts - 1)
                    378:                shpnt = shpnt->next;
                    379:            if(shpnt)
                    380:                break;
                    381:        }
                    382:     }
                    383:     next_scsi_host--;
                    384:     scsi_init_free((char *) sh, sizeof(struct Scsi_Host) + sh->extra_bytes);
                    385: }
                    386: 
                    387: /* We call this when we come across a new host adapter. We only do this
                    388:  * once we are 100% sure that we want to use this host adapter -  it is a
                    389:  * pain to reverse this, so we try to avoid it 
                    390:  */
                    391: 
                    392: struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){
                    393:     struct Scsi_Host * retval, *shpnt;
                    394:     retval = (struct Scsi_Host *)scsi_init_malloc(sizeof(struct Scsi_Host) + j,
                    395:                                                  (tpnt->unchecked_isa_dma && j ? GFP_DMA : 0) | GFP_ATOMIC);
                    396:     retval->host_busy = 0;
                    397:     retval->block = NULL;
                    398:     retval->wish_block = 0;
                    399:     if(j > 0xffff) panic("Too many extra bytes requested\n");
                    400:     retval->extra_bytes = j;
                    401:     retval->loaded_as_module = scsi_loadable_module_flag;
                    402:     retval->host_no = max_scsi_hosts++; /* never reuse host_no (DB) */
                    403:     next_scsi_host++;
                    404:     retval->host_queue = NULL;
                    405:     retval->host_wait = NULL;
                    406:     retval->last_reset = 0;
                    407:     retval->irq = 0;
                    408:     retval->dma_channel = 0xff;
                    409: 
                    410:     /* These three are default values which can be overridden */
                    411:     retval->max_channel = 0; 
                    412:     retval->max_id = 8;      
                    413:     retval->max_lun = 8;
                    414: 
                    415:     retval->unique_id = 0;
                    416:     retval->io_port = 0;
                    417:     retval->hostt = tpnt;
                    418:     retval->next = NULL;
                    419: #ifdef DEBUG
                    420:     printk("Register %x %x: %d\n", (int)retval, (int)retval->hostt, j);
                    421: #endif
                    422: 
                    423:     /* The next six are the default values which can be overridden
                    424:      * if need be */
                    425:     retval->this_id = tpnt->this_id;
                    426:     retval->can_queue = tpnt->can_queue;
                    427:     retval->sg_tablesize = tpnt->sg_tablesize;
                    428:     retval->cmd_per_lun = tpnt->cmd_per_lun;
                    429:     retval->unchecked_isa_dma = tpnt->unchecked_isa_dma;
                    430:     retval->use_clustering = tpnt->use_clustering;   
                    431: 
                    432:     retval->select_queue_depths = NULL;
                    433: 
                    434:     if(!scsi_hostlist)
                    435:        scsi_hostlist = retval;
                    436:     else
                    437:     {
                    438:        shpnt = scsi_hostlist;
                    439:        while(shpnt->next) shpnt = shpnt->next;
                    440:        shpnt->next = retval;
                    441:     }
                    442:     
                    443:     return retval;
                    444: }
                    445: 
                    446: int
                    447: scsi_register_device(struct Scsi_Device_Template * sdpnt)
                    448: {
                    449:     if(sdpnt->next) panic("Device already registered");
                    450:     sdpnt->next = scsi_devicelist;
                    451:     scsi_devicelist = sdpnt;
                    452:     return 0;
                    453: }
                    454: 
                    455: unsigned int scsi_init()
                    456: {
                    457:     static int called = 0;
                    458:     int i, pcount;
                    459:     Scsi_Host_Template * tpnt;
                    460:     struct Scsi_Host * shpnt;
                    461:     const char * name;
                    462:     
                    463:     if(called) return 0;
                    464:     
                    465:     called = 1;
                    466:     for (tpnt = &builtin_scsi_hosts[0], i = 0; i < MAX_SCSI_HOSTS; ++i, tpnt++)
                    467:     {
                    468:        /*
                    469:         * Initialize our semaphores.  -1 is interpreted to mean
                    470:         * "inactive" - where as 0 will indicate a time out condition.
                    471:         */
                    472:        
                    473:        pcount = next_scsi_host;
                    474:        if ((tpnt->detect) &&
                    475:            (tpnt->present =
                    476:             tpnt->detect(tpnt)))
                    477:        {
                    478:            /* The only time this should come up is when people use
                    479:             * some kind of patched driver of some kind or another. */
                    480:            if(pcount == next_scsi_host) {
                    481:                if(tpnt->present > 1)
                    482:                    panic("Failure to register low-level scsi driver");
                    483:                /* The low-level driver failed to register a driver.  We
                    484:                 * can do this now. */
                    485:                scsi_register(tpnt,0);
                    486:            }
                    487:            tpnt->next = scsi_hosts;
                    488:            scsi_hosts = tpnt;
                    489: 
                    490:             /* Add the driver to /proc/scsi */
                    491: #if CONFIG_PROC_FS 
                    492:             build_proc_dir_entries(tpnt);    
                    493: #endif
                    494:        }
                    495:     }
                    496:         
                    497:     for(shpnt=scsi_hostlist; shpnt; shpnt = shpnt->next)
                    498:     {
                    499:        if(shpnt->hostt->info)
                    500:            name = shpnt->hostt->info(shpnt);
                    501:        else
                    502:            name = shpnt->hostt->name;
                    503:        printk ("scsi%d : %s\n", /* And print a little message */
                    504:                shpnt->host_no, name);
                    505:     }
                    506:     
                    507:     printk ("scsi : %d host%s.\n", next_scsi_host,
                    508:            (next_scsi_host == 1) ? "" : "s");
                    509:     
                    510:     scsi_make_blocked_list();
                    511:     
                    512:     /* Now attach the high level drivers */
                    513: #ifdef CONFIG_BLK_DEV_SD
                    514:     scsi_register_device(&sd_template);
                    515: #endif
                    516: #ifdef CONFIG_BLK_DEV_SR
                    517:     scsi_register_device(&sr_template);
                    518: #endif
                    519: #ifdef CONFIG_CHR_DEV_ST
                    520:     scsi_register_device(&st_template);
                    521: #endif
                    522: #ifdef CONFIG_CHR_DEV_SG
                    523:     scsi_register_device(&sg_template);
                    524: #endif
                    525:     
                    526: #if 0      
                    527:     max_scsi_hosts = next_scsi_host;
                    528: #endif
                    529:     return 0;
                    530: }
                    531: 
                    532: /*
                    533:  * Overrides for Emacs so that we follow Linus's tabbing style.
                    534:  * Emacs will notice this stuff at the end of the file and automatically
                    535:  * adjust the settings for this buffer only.  This must remain at the end
                    536:  * of the file.
                    537:  * ---------------------------------------------------------------------------
                    538:  * Local variables:
                    539:  * c-indent-level: 4
                    540:  * c-brace-imaginary-offset: 0
                    541:  * c-brace-offset: -4
                    542:  * c-argdecl-indent: 4
                    543:  * c-label-offset: -4
                    544:  * c-continued-statement-offset: 4
                    545:  * c-continued-brace-offset: 0
                    546:  * indent-tabs-mode: nil
                    547:  * tab-width: 8
                    548:  * End:
                    549:  */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.