Annotation of Gnu-Mach/linux/src/drivers/scsi/hosts.c, revision 1.1.1.3

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: 
1.1.1.3 ! root      136: #ifdef CONFIG_SCSI_SYM53C8XX
        !           137: #include "sym53c8xx.h"
        !           138: #endif
        !           139: 
1.1       root      140: #ifdef CONFIG_SCSI_NCR53C8XX
                    141: #include "ncr53c8xx.h"
                    142: #endif
                    143: 
                    144: #ifdef CONFIG_SCSI_ULTRASTOR
                    145: #include "ultrastor.h"
                    146: #endif
                    147: 
                    148: #ifdef CONFIG_SCSI_7000FASST
                    149: #include "wd7000.h"
                    150: #endif
                    151: 
                    152: #ifdef CONFIG_SCSI_EATA
                    153: #include "eata.h"
                    154: #endif
                    155: 
                    156: #ifdef CONFIG_SCSI_NCR53C406A
                    157: #include "NCR53c406a.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: /*
1.1.1.3 ! root      194: static const char RCSid[] = "$Header: cvs/gnumach/linux/src/drivers/scsi/Attic/hosts.c,v 1.1 1999/04/26 05:54:40 tb Exp $";
1.1       root      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
1.1.1.3 ! root      305: #ifdef CONFIG_SCSI_SYM53C8XX
        !           306:     SYM53C8XX,
        !           307: #endif
