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

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