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_init
  4. sd_init
  5. sd_init1
  6. sd_attach
  7. sr_init
  8. sr_init1
  9. sr_attach
  10. st_init
  11. st_init1
  12. st_attach
  13. sg_init
  14. sg_init1
  15. sg_attach

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

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