1.1       root      308: #ifdef CONFIG_SCSI_NCR53C8XX
                    309:     NCR53C8XX,
                    310: #endif
                    311: #ifdef CONFIG_SCSI_EATA_DMA
                    312:     EATA_DMA,
                    313: #endif
                    314: #ifdef CONFIG_SCSI_EATA_PIO
                    315:     EATA_PIO,
                    316: #endif
                    317: #ifdef CONFIG_SCSI_7000FASST
                    318:     WD7000,
                    319: #endif
                    320: #ifdef CONFIG_SCSI_EATA
                    321:     EATA,
                    322: #endif
                    323: #ifdef CONFIG_SCSI_AM53C974
                    324:     AM53C974,
                    325: #endif
                    326: #ifdef CONFIG_SCSI_MEGARAID
                    327:     MEGARAID,
                    328: #endif
                    329: #ifdef CONFIG_SCSI_PPA
                    330:     PPA,
                    331: #endif
                    332: #ifdef CONFIG_SCSI_SUNESP
                    333:     SCSI_SPARC_ESP,
                    334: #endif
                    335: #ifdef CONFIG_SCSI_GDTH
                    336:     GDTH,
                    337: #endif
                    338: #ifdef CONFIG_BLK_DEV_IDESCSI
                    339:     IDESCSI,
                    340: #endif
                    341: #ifdef CONFIG_SCSI_DEBUG
                    342:     SCSI_DEBUG,
                    343: #endif
                    344: };
                    345: 
                    346: #define MAX_SCSI_HOSTS (sizeof(builtin_scsi_hosts) / sizeof(Scsi_Host_Template))
                    347: 
                    348: 
                    349: /*
                    350:  *  Our semaphores and timeout counters, where size depends on 
                    351:  *      MAX_SCSI_HOSTS here.
                    352:  */
                    353: 
                    354: struct Scsi_Host * scsi_hostlist = NULL;
                    355: struct Scsi_Device_Template * scsi_devicelist = NULL;
                    356: 
                    357: int max_scsi_hosts = 0;
                    358: int next_scsi_host = 0;
                    359: 
                    360: void
                    361: scsi_unregister(struct Scsi_Host * sh){
                    362:     struct Scsi_Host * shpnt;
                    363:     
                    364:     if(scsi_hostlist == sh)
                    365:        scsi_hostlist = sh->next;
                    366:     else {
                    367:        shpnt = scsi_hostlist;
                    368:        while(shpnt->next != sh) shpnt = shpnt->next;
                    369:        shpnt->next = shpnt->next->next;
                    370:     }
                    371:     
                    372:     /* If we are removing the last host registered, it is safe to reuse
                    373:      * its host number (this avoids "holes" at boot time) (DB) 
                    374:      * It is also safe to reuse those of numbers directly below which have
                    375:      * been released earlier (to avoid some holes in numbering).
                    376:      */
                    377:     if(sh->host_no == max_scsi_hosts - 1) {
                    378:        while(--max_scsi_hosts >= next_scsi_host) {
                    379:            shpnt = scsi_hostlist;
                    380:            while(shpnt && shpnt->host_no != max_scsi_hosts - 1)
                    381:                shpnt = shpnt->next;
                    382:            if(shpnt)
                    383:                break;
                    384:        }
                    385:     }
                    386:     next_scsi_host--;
                    387:     scsi_init_free((char *) sh, sizeof(struct Scsi_Host) + sh->extra_bytes);
                    388: }
                    389: 
                    390: /* We call this when we come across a new host adapter. We only do this
                    391:  * once we are 100% sure that we want to use this host adapter -  it is a
                    392:  * pain to reverse this, so we try to avoid it 
                    393:  */
                    394: 
                    395: struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){
                    396:     struct Scsi_Host * retval, *shpnt;
                    397:     retval = (struct Scsi_Host *)scsi_init_malloc(sizeof(struct Scsi_Host) + j,
                    398:                                                  (tpnt->unchecked_isa_dma && j ? GFP_DMA : 0) | GFP_ATOMIC);
                    399:     retval->host_busy = 0;
                    400:     retval->block = NULL;
                    401:     retval->wish_block = 0;
                    402:     if(j > 0xffff) panic("Too many extra bytes requested\n");
                    403:     retval->extra_bytes = j;
                    404:     retval->loaded_as_module = scsi_loadable_module_flag;
                    405:     retval->host_no = max_scsi_hosts++; /* never reuse host_no (DB) */
                    406:     next_scsi_host++;
                    407:     retval->host_queue = NULL;
                    408:     retval->host_wait = NULL;
                    409:     retval->last_reset = 0;
                    410:     retval->irq = 0;
                    411:     retval->dma_channel = 0xff;
                    412: 
                    413:     /* These three are default values which can be overridden */
                    414:     retval->max_channel = 0; 
                    415:     retval->max_id = 8;      
                    416:     retval->max_lun = 8;
                    417: 
                    418:     retval->unique_id = 0;
                    419:     retval->io_port = 0;
                    420:     retval->hostt = tpnt;
                    421:     retval->next = NULL;
                    422: #ifdef DEBUG
                    423:     printk("Register %x %x: %d\n", (int)retval, (int)retval->hostt, j);
                    424: #endif
                    425: 
                    426:     /* The next six are the default values which can be overridden
                    427:      * if need be */
                    428:     retval->this_id = tpnt->this_id;
                    429:     retval->can_queue = tpnt->can_queue;
                    430:     retval->sg_tablesize = tpnt->sg_tablesize;
                    431:     retval->cmd_per_lun = tpnt->cmd_per_lun;
                    432:     retval->unchecked_isa_dma = tpnt->unchecked_isa_dma;
                    433:     retval->use_clustering = tpnt->use_clustering;   
                    434: 
                    435:     retval->select_queue_depths = NULL;
                    436: 
                    437:     if(!scsi_hostlist)
                    438:        scsi_hostlist = retval;
                    439:     else
                    440:     {
                    441:        shpnt = scsi_hostlist;
                    442:        while(shpnt->next) shpnt = shpnt->next;
                    443:        shpnt->next = retval;
                    444:     }
                    445:     
                    446:     return retval;
                    447: }
                    448: 
                    449: int
                    450: scsi_register_device(struct Scsi_Device_Template * sdpnt)
                    451: {
                    452:     if(sdpnt->next) panic("Device already registered");
                    453:     sdpnt->next = scsi_devicelist;
                    454:     scsi_devicelist = sdpnt;
                    455:     return 0;
                    456: }
                    457: 
                    458: unsigned int scsi_init()
                    459: {
                    460:     static int called = 0;
                    461:     int i, pcount;
                    462:     Scsi_Host_Template * tpnt;
                    463:     struct Scsi_Host * shpnt;
                    464:     const char * name;
                    465:     
                    466:     if(called) return 0;
                    467:     
                    468:     called = 1;
                    469:     for (tpnt = &builtin_scsi_hosts[0], i = 0; i < MAX_SCSI_HOSTS; ++i, tpnt++)
                    470:     {
                    471:        /*
                    472:         * Initialize our semaphores.  -1 is interpreted to mean
                    473:         * "inactive" - where as 0 will indicate a time out condition.
                    474:         */
1.1.1.3 ! root      475:        printk("\rprobing scsi %d/%d: %s \e[K", tpnt-builtin_scsi_hosts, MAX_SCSI_HOSTS, tpnt->name);
1.1       root      476:        
                    477:        pcount = next_scsi_host;
                    478:        if ((tpnt->detect) &&
                    479:            (tpnt->present =
                    480:             tpnt->detect(tpnt)))
                    481:        {
                    482:            /* The only time this should come up is when people use
                    483:             * some kind of patched driver of some kind or another. */
                    484:            if(pcount == next_scsi_host) {
                    485:                if(tpnt->present > 1)
                    486:                    panic("Failure to register low-level scsi driver");
                    487:                /* The low-level driver failed to register a driver.  We
                    488:                 * can do this now. */
                    489:                scsi_register(tpnt,0);
                    490:            }
                    491:            tpnt->next = scsi_hosts;
                    492:            scsi_hosts = tpnt;
                    493: 
                    494:             /* Add the driver to /proc/scsi */
                    495: #if CONFIG_PROC_FS 
                    496:             build_proc_dir_entries(tpnt);    
                    497: #endif
                    498:        }
                    499:     }
1.1.1.3 ! root      500:     printk("\ndone\n");
1.1       root      501:         
                    502:     for(shpnt=scsi_hostlist; shpnt; shpnt = shpnt->next)
                    503:     {
                    504:        if(shpnt->hostt->info)
                    505:            name = shpnt->hostt->info(shpnt);
                    506:        else
                    507:            name = shpnt->hostt->name;
                    508:        printk ("scsi%d : %s\n", /* And print a little message */
                    509:                shpnt->host_no, name);
                    510:     }
                    511:     
                    512:     printk ("scsi : %d host%s.\n", next_scsi_host,
                    513:            (next_scsi_host == 1) ? "" : "s");
                    514:     
                    515:     scsi_make_blocked_list();
                    516:     
                    517:     /* Now attach the high level drivers */
                    518: #ifdef CONFIG_BLK_DEV_SD
                    519:     scsi_register_device(&sd_template);
                    520: #endif
                    521: #ifdef CONFIG_BLK_DEV_SR
                    522:     scsi_register_device(&sr_template);
                    523: #endif
                    524: #ifdef CONFIG_CHR_DEV_ST
                    525:     scsi_register_device(&st_template);
                    526: #endif
                    527: #ifdef CONFIG_CHR_DEV_SG
                    528:     scsi_register_device(&sg_template);
                    529: #endif
                    530:     
                    531: #if 0      
                    532:     max_scsi_hosts = next_scsi_host;
                    533: #endif
                    534:     return 0;
                    535: }
                    536: 
                    537: /*
                    538:  * Overrides for Emacs so that we follow Linus's tabbing style.
                    539:  * Emacs will notice this stuff at the end of the file and automatically
                    540:  * adjust the settings for this buffer only.  This must remain at the end
                    541:  * of the file.
                    542:  * ---------------------------------------------------------------------------
                    543:  * Local variables:
                    544:  * c-indent-level: 4
                    545:  * c-brace-imaginary-offset: 0
                    546:  * c-brace-offset: -4
                    547:  * c-argdecl-indent: 4
                    548:  * c-label-offset: -4
                    549:  * c-continued-statement-offset: 4
                    550:  * c-continued-brace-offset: 0
                    551:  * indent-tabs-mode: nil
                    552:  * tab-width: 8
                    553:  * End:
                    554:  */

unix.superglobalmegacorp.com

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