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

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