root/drivers/scsi/hosts.c

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

DEFINITIONS

This source file includes following definitions.
  1. scsi_unregister
  2. scsi_register
  3. scsi_register_device
  4. scsi_init

   1 /*
   2  *      hosts.c Copyright (C) 1992 Drew Eckhardt 
   3  *      mid to lowlevel SCSI driver interface by
   4  *              Drew Eckhardt 
   5  *
   6  *      <drew@colorado.edu>
   7  */
   8 
   9 
  10 /*
  11  *      This file contains the medium level SCSI
  12  *      host interface initialization, as well as the scsi_hosts array of SCSI
  13  *      hosts currently present in the system. 
  14  */
  15 
  16 #include <linux/config.h>
  17 #include "../block/blk.h"
  18 #include <linux/kernel.h>
  19 #include <linux/string.h>
  20 #include "scsi.h"
  21 
  22 #ifndef NULL 
  23 #define NULL 0L
  24 #endif
  25 
  26 #define HOSTS_C
  27 
  28 #include "hosts.h"
  29 
  30 #ifdef CONFIG_SCSI_AHA152X
  31 #include "aha152x.h"
  32 #endif
  33 
  34 #ifdef CONFIG_SCSI_AHA1542
  35 #include "aha1542.h"
  36 #endif
  37 
  38 #ifdef CONFIG_SCSI_AHA1740
  39 #include "aha1740.h"
  40 #endif
  41 
  42 #ifdef CONFIG_SCSI_BUSLOGIC
  43 #include "buslogic.h"
  44 #endif
  45 
  46 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
  47 #include "fdomain.h"
  48 #endif
  49 
  50 #ifdef CONFIG_SCSI_GENERIC_NCR5380
  51 #include "g_NCR5380.h"
  52 #endif
  53 
  54 #ifdef CONFIG_SCSI_IN2000
  55 #include "in2000.h"
  56 #endif
  57 
  58 #ifdef CONFIG_SCSI_PAS16
  59 #include "pas16.h"
  60 #endif
  61 
  62 #ifdef CONFIG_SCSI_SEAGATE
  63 #include "seagate.h"
  64 #endif
  65 
  66 #ifdef CONFIG_SCSI_T128
  67 #include "t128.h"
  68 #endif
  69 
  70 #ifdef CONFIG_SCSI_NCR53C7xx
  71 #include "53c7,8xx.h"
  72 #endif
  73 
  74 #ifdef CONFIG_SCSI_ULTRASTOR
  75 #include "ultrastor.h"
  76 #endif
  77 
  78 #ifdef CONFIG_SCSI_7000FASST
  79 #include "wd7000.h"
  80 #endif
  81 
  82 #ifdef CONFIG_SCSI_DEBUG
  83 #include "scsi_debug.h"
  84 #endif
  85 
  86 /*
  87 static const char RCSid[] = "$Header: /usr/src/linux/kernel/blk_drv/scsi/RCS/hosts.c,v 1.3 1993/09/24 12:21:00 drew Exp drew $";
  88 */
  89 
  90 /*
  91  *      The scsi host entries should be in the order you wish the 
  92  *      cards to be detected.  A driver may appear more than once IFF
  93  *      it can deal with being detected (and therefore initialized) 
  94  *      with more than one simultaneous host number, can handle being
  95  *      reentrant, etc.
  96  *
  97  *      They may appear in any order, as each SCSI host  is told which host number it is
  98  *      during detection.
  99  */
 100 
 101 /* This is a placeholder for controllers that are not configured into
 102    the system - we do this to ensure that the controller numbering is
 103    always consistent, no matter how the kernel is configured. */
 104 
 105 #define NO_CONTROLLER {NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
 106                 NULL, NULL, 0, 0, 0, 0, 0, 0}
 107 
 108 /*
 109  *      When figure is run, we don't want to link to any object code.  Since 
 110  *      the macro for each host will contain function pointers, we cannot 
 111  *      use it and instead must use a "blank" that does no such 
 112  *      idiocy.
 113  */
 114 
 115 Scsi_Host_Template * scsi_hosts = NULL;
 116 
 117 static Scsi_Host_Template builtin_scsi_hosts[] =
 118         {
 119 #ifdef CONFIG_SCSI_ULTRASTOR
 120         ULTRASTOR_14F,
 121 #endif
 122 #ifdef CONFIG_SCSI_AHA152X
 123         AHA152X,
 124 #endif
 125 /* Buslogic must come before aha1542.c */
 126 #ifdef CONFIG_SCSI_BUSLOGIC
 127         BUSLOGIC,
 128 #endif
 129 #ifdef CONFIG_SCSI_AHA1542
 130         AHA1542,
 131 #endif
 132 #ifdef CONFIG_SCSI_AHA1740
 133         AHA1740,
 134 #endif
 135 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
 136         FDOMAIN_16X0,
 137 #endif
 138 #ifdef CONFIG_SCSI_IN2000
 139         IN2000,
 140 #endif
 141 #ifdef CONFIG_SCSI_GENERIC_NCR5380
 142         GENERIC_NCR5380,
 143 #endif
 144 #ifdef CONFIG_SCSI_PAS16
 145         MV_PAS16,
 146 #endif
 147 #ifdef CONFIG_SCSI_SEAGATE
 148         SEAGATE_ST0X,
 149 #endif
 150 #ifdef CONFIG_SCSI_T128
 151         TRANTOR_T128,
 152 #endif
 153 #ifdef CONFIG_SCSI_NCR53C7xx
 154         NCR53c7xx,
 155 #endif
 156 #ifdef CONFIG_SCSI_7000FASST
 157         WD7000,
 158 #endif
 159 #ifdef CONFIG_SCSI_DEBUG
 160         SCSI_DEBUG,
 161 #endif
 162         };
 163 
 164 #define MAX_SCSI_HOSTS (sizeof(builtin_scsi_hosts) / sizeof(Scsi_Host_Template))
 165 
 166 /*
 167  *      Our semaphores and timeout counters, where size depends on MAX_SCSI_HOSTS here. 
 168  */
 169 
 170 struct Scsi_Host * scsi_hostlist = NULL;
 171 struct Scsi_Device_Template * scsi_devicelist;
 172 
 173 int max_scsi_hosts = 0;
 174 static int next_host = 0;
 175 
 176 void
 177 scsi_unregister(struct Scsi_Host * sh){
     /* [previous][next][first][last][top][bottom][index][help] */
 178         struct Scsi_Host * shpnt;
 179         int j;
 180 
 181         j = sh->extra_bytes;
 182 
 183         if(scsi_hostlist == sh)
 184                 scsi_hostlist = NULL;
 185         else {
 186                 shpnt = scsi_hostlist;
 187                 while(shpnt->next != sh) shpnt = shpnt->next;
 188                 shpnt->next = shpnt->next->next;
 189         };
 190         next_host--;
 191         scsi_init_free((char *) sh, sizeof(struct Scsi_Host) + j);
 192 }
 193 
 194 /* We call this when we come across a new host adapter. We only do this
 195    once we are 100% sure that we want to use this host adapter -  it is a
 196    pain to reverse this, so we try and avoid it */
 197 
 198 struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){
     /* [previous][next][first][last][top][bottom][index][help] */
 199         struct Scsi_Host * retval, *shpnt;
 200         retval = (struct Scsi_Host *)scsi_init_malloc(sizeof(struct Scsi_Host) + j);
 201         retval->host_busy = 0;
 202         if(j > 0xffff) panic("Too many extra bytes requested\n");
 203         retval->extra_bytes = j;
 204         retval->loaded_as_module = scsi_loadable_module_flag;
 205         retval->host_no = next_host++;
 206         retval->host_queue = NULL;      
 207         retval->host_wait = NULL;       
 208         retval->last_reset = 0; 
 209         retval->irq = 0;
 210         retval->hostt = tpnt;   
 211         retval->next = NULL;
 212 #ifdef DEBUG
 213         printk("Register %x %x: %d\n", retval, retval->hostt, j);
 214 #endif
 215 
 216         /* The next three are the default values which can be overridden
 217            if need be */
 218         retval->this_id = tpnt->this_id;
 219         retval->sg_tablesize = tpnt->sg_tablesize;
 220         retval->unchecked_isa_dma = tpnt->unchecked_isa_dma;
 221 
 222         if(!scsi_hostlist)
 223                 scsi_hostlist = retval;
 224         else
 225         {
 226                 shpnt = scsi_hostlist;
 227                 while(shpnt->next) shpnt = shpnt->next;
 228                 shpnt->next = retval;
 229         }
 230 
 231         return retval;
 232 }
 233 
 234 int
 235 scsi_register_device(struct Scsi_Device_Template * sdpnt)
     /* [previous][next][first][last][top][bottom][index][help] */
 236 {
 237   if(sdpnt->next) panic("Device already registered");
 238   sdpnt->next = scsi_devicelist;
 239   scsi_devicelist = sdpnt;
 240   return 0;
 241 }
 242 
 243 unsigned int scsi_init()
     /* [previous][next][first][last][top][bottom][index][help] */
 244 {
 245         static int called = 0;
 246         int i, j, count, pcount;
 247         Scsi_Host_Template * tpnt;
 248         count = 0;
 249 
 250         if(called) return 0;
 251 
 252         called = 1;     
 253         for (tpnt = &builtin_scsi_hosts[0], i = 0; i < MAX_SCSI_HOSTS; ++i, tpnt++)
 254         {
 255                 /*
 256                  * Initialize our semaphores.  -1 is interpreted to mean 
 257                  * "inactive" - where as 0 will indicate a time out condition.
 258                  */ 
 259                 
 260                 pcount = next_host;
 261                 if ((tpnt->detect) && 
 262                     (tpnt->present = 
 263                      tpnt->detect(tpnt)))
 264                 {               
 265                         /* The only time this should come up is when people use
 266                            some kind of patched driver of some kind or another. */
 267                         if(pcount == next_host) {
 268                                 if(tpnt->present > 1)
 269                                         panic("Failure to register low-level scsi driver");
 270                                 /* The low-level driver failed to register a driver.  We
 271                                    can do this now. */
 272                                 scsi_register(tpnt,0);
 273                         };
 274                         tpnt->next = scsi_hosts;
 275                         scsi_hosts = tpnt;
 276                         for(j = 0; j < tpnt->present; j++)
 277                                 printk ("scsi%d : %s\n",
 278                                         count++, tpnt->name);
 279                 }
 280         }
 281         printk ("scsi : %d hosts.\n", count);
 282         
 283         /* Now attach the high level drivers */
 284 #ifdef CONFIG_BLK_DEV_SD
 285         scsi_register_device(&sd_template);
 286 #endif
 287 #ifdef CONFIG_BLK_DEV_SR
 288         scsi_register_device(&sr_template);
 289 #endif
 290 #ifdef CONFIG_CHR_DEV_ST
 291         scsi_register_device(&st_template);
 292 #endif
 293 #ifdef CONFIG_CHR_DEV_SG
 294         scsi_register_device(&sg_template);
 295 #endif
 296 
 297         max_scsi_hosts = count;
 298         return 0;
 299 }

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