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[] =
 112         {
 113 #ifdef CONFIG_SCSI_ULTRASTOR
 114         ULTRASTOR_14F,
 115 #endif
 116 #ifdef CONFIG_SCSI_AHA152X
 117         AHA152X,
 118 #endif
 119 /* Buslogic must come before aha1542.c */
 120 #ifdef CONFIG_SCSI_BUSLOGIC
 121         BUSLOGIC,
 122 #endif
 123 #ifdef CONFIG_SCSI_AHA1542
 124         AHA1542,
 125 #endif
 126 #ifdef CONFIG_SCSI_AHA1740
 127         AHA1740,
 128 #endif
 129 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
 130         FDOMAIN_16X0,
 131 #endif
 132 #ifdef CONFIG_SCSI_IN2000
 133         IN2000,
 134 #endif
 135 #ifdef CONFIG_SCSI_GENERIC_NCR5380
 136         GENERIC_NCR5380,
 137 #endif
 138 #ifdef CONFIG_SCSI_PAS16
 139         MV_PAS16,
 140 #endif
 141 #ifdef CONFIG_SCSI_SEAGATE
 142         SEAGATE_ST0X,
 143 #endif
 144 #ifdef CONFIG_SCSI_T128
 145         TRANTOR_T128,
 146 #endif
 147 #ifdef CONFIG_SCSI_7000FASST
 148         WD7000,
 149 #endif
 150 #ifdef CONFIG_SCSI_DEBUG
 151         SCSI_DEBUG,
 152 #endif
 153         };
 154 
 155 #define MAX_SCSI_HOSTS (sizeof(scsi_hosts) / sizeof(Scsi_Host_Template))
 156 
 157 /*
 158  *      Our semaphores and timeout counters, where size depends on MAX_SCSI_HOSTS here. 
 159  */
 160 
 161 struct Scsi_Host * scsi_hostlist = NULL;
 162 
 163 static int scsi_init_memory_start = 0;
 164 
 165 int max_scsi_hosts = 0;
 166 static int next_host = 0;
 167 
 168 void
 169 scsi_unregister(struct Scsi_Host * sh, int j){
     /* [previous][next][first][last][top][bottom][index][help] */
 170         struct Scsi_Host * shpnt;
 171 
 172         if(((unsigned int) sh) + sizeof(struct Scsi_Host) + j != scsi_init_memory_start)
 173                 panic("Unable to unregister scsi host");
 174         if(scsi_hostlist == sh)
 175                 scsi_hostlist = NULL;
 176         else {
 177                 shpnt = scsi_hostlist;
 178                 while(shpnt->next != sh) shpnt = shpnt->next;
 179                 shpnt->next = shpnt->next->next;
 180 
 181         };
 182         next_host--;
 183         scsi_init_memory_start = (unsigned int) sh;
 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(int i, int j){
     /* [previous][next][first][last][top][bottom][index][help] */
 191         struct Scsi_Host * retval, *shpnt;
 192         retval = (struct Scsi_Host*) scsi_init_memory_start;
 193         scsi_init_memory_start += sizeof(struct Scsi_Host) + j;
 194         retval->host_busy = 0;
 195         retval->host_no = next_host++;
 196         retval->host_queue = NULL;      
 197         retval->host_wait = NULL;       
 198         retval->last_reset = 0; 
 199         retval->irq = 0;
 200         retval->hostt = &scsi_hosts[i]; 
 201         retval->next = NULL;
 202 #ifdef DEBUG
 203         printk("Register %x %x: %d %d\n", retval, retval->hostt, i, j);
 204 #endif
 205 
 206         /* The next three are the default values which can be overridden
 207            if need be */
 208         retval->this_id = scsi_hosts[i].this_id;
 209         retval->sg_tablesize = scsi_hosts[i].sg_tablesize;
 210         retval->unchecked_isa_dma = scsi_hosts[i].unchecked_isa_dma;
 211 
 212         if(!scsi_hostlist)
 213                 scsi_hostlist = retval;
 214         else
 215         {
 216                 shpnt = scsi_hostlist;
 217                 while(shpnt->next) shpnt = shpnt->next;
 218                 shpnt->next = retval;
 219         }
 220 
 221         return retval;
 222 }
 223 
 224 unsigned int
 225 scsi_init(unsigned long memory_start,unsigned long memory_end)
     /* [previous][next][first][last][top][bottom][index][help] */
 226 {
 227         static int called = 0;
 228         int i, j, count, pcount;
 229 
 230         count = 0;
 231 
 232         if(called) return memory_start;
 233 
 234         scsi_init_memory_start = memory_start;
 235         called = 1;     
 236         for (i = 0; i < MAX_SCSI_HOSTS; ++i)
 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 ((scsi_hosts[i].detect) && 
 245                     (scsi_hosts[i].present = 
 246                      scsi_hosts[i].detect(i)))
 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(scsi_hosts[i].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(i,0);
 256                         };
 257                         for(j = 0; j < scsi_hosts[i].present; j++)
 258                                 printk ("scsi%d : %s\n",
 259                                         count++, scsi_hosts[i].name);
 260                 }
 261         }
 262         printk ("scsi : %d hosts.\n", count);
 263         
 264         max_scsi_hosts = count;
 265         return scsi_init_memory_start;
 266 }
 267 
 268 #ifndef CONFIG_BLK_DEV_SD
 269 unsigned long sd_init(unsigned long memory_start, unsigned long memory_end){
     /* [previous][next][first][last][top][bottom][index][help] */
 270   return memory_start;
 271 };
 272 unsigned long sd_init1(unsigned long memory_start, unsigned long memory_end){
     /* [previous][next][first][last][top][bottom][index][help] */
 273   return memory_start;
 274 };
 275 void sd_attach(Scsi_Device * SDp){
     /* [previous][next][first][last][top][bottom][index][help] */
 276 };
 277 int NR_SD=-1;
 278 int MAX_SD=0;
 279 #endif
 280 
 281 
 282 #ifndef CONFIG_BLK_DEV_SR
 283 unsigned long sr_init(unsigned long memory_start, unsigned long memory_end){
     /* [previous][next][first][last][top][bottom][index][help] */
 284   return memory_start;
 285 };
 286 unsigned long sr_init1(unsigned long memory_start, unsigned long memory_end){
     /* [previous][next][first][last][top][bottom][index][help] */
 287   return memory_start;
 288 };
 289 void sr_attach(Scsi_Device * SDp){
     /* [previous][next][first][last][top][bottom][index][help] */
 290 };
 291 int NR_SR=-1;
 292 int MAX_SR=0;
 293 #endif
 294 
 295 
 296 #ifndef CONFIG_CHR_DEV_ST
 297 unsigned long st_init(unsigned long memory_start, unsigned long memory_end){
     /* [previous][next][first][last][top][bottom][index][help] */
 298   return memory_start;
 299 };
 300 unsigned long st_init1(unsigned long memory_start, unsigned long memory_end){
     /* [previous][next][first][last][top][bottom][index][help] */
 301   return memory_start;
 302 };
 303 void st_attach(Scsi_Device * SDp){
     /* [previous][next][first][last][top][bottom][index][help] */
 304 };
 305 int NR_ST=-1;
 306 int MAX_ST=0;
 307 #endif
 308 
 309 #ifndef CONFIG_CHR_DEV_SG
 310 unsigned long sg_init(unsigned long memory_start, unsigned long memory_end){
     /* [previous][next][first][last][top][bottom][index][help] */
 311   return memory_start;
 312 };
 313 unsigned long sg_init1(unsigned long memory_start, unsigned long memory_end){
     /* [previous][next][first][last][top][bottom][index][help] */
 314   return memory_start;
 315 };
 316 void sg_attach(Scsi_Device * SDp){
     /* [previous][next][first][last][top][bottom][index][help] */
 317 };
 318 int NR_SG=-1;
 319 int MAX_SG=0;
 320 #endif

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