root/drivers/scsi/eata_dma.c

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

DEFINITIONS

This source file includes following definitions.
  1. eata_scsi_done
  2. eata_fake_int_handler
  3. eata_release
  4. eata_info
  5. eata_int_handler
  6. eata_send_command
  7. eata_queue
  8. internal_done
  9. eata_command
  10. eata_abort
  11. eata_reset
  12. get_board_data
  13. check_blink_state
  14. get_conf_PIO
  15. print_config
  16. register_HBA
  17. find_EISA
  18. find_ISA
  19. find_PCI
  20. eata_detect

   1 /************************************************************
   2  *                                                          *
   3  *                  Linux EATA SCSI driver                  *
   4  *                                                          *
   5  *  based on the CAM document CAM/89-004 rev. 2.0c,         *
   6  *  DPT's driver kit, some internal documents and source,   *
   7  *  and several other Linux scsi drivers and kernel docs.   *
   8  *                                                          *
   9  *  The driver currently:                                   *
  10  *      -supports all ISA based EATA-DMA boards             *
  11  *      -supports all EISA based EATA-DMA boards            *
  12  *      -supports all PCI based EATA-DMA boards             *
  13  *      -supports multiple HBAs with & without IRQ sharing  *
  14  *      -supports all SCSI channels on multi channel boards *
  15  *      -displays (more or less useful) infos in /proc/scsi *
  16  *      -can be loaded as module                            *
  17  *                                                          *
  18  *  (c)1993,94,95 Michael Neuffer                           *
  19  *                neuffer@goofy.zdv.uni-mainz.de            *
  20  *                                                          *
  21  *  This program is free software; you can redistribute it  *
  22  *  and/or modify it under the terms of the GNU General     *
  23  *  Public License as published by the Free Software        *
  24  *  Foundation; either version 2 of the License, or         *
  25  *  (at your option) any later version.                     *
  26  *                                                          *
  27  *  This program is distributed in the hope that it will be *
  28  *  useful, but WITHOUT ANY WARRANTY; without even the      *
  29  *  implied warranty of MERCHANTABILITY or FITNESS FOR A    *
  30  *  PARTICULAR PURPOSE.  See the GNU General Public License *
  31  *  for more details.                                       *
  32  *                                                          *
  33  *  You should have received a copy of the GNU General      *
  34  *  Public License along with this kernel; if not, write to *
  35  *  the Free Software Foundation, Inc., 675 Mass Ave,       *
  36  *  Cambridge, MA 02139, USA.                               *
  37  *                                                          *
  38  * I have to thank DPT for their excellent support. I took  *
  39  * me almost a year and a stopover at their HQ, on my first *
  40  * trip to the USA, to get it, but since then they've been  *
  41  * very helpful and tried to give me all the infos and      *
  42  * support I need.                                          *
  43  *                                                          *
  44  * Thanks also to Greg Hosler who did a lot of testing and  *
  45  * found quite a number of bugs during the development.     *
  46  ************************************************************
  47  *  last change: 95/04/10       OS: Linux 1.2.00 or higher  *
  48  ************************************************************/
  49 
  50 /* Look in eata_dma.h for configuration and revision information */
  51 
  52 #ifdef MODULE
  53 #include <linux/module.h>
  54 #include <linux/version.h>
  55 #endif
  56  
  57 #include <linux/kernel.h>
  58 #include <linux/sched.h>
  59 #include <linux/string.h>
  60 #include <linux/ioport.h>
  61 #include <linux/malloc.h>
  62 #include <linux/in.h>
  63 #include <linux/bios32.h>
  64 #include <linux/pci.h>
  65 #include <asm/types.h>
  66 #include <asm/io.h>
  67 #include <asm/dma.h>
  68 #include "../block/blk.h"
  69 #include "scsi.h"
  70 #include "sd.h"
  71 #include "hosts.h"
  72 #include <linux/scsicam.h>
  73 #include "eata_dma.h"
  74 
  75 #if EATA_DMA_PROC  
  76 #include "eata_dma_proc.h"  /* If you're interested send me a mail */ 
  77 ulong  reads[13];           /* /proc/scsi probably won't get       */ 
  78 ulong  writes[13];          /* into the kernel before pl. 1.3      */
  79 #endif
  80 
  81 static uint ISAbases[] =
  82 {0x1F0, 0x170, 0x330, 0x230};
  83 static unchar EISAbases[] =
  84 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
  85 static uint registered_HBAs = 0;
  86 static struct Scsi_Host *last_HBA = NULL;
  87 static struct Scsi_Host *first_HBA = NULL;
  88 static unchar reg_IRQ[] =
  89 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  90 static unchar reg_IRQL[] =
  91 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  92 static struct eata_sp *status = 0;   /* Statuspacket array   */
  93 static void *dma_scratch = 0;
  94 
  95 static uint internal_command_finished = TRUE;
  96 static unchar HBA_interpret = FALSE;
  97 static u32 fake_int_base;
  98 static u32 fake_int_result;
  99 static struct geom_emul geometry;       /* Drive 1 & 2 geometry */
 100 
 101 static ulong int_counter = 0;
 102 static ulong queue_counter = 0;
 103 
 104 void eata_scsi_done (Scsi_Cmnd * SCpnt)
     /* [previous][next][first][last][top][bottom][index][help] */
 105 {
 106     return;
 107 }       
 108 
 109 void eata_fake_int_handler(s32 irq, struct pt_regs * regs)
     /* [previous][next][first][last][top][bottom][index][help] */
 110 {
 111     fake_int_result = inb(fake_int_base + HA_RSTATUS);
 112     DBG(DBG_INTR3, printk("eata_fake_int_handler called irq%ld base %#lx res %#lx\n", 
 113                           irq, fake_int_base, fake_int_result));
 114     return;
 115 }
 116 
 117 #if EATA_DMA_PROC 
 118 #include "eata_dma_proc.c"
 119 #endif
 120 
 121 int eata_release(struct Scsi_Host *sh)
     /* [previous][next][first][last][top][bottom][index][help] */
 122 {
 123   if (sh->irq && reg_IRQ[sh->irq] == 1) free_irq(sh->irq);
 124   else reg_IRQ[sh->irq]--;
 125     
 126     scsi_init_free((void *)status, 512);
 127     
 128   if (SD(sh)->channel == 0) {
 129       if (sh->dma_channel != 0xff) free_dma(sh->dma_channel);
 130       if (sh->io_port && sh->n_io_port)
 131           release_region(sh->io_port, sh->n_io_port);
 132   }
 133   return(TRUE);
 134 }
 135 
 136 const char *eata_info(struct Scsi_Host *host)
     /* [previous][next][first][last][top][bottom][index][help] */
 137 {
 138     static char *information = "EATA SCSI HBA Driver";
 139     return information;
 140 }
 141 
 142 void eata_int_handler(int irq, struct pt_regs * regs)
     /* [previous][next][first][last][top][bottom][index][help] */
 143 {
 144     uint i, result = 0;
 145     uint hba_stat, scsi_stat, eata_stat;
 146     Scsi_Cmnd *cmd;
 147     struct eata_ccb *cp;
 148     struct eata_sp *sp;
 149     uint base;
 150     ulong flags;
 151     uint x;
 152     struct Scsi_Host *sh;
 153 
 154     save_flags(flags);
 155     cli();
 156 
 157     for (x = 1, sh = first_HBA; x <= registered_HBAs; x++, sh = SD(sh)->prev) {
 158         if (sh->irq != irq)
 159             continue;
 160         if (!(inb((uint)sh->base + HA_RAUXSTAT) & HA_AIRQ))
 161             continue;
 162 
 163         int_counter++;
 164 
 165         sp=&SD(sh)->sp;
 166 
 167         cp = sp->ccb;
 168         cmd = cp->cmd;
 169         base = (uint) cmd->host->base;
 170 
 171         hba_stat = sp->hba_stat;
 172 
 173         scsi_stat = (sp->scsi_stat >> 1) && 0x1f; 
 174 
 175         if (sp->EOC == FALSE) {
 176             eata_stat = inb(base + HA_RSTATUS);
 177             printk("eata_dma: int_handler, board: %x cmd %lx returned "
 178                    "unfinished.\nEATA: %x HBA: %x SCSI: %x spadr %lx spadrirq "
 179                    "%lx, irq%d\n", base, (long)cp, eata_stat, hba_stat, 
 180                    scsi_stat,(long)&status, (long)&status[irq], irq);
 181             DBG(DBG_DELAY,DEL2(800));
 182             restore_flags(flags);
 183             return;
 184         } 
 185 
 186         if (cp->status == LOCKED) {
 187             cp->status = FREE;
 188             eata_stat = inb(base + HA_RSTATUS);
 189             printk("eata_dma: int_handler, freeing locked queueslot\n");
 190             DBG(DBG_INTR&&DBG_DELAY,DEL2(800));
 191             restore_flags(flags);
 192             return;
 193         }
 194 
 195         eata_stat = inb(base + HA_RSTATUS);     
 196         DBG(DBG_INTR, printk("IRQ %d received, base %#.4x, pid %ld, target: "
 197                              "%x, lun: %x, ea_s: %#.2x, hba_s: %#.2x \n", 
 198                              irq, base, cmd->pid, cmd->target, cmd->lun, 
 199                              eata_stat, hba_stat));
 200 
 201         switch (hba_stat) {
 202         case HA_NO_ERROR:       /* NO Error */
 203             if (scsi_stat == CONDITION_GOOD
 204                 && cmd->device->type == TYPE_DISK
 205                 && (HD(cmd)->t_state[cmd->target] == RESET))
 206                 result = DID_BUS_BUSY << 16;        
 207             else if (scsi_stat == GOOD)
 208               HD(cmd)->t_state[cmd->target] = FALSE;
 209             else if (scsi_stat == CHECK_CONDITION
 210                      && cmd->device->type == TYPE_DISK
 211                      && (cmd->sense_buffer[2] & 0xf) == RECOVERED_ERROR)
 212               result = DID_BUS_BUSY << 16;
 213             else
 214                 result = DID_OK << 16;
 215             HD(cmd)->t_timeout[cmd->target] = FALSE;
 216             break;
 217         case HA_ERR_SEL_TO:             /* Selection Timeout */
 218             result = DID_BAD_TARGET << 16;  
 219             break;
 220         case HA_ERR_CMD_TO:             /* Command Timeout   */
 221             if (HD(cmd)->t_timeout[cmd->target] > 1)
 222                 result = DID_ERROR << 16;
 223             else {
 224                 result = DID_TIME_OUT << 16;
 225                 HD(cmd)->t_timeout[cmd->target]++;
 226             }
 227             break;
 228         case HA_ERR_RESET:              /* SCSI Bus Reset Received */
 229         case HA_INIT_POWERUP:           /* Initial Controller Power-up */
 230             if (cmd->device->type != TYPE_TAPE)
 231                 result = DID_BUS_BUSY << 16;
 232             else
 233                 result = DID_ERROR << 16;
 234 
 235             for (i = 0; i < MAXTARGET; i++)
 236                 HD(cmd)->t_state[i] = RESET;
 237             break;
 238         case HA_UNX_BUSPHASE:       /* Unexpected Bus Phase */
 239         case HA_UNX_BUS_FREE:       /* Unexpected Bus Free */
 240         case HA_BUS_PARITY:         /* Bus Parity Error */
 241         case HA_SCSI_HUNG:          /* SCSI Hung */
 242         case HA_UNX_MSGRJCT:        /* Unexpected Message Reject */
 243         case HA_RESET_STUCK:        /* SCSI Bus Reset Stuck */
 244         case HA_RSENSE_FAIL:        /* Auto Request-Sense Failed */
 245         case HA_PARITY_ERR:         /* Controller Ram Parity */
 246         default:
 247             result = DID_ERROR << 16;
 248             break;
 249         }
 250         cmd->result = result | (scsi_stat << 1); 
 251 
 252 #if DBG_INTR2
 253         if (scsi_stat || result || hba_stat || eata_stat != 0x50) 
 254             printk("eata_stat: %#x hba_stat: %#.2x,scsi_stat: %#.2x, "
 255                    "sense_key: %#x, result: %#.8x\n", eata_stat, hba_stat, 
 256                  scsi_stat,cmd->sense_buffer[2] & 0xf, cmd->result); 
 257         DBG(DBG_INTR&&DBG_DELAY,DEL2(800));
 258 #endif
 259 
 260         cp->status = FREE;   /* now we can release the slot  */
 261  
 262         restore_flags(flags);
 263         if(cmd->scsi_done != eata_scsi_done) cmd->scsi_done(cmd);
 264         else {
 265             internal_command_finished = TRUE;
 266             HBA_interpret = FALSE;
 267         }
 268         save_flags(flags);
 269         cli();
 270     }
 271     restore_flags(flags);
 272 
 273     return;
 274 }
 275 
 276 inline uint eata_send_command(ulong addr, uint base, unchar command)
     /* [previous][next][first][last][top][bottom][index][help] */
 277 {
 278     uint loop = R_LIMIT;
 279 
 280     while (inb(base + HA_RAUXSTAT) & HA_ABUSY)
 281         if (--loop == 0)
 282             return(FALSE);
 283 
 284     outb(addr & 0x000000ff, base + HA_WDMAADDR);
 285     outb((addr & 0x0000ff00) >> 8, base + HA_WDMAADDR + 1);
 286     outb((addr & 0x00ff0000) >> 16, base + HA_WDMAADDR + 2);
 287     outb((addr & 0xff000000) >> 24, base + HA_WDMAADDR + 3);
 288     outb(command, base + HA_WCOMMAND);
 289     return(TRUE);
 290 }
 291 
 292 int eata_queue(Scsi_Cmnd * cmd, void *(done) (Scsi_Cmnd *))
     /* [previous][next][first][last][top][bottom][index][help] */
 293 {
 294     uint i, x, y;
 295     long flags;
 296 
 297     hostdata *hd;
 298     struct Scsi_Host *sh;
 299     struct eata_ccb *cp;
 300     struct scatterlist *sl;
 301 
 302     save_flags(flags);
 303     cli();
 304 
 305     queue_counter++;
 306 
 307     if (done == (void *)eata_scsi_done) { 
 308         if (internal_command_finished == TRUE)
 309             internal_command_finished = FALSE;
 310         else 
 311             cmd->result = (DID_ERROR << 16) + QUEUE_FULL;
 312     }
 313     
 314     hd = HD(cmd);
 315     sh = cmd->host;
 316  
 317     /* check for free slot */
 318      for (y = hd->last_ccb + 1, x = 0; x < sh->can_queue; x++, y++) { 
 319         if (y >= sh->can_queue)
 320             y = 0;
 321         if (hd->ccb[y].status == FREE)
 322             break;
 323     }
 324 
 325     hd->last_ccb = y;
 326 
 327     if (x == sh->can_queue) { 
 328 
 329         DBG(DBG_QUEUE, printk("can_queue %d, x %d, y %d\n",sh->can_queue,x,y));
 330 #if DEBUG_EATA
 331         panic("eata_dma: run out of queue slots cmdno:%ld intrno: %ld\n", 
 332               queue_counter, int_counter);
 333 #else
 334         panic("eata_dma: run out of queue slots....\n");
 335 #endif
 336     }
 337 
 338     cp = &hd->ccb[y];
 339 
 340     memset(cp, 0, sizeof(struct eata_ccb));
 341 
 342     cp->status = USED;          /* claim free slot */
 343     
 344     DBG(DBG_QUEUE, printk("eata_queue pid %ld, target: %x, lun: %x, y %d\n",
 345                           cmd->pid, cmd->target, cmd->lun, y));
 346     DBG(DBG_QUEUE && DBG_DELAY, DEL2(250));
 347  
 348     cmd->scsi_done = (void *)done;
 349 
 350     switch (cmd->cmnd[0]) {
 351     case CHANGE_DEFINITION: case COMPARE:         case COPY:
 352     case COPY_VERIFY:       case LOG_SELECT:      case MODE_SELECT:
 353     case MODE_SELECT_10:    case SEND_DIAGNOSTIC: case WRITE_BUFFER:
 354     case FORMAT_UNIT:       case REASSIGN_BLOCKS: case RESERVE:
 355     case SEARCH_EQUAL:      case SEARCH_HIGH:     case SEARCH_LOW:
 356     case WRITE_6:           case WRITE_10:        case WRITE_VERIFY:
 357     case UPDATE_BLOCK:      case WRITE_LONG:      case WRITE_SAME:      
 358     case SEARCH_HIGH_12:    case SEARCH_EQUAL_12: case SEARCH_LOW_12:
 359     case WRITE_12:          case WRITE_VERIFY_12: case SET_WINDOW: 
 360     case MEDIUM_SCAN:       case SEND_VOLUME_TAG:            
 361     case 0xea:          /* alternate number for WRITE LONG */
 362         cp->DataOut = TRUE;     /* Output mode */
 363         break;
 364     case 0x00:
 365     default:
 366         cp->DataIn = TRUE;      /* Input mode  */
 367     }
 368 
 369     if (done == (void *) eata_scsi_done && HBA_interpret == TRUE) 
 370         cp->Interpret = TRUE;   /* Interpret command */
 371    
 372     if (cmd->use_sg) {
 373         cp->scatter = TRUE;     /* SG mode     */
 374         cp->cp_dataDMA = htonl((long)&cp->sg_list);
 375         cp->cp_datalen = htonl(cmd->use_sg*8);
 376         sl=(struct scatterlist *)cmd->request_buffer;
 377  
 378         for(i = 0; i < cmd->use_sg; i++, sl++){
 379             cp->sg_list[i].data = htonl((ulong) sl->address);
 380             cp->sg_list[i].len = htonl((ulong) sl->length);
 381         }
 382     } else {
 383         cp->scatter = FALSE;
 384         cp->cp_datalen = htonl(cmd->request_bufflen);
 385         cp->cp_dataDMA = htonl((ulong)cmd->request_buffer);
 386     }
 387 
 388     cp->Auto_Req_Sen = TRUE;
 389     cp->cp_reqDMA = htonl((ulong) cmd->sense_buffer);
 390     cp->reqlen = sizeof(cmd->sense_buffer);
 391 
 392     cp->cp_id = cmd->target;
 393     cp->cp_lun = cmd->lun;
 394     cp->cp_dispri = TRUE;
 395     cp->cp_identify = TRUE;
 396     memcpy(cp->cp_cdb, cmd->cmnd, cmd->cmd_len);
 397 
 398     cp->cp_statDMA = htonl((ulong) &(hd->sp));
 399 
 400     cp->cp_viraddr = cp;
 401     cp->cmd = cmd;
 402     cmd->host_scribble = (char *)&hd->ccb[y];   
 403 
 404     if(eata_send_command((ulong) cp, (uint) sh->base, EATA_CMD_DMA_SEND_CP) == FALSE) {
 405       cmd->result = DID_ERROR << 16;
 406       printk("eata_queue target %d, pid %ld, HBA busy, returning DID_ERROR, done.\n",
 407               cmd->target, cmd->pid);
 408       restore_flags(flags);
 409       if(done != (void *)eata_scsi_done) done(cmd);
 410       return (0);
 411     }
 412     DBG(DBG_QUEUE,printk("Queued base %#.4lx pid: %ld target: %x lun: %x slot %d irq %d\n",
 413            (long)sh->base, cmd->pid, cmd->target, cmd->lun, y, sh->irq));
 414     DBG(DBG_QUEUE && DBG_DELAY, DEL2(200));
 415     restore_flags(flags);
 416     return (0);
 417 }
 418 
 419 static volatile int internal_done_flag = 0;
 420 static volatile int internal_done_errcode = 0;
 421 
 422 static void internal_done(Scsi_Cmnd * cmd)
     /* [previous][next][first][last][top][bottom][index][help] */
 423 {
 424     internal_done_errcode = cmd->result;
 425     ++internal_done_flag;
 426 }
 427 
 428 int eata_command(Scsi_Cmnd * cmd)
     /* [previous][next][first][last][top][bottom][index][help] */
 429 {
 430 
 431     DBG(DBG_COM, printk("eata_command: calling eata_queue\n"));
 432 
 433     eata_queue(cmd, (void *)internal_done);
 434 
 435     while (!internal_done_flag);
 436     internal_done_flag = 0;
 437     return (internal_done_errcode);
 438 }
 439 
 440 int eata_abort(Scsi_Cmnd * cmd)
     /* [previous][next][first][last][top][bottom][index][help] */
 441 {
 442     ulong flags;
 443     uint loop = R_LIMIT;
 444 
 445     save_flags(flags);
 446     cli();
 447 
 448     DBG(DBG_ABNORM, printk("eata_abort called pid: %ld target: %x lun: %x reason %x\n",
 449                            cmd->pid, cmd->target, cmd->lun, cmd->abort_reason));
 450     DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 451  
 452 
 453     while (inb((uint)(cmd->host->base) + HA_RAUXSTAT) & HA_ABUSY)
 454         if (--loop == 0) {
 455             printk("eata_dma: abort, timeout error.\n");
 456             restore_flags(flags);
 457             DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 458             return (SCSI_ABORT_ERROR);
 459         }
 460     if (CD(cmd)->status == FREE) {
 461         DBG(DBG_ABNORM, printk("Returning: SCSI_ABORT_NOT_RUNNING\n")); 
 462         restore_flags(flags);
 463         return (SCSI_ABORT_NOT_RUNNING);
 464     }
 465     if (CD(cmd)->status == USED) {
 466         DBG(DBG_ABNORM, printk("Returning: SCSI_ABORT_BUSY\n"));
 467         restore_flags(flags);
 468         return (SCSI_ABORT_BUSY);  /* SNOOZE */ 
 469     }
 470     if (CD(cmd)->status == RESET) {
 471         restore_flags(flags);
 472         printk("eata_dma: abort, command reset error.\n");
 473         DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 474         return (SCSI_ABORT_ERROR);
 475     }
 476     if (CD(cmd)->status == LOCKED) {
 477         restore_flags(flags);
 478         DBG(DBG_ABNORM, printk("eata_dma: abort, queue slot locked.\n"));
 479         DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 480         return (SCSI_ABORT_NOT_RUNNING);
 481     } else
 482         panic("eata_dma: abort: invalid slot status\n");
 483 }
 484 
 485 int eata_reset(Scsi_Cmnd * cmd)
     /* [previous][next][first][last][top][bottom][index][help] */
 486 {
 487     uint x, z, time, limit = 0;
 488     uint loop = R_LIMIT;
 489     ulong flags;
 490     unchar success = FALSE;
 491     Scsi_Cmnd *sp; 
 492 
 493     save_flags(flags);
 494     cli();
 495 
 496     DBG(DBG_ABNORM, printk("eata_reset called pid:%ld target: %x lun: %x reason %x\n",
 497                            cmd->pid, cmd->target, cmd->lun, cmd->abort_reason));
 498 
 499 
 500     if (HD(cmd)->state == RESET) {
 501         printk("eata_reset: exit, already in reset.\n");
 502         restore_flags(flags);
 503         DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 504         return (SCSI_RESET_ERROR);
 505     }
 506 
 507     while (inb((uint)(cmd->host->base) + HA_RAUXSTAT) & HA_ABUSY)
 508         if (--loop == 0) {
 509             printk("eata_reset: exit, timeout error.\n");
 510             restore_flags(flags);
 511             DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 512             return (SCSI_RESET_ERROR);
 513         }
 514     for (z = 0; z < MAXTARGET; z++) {
 515         HD(cmd)->t_state[z] = RESET;
 516         HD(cmd)->t_timeout[z] = FALSE;
 517     }
 518 
 519     for (x = 0; x < cmd->host->can_queue; x++) {
 520 
 521         if (HD(cmd)->ccb[x].status == FREE)
 522             continue;
 523 
 524         if (HD(cmd)->ccb[x].status == LOCKED) {
 525             HD(cmd)->ccb[x].status = FREE;
 526             printk("eata_reset: locked slot %d forced free.\n", x);
 527             DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 528             continue;
 529         }
 530         sp = HD(cmd)->ccb[x].cmd;
 531         HD(cmd)->ccb[x].status = RESET;
 532         printk("eata_reset: slot %d in reset, pid %ld.\n", x, sp->pid);
 533         DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 534  
 535         if (sp == NULL)
 536             panic("eata_reset: slot %d, sp==NULL.\n", x);
 537             DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 538  
 539         if (sp == cmd)
 540             success = TRUE;
 541     }
 542 
 543     /* hard reset the HBA  */
 544     inb((uint) (cmd->host->base) + HA_RSTATUS);  /* This might cause trouble */
 545     eata_send_command(0, (uint) cmd->host->base, EATA_CMD_RESET);
 546 
 547     DBG(DBG_ABNORM, printk("eata_reset: board reset done, enabling interrupts.\n"));
 548     HD(cmd)->state = RESET;
 549 
 550     restore_flags(flags);
 551 
 552     time = jiffies;
 553     while (jiffies < (time + 300) && limit++ < 10000000);
 554 
 555     save_flags(flags);
 556     cli();
 557 
 558     DBG(DBG_ABNORM, printk("eata_reset: interrupts disabled, loops %d.\n", limit));
 559     DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 560  
 561     for (x = 0; x < cmd->host->can_queue; x++) {
 562 
 563         /* Skip slots already set free by interrupt */
 564         if (HD(cmd)->ccb[x].status != RESET)
 565             continue;
 566 
 567         sp = HD(cmd)->ccb[x].cmd;
 568         sp->result = DID_RESET << 16;
 569 
 570         /* This mailbox is still waiting for its interrupt */
 571         HD(cmd)->ccb[x].status = LOCKED;
 572 
 573         printk("eata_reset: slot %d locked, DID_RESET, pid %ld done.\n",
 574             x, sp->pid);
 575         DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 576         restore_flags(flags);
 577         sp->scsi_done(sp);
 578         cli();
 579     }
 580 
 581     HD(cmd)->state = FALSE;
 582     restore_flags(flags);
 583 
 584     if (success) {
 585         DBG(DBG_ABNORM, printk("eata_reset: exit, success.\n"));
 586         DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 587         return (SCSI_RESET_SUCCESS);
 588     } else {
 589         DBG(DBG_ABNORM, printk("eata_reset: exit, wakeup.\n"));
 590         DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
 591         return (SCSI_RESET_PUNT);
 592     }
 593 }
 594 
 595 char * get_board_data(ulong base, uint irq, uint id)
     /* [previous][next][first][last][top][bottom][index][help] */
 596 {
 597     struct eata_ccb cp;
 598     struct eata_sp  sp;
 599     static char *buff;
 600     u32 i;
 601 
 602     buff = dma_scratch;
 603 
 604     memset(&cp, 0, sizeof(struct eata_ccb));
 605     memset(&sp, 0, sizeof(struct eata_sp));
 606     memset(buff, 0, 256);
 607 
 608     cp.DataIn = TRUE;     
 609     cp.Interpret = TRUE;   /* Interpret command */
 610  
 611     cp.cp_datalen = htonl(255);  
 612     cp.cp_dataDMA = htonl((s32)buff);
 613     cp.cp_viraddr = &cp;
 614 
 615     cp.cp_id = id;
 616     cp.cp_lun = 0;
 617 
 618     cp.cp_cdb[0] = INQUIRY;
 619     cp.cp_cdb[1] = 0;
 620     cp.cp_cdb[2] = 0;
 621     cp.cp_cdb[3] = 0;
 622     cp.cp_cdb[4] = 255;
 623     cp.cp_cdb[5] = 0;
 624 
 625     cp.cp_statDMA = htonl((ulong) &sp);
 626 
 627     fake_int_base = base;
 628     fake_int_result = 0;
 629 
 630     eata_send_command((u32) &cp, (u32) base, EATA_CMD_DMA_SEND_CP);
 631     
 632     i = jiffies + 300;
 633     while (!fake_int_result && jiffies <= i) 
 634         /* nothing */;
 635     
 636     DBG(DBG_INTR3, printk("fake_int_result: %#lx hbastat %#lx scsistat %#lx,"
 637                           " buff %p sp %p\n",
 638                           fake_int_result, (u32) (sp.hba_stat & 0x7f), 
 639                           (u32) sp.scsi_stat, buff, &sp));
 640     
 641     if (jiffies > i || (fake_int_result & 1))
 642         return (NULL);
 643     else
 644         return (buff);
 645 }
 646     
 647 int check_blink_state(long base)
     /* [previous][next][first][last][top][bottom][index][help] */
 648 {
 649     uint loops = 10;
 650     ulong blinkindicator = 0x42445054;
 651     ulong state = 0x12345678;
 652     ulong oldstate = 0;
 653 
 654     while ((loops--) && (state != oldstate)) {
 655         oldstate = state;
 656         state = inl((uint) base + 1);
 657     }
 658 
 659     DBG(DBG_BLINK, printk("Did Blink check. Status: %d\n",
 660                           (state == oldstate) && (state == blinkindicator)));
 661 
 662     if ((state == oldstate) && (state == blinkindicator))
 663         return(TRUE);
 664     else
 665         return (FALSE);
 666 }
 667 
 668 int get_conf_PIO(struct eata_register *base, struct get_conf *buf)
     /* [previous][next][first][last][top][bottom][index][help] */
 669 {
 670     ulong loop = R_LIMIT;
 671     ushort *p;
 672 
 673     u8  warning = FALSE;
 674     
 675     if(check_region((int) base, 9)) {
 676         if ((int)base == 0x1f0 || (int)base == 0x170) {
 677             warning = 1;
 678         } else
 679         return (FALSE);
 680     }
 681  
 682     memset(buf, 0, sizeof(struct get_conf));
 683 
 684     while (inb((uint) base + HA_RSTATUS) & HA_SBUSY)
 685         if (--loop == 0) 
 686             return (FALSE);
 687        
 688     DBG(DBG_PIO && DBG_PROBE,printk("Issuing PIO READ CONFIG to HBA at %lx\n", 
 689                                    (long)base));
 690     eata_send_command(0, (uint) base, EATA_CMD_PIO_READ_CONFIG);
 691     loop = R_LIMIT;
 692     for (p = (ushort *) buf; 
 693          (long)p <= ((long)buf + (sizeof(struct get_conf)/ 2)); p++) {
 694         while (!(inb((uint) base + HA_RSTATUS) & HA_SDRQ))
 695             if (--loop == 0)
 696                 return (FALSE);
 697         loop = R_LIMIT;
 698         *p = inw((uint) base + HA_RDATA);
 699     }
 700     if (!(inb((uint) base + HA_RSTATUS) & HA_SERROR)) {         /* Error ? */
 701         DBG(DBG_PIO&&DBG_PROBE, printk("\nSignature: %c%c%c%c\n", 
 702                               (char)buf->sig[0], (char)buf->sig[1], 
 703                               (char)buf->sig[2], (char)buf->sig[3]));
 704 
 705         if ((buf->sig[0] == 'E') && (buf->sig[1] == 'A')
 706             && (buf->sig[2] == 'T') && (buf->sig[3] == 'A')) {
 707             DBG(DBG_PIO&&DBG_PROBE, printk("EATA Controller found at %x "
 708                       "EATA Level: %x\n", (uint) base, (uint) (buf->version)));
 709         
 710             while (inb((uint) base + HA_RSTATUS) & HA_SDRQ) 
 711                 inw((uint) base + HA_RDATA);
 712             if (warning == TRUE)
 713                 printk("Warning: HBA with IO on 0x%p detected,\n"
 714                        "         this IO space is already allocated, probably by the IDE driver.\n"
 715                        "         This might lead to problems.", base);
 716             return (TRUE);
 717         } 
 718     } else {
 719         DBG(DBG_PROBE, printk("eata_dma: get_conf_PIO, error during transfer "
 720                               "for HBA at %lx\n", (long)base));
 721     }
 722     return (FALSE);
 723 }
 724 
 725 void print_config(struct get_conf *gc)
     /* [previous][next][first][last][top][bottom][index][help] */
 726 {
 727     printk("Please check values: (read config data)\n");
 728     printk("LEN: %d ver:%d OCS:%d TAR:%d TRNXFR:%d MORES:%d DMAS:%d\n",
 729         (uint) ntohl(gc->len), gc->version,
 730         gc->OCS_enabled, gc->TAR_support, gc->TRNXFR, gc->MORE_support,
 731         gc->DMA_support);
 732     printk("DMAV:%d HAAV:%d SCSIID0:%d ID1:%d ID2:%d QUEUE:%d SG:%d SEC:%d\n",
 733         gc->DMA_valid, gc->HAA_valid, gc->scsi_id[3], gc->scsi_id[2],
 734         gc->scsi_id[1], ntohs(gc->queuesiz), ntohs(gc->SGsiz), gc->SECOND);
 735     printk("IRQ:%d IRQT:%d DMAC:%d FORCADR:%d MCH:%d RIDQ:%d PCI:%d EISA:%d\n",
 736         gc->IRQ, gc->IRQ_TR, (8 - gc->DMA_channel) & 7, gc->FORCADR, 
 737         gc->MAX_CHAN, gc->ID_qest, gc->is_PCI, gc->is_EISA);
 738     DBG(DPT_DEBUG, DELAY(1400));
 739 }
 740 
 741 int register_HBA(long base, struct get_conf *gc, Scsi_Host_Template * tpnt)
     /* [previous][next][first][last][top][bottom][index][help] */
 742 {
 743     ulong size = 0;
 744     unchar dma_channel = 0;
 745     char *buff;
 746     uint i;
 747     struct Scsi_Host *sh;
 748     hostdata *hd;
 749     
 750     DBG(DBG_REGISTER, print_config(gc));
 751 
 752     if(gc->HAA_valid == FALSE || ntohl(gc->len) < 0x22) 
 753         gc->MAX_CHAN = 0;
 754 
 755     if (!reg_IRQ[gc->IRQ]) {    /* Interrupt already registered ? */
 756         if (!request_irq(gc->IRQ, (void *) eata_fake_int_handler, SA_INTERRUPT, "eata_dma")){
 757             reg_IRQ[gc->IRQ] += (gc->MAX_CHAN+1);
 758             if (!gc->IRQ_TR)
 759                 reg_IRQL[gc->IRQ] = TRUE;       /* IRQ is edge triggered */
 760         } else {
 761             printk("Couldn't allocate IRQ %d, Sorry.", gc->IRQ);
 762             return (FALSE);
 763         }
 764     } else {                    /* More than one HBA on this IRQ */
 765         if (reg_IRQL[gc->IRQ] == TRUE) {
 766             printk("Can't support more than one HBA on this IRQ,\n"
 767                    "  if the IRQ is edge triggered. Sorry.\n");
 768             return (FALSE);
 769         } else
 770             reg_IRQ[gc->IRQ] += (gc->MAX_CHAN+1);
 771     }
 772 
 773     /* if gc->DMA_valid it must be an ISA HBA and we have to register it */
 774     dma_channel = 0xff;
 775     if (gc->DMA_valid) {
 776         if (request_dma(dma_channel = (8 - gc->DMA_channel) & 7, "eata_dma")) {
 777             printk("Unable to allocate DMA channel %d for ISA HBA at %#.4lx.\n",
 778                    dma_channel, base);
 779             reg_IRQ[gc->IRQ] -= (gc->MAX_CHAN+1);
 780             if (reg_IRQ[gc->IRQ] == 0)
 781                 free_irq(gc->IRQ);
 782             if (!gc->IRQ_TR)
 783                 reg_IRQL[gc->IRQ] = FALSE; 
 784             return (FALSE);
 785         }
 786     } 
 787     
 788     buff = get_board_data(base, gc->IRQ, gc->scsi_id[3]);
 789 
 790     if (buff == NULL) {
 791         if (gc->DMA_support == FALSE)
 792             printk("HBA at %#.4lx doesn't support DMA. Sorry\n", base);
 793         else
 794             printk("HBA at %#.4lx didn't react on INQUIRY. Sorry.\n", base);
 795         if (gc->DMA_valid) 
 796             free_dma(dma_channel);
 797         reg_IRQ[gc->IRQ] -= (gc->MAX_CHAN+1);
 798         if (reg_IRQ[gc->IRQ] == 0)
 799             free_irq(gc->IRQ);
 800         if (!gc->IRQ_TR)
 801             reg_IRQL[gc->IRQ] = FALSE; 
 802         return (FALSE);
 803     }
 804     
 805     if (gc->DMA_support == FALSE && buff != NULL)  
 806         printk("HBA %.12sat %#.4lx doesn't set the DMA_support flag correctly.\n",
 807                &buff[16], base);
 808     
 809     request_region(base, 9, "eata_dma"); /* We already checked the 
 810                                           * availability, so this could 
 811                                           * only fail if we're on 
 812                                           * 0x1f0 or 0x170.
 813                                           */
 814 
 815     if(ntohs(gc->queuesiz) == 0) {
 816         gc->queuesiz = ntohs(64);
 817             printk("Warning: Queue size had to be corrected.\n"
 818                    "This might be a PM2012 with a defective Firmware\n");
 819     }
 820 
 821     size = sizeof(hostdata) + ((sizeof(struct eata_ccb) * ntohs(gc->queuesiz))/
 822                                (gc->MAX_CHAN + 1));
 823 
 824     if (gc->MAX_CHAN) {
 825         printk("This is a multichannel HBA. Linux doesn't support them,\n");
 826         printk("so we'll try to register every channel as a virtual HBA.\n");
 827     }
 828     
 829     for (i = 0; i <= gc->MAX_CHAN; i++) {
 830 
 831         sh = scsi_register(tpnt, size);
 832 
 833         if(sh == NULL) {
 834             if (gc->DMA_valid) 
 835                 free_dma(dma_channel);
 836             reg_IRQ[gc->IRQ] -= 1;
 837             if (reg_IRQ[gc->IRQ] == 0)
 838                 free_irq(gc->IRQ);
 839             if (!gc->IRQ_TR)
 840                 reg_IRQL[gc->IRQ] = FALSE; 
 841             return (FALSE);
 842         }
 843 
 844         hd = SD(sh);                   
 845 
 846         memset(hd->ccb, 0, (sizeof(struct eata_ccb) * ntohs(gc->queuesiz)) / 
 847                (gc->MAX_CHAN + 1));
 848         memset(hd->reads, 0, sizeof(ulong) * 26); 
 849  
 850         strncpy(SD(sh)->vendor, &buff[8], 8);
 851         SD(sh)->vendor[8] = 0;
 852         strncpy(SD(sh)->name, &buff[16], 17);
 853         SD(sh)->name[17] = 0;
 854         SD(sh)->revision[0] = buff[32];
 855         SD(sh)->revision[1] = buff[33];
 856         SD(sh)->revision[2] = buff[34];
 857         SD(sh)->revision[3] = '.';
 858         SD(sh)->revision[4] = buff[35];
 859         SD(sh)->revision[5] = 0;
 860         switch (ntohl(gc->len)) {
 861         case 0x1c:
 862             SD(sh)->EATA_revision = 'a';
 863             break;
 864         case 0x1e:
 865             SD(sh)->EATA_revision = 'b';
 866             break;
 867         case 0x22:
 868             SD(sh)->EATA_revision = 'c';
 869             break;
 870         default:
 871             SD(sh)->EATA_revision = '?';
 872         }
 873         sh->base = (char *) base;
 874         sh->io_port = (ushort) base;
 875         sh->n_io_port = 9;
 876         sh->irq = gc->IRQ;
 877         sh->dma_channel = dma_channel;
 878         sh->this_id = gc->scsi_id[3 - i];
 879         sh->can_queue = ntohs(gc->queuesiz) / (gc->MAX_CHAN + 1);
 880 
 881         if (gc->OCS_enabled == TRUE) {
 882             sh->cmd_per_lun = sh->can_queue/C_P_L_DIV; 
 883 #if 0   /* The memory management seems to be more stable now */
 884             if (sh->cmd_per_lun > C_P_L_CURRENT_MAX)
 885                 sh->cmd_per_lun = C_P_L_CURRENT_MAX;
 886 #endif
 887         } else {
 888             sh->cmd_per_lun = 1;
 889         }
 890         sh->sg_tablesize = ntohs(gc->SGsiz);
 891         if (sh->sg_tablesize > SG_SIZE || sh->sg_tablesize == 0) {
 892             sh->sg_tablesize = SG_SIZE;
 893             if (ntohs(gc->SGsiz) == 0)
 894                 printk("Warning: SG size had to be corrected.\n"
 895                        "This might be a PM2012 with a defective Firmware\n");
 896         }
 897 
 898         hd->channel = i;
 899 
 900         if (buff[21] == '4')
 901             hd->bustype = 'P';
 902         else if (buff[21] == '2')
 903             hd->bustype = 'E';
 904         else
 905             hd->bustype = 'I';
 906 
 907         if (gc->SECOND)
 908             hd->primary = FALSE;
 909         else
 910             hd->primary = TRUE;
 911 
 912         if (hd->bustype != 'I') {
 913             sh->unchecked_isa_dma = FALSE;
 914             sh->wish_block = FALSE;        
 915         }
 916         else {
 917             sh->unchecked_isa_dma = TRUE;   /* We're doing ISA DMA */
 918             sh->wish_block = TRUE;          /* This will reduce performance */
 919         }
 920         if((hd->primary == TRUE) && (i == 0) && HARDCODED){                  
 921           geometry.drv[0].heads = HEADS0;          
 922           geometry.drv[0].sectors = SECTORS0;      
 923           geometry.drv[0].cylinder = CYLINDER0;
 924           geometry.drv[0].id = ID0;
 925           geometry.drv[0].trans = TRUE;
 926           geometry.drv[1].heads = HEADS1;
 927           geometry.drv[1].sectors = SECTORS1;
 928           geometry.drv[1].cylinder = CYLINDER1;
 929           geometry.drv[1].id = ID1;
 930           geometry.drv[1].trans = TRUE;
 931         } else {
 932           geometry.drv[0].id=-1;
 933           geometry.drv[1].id=-1;
 934         }
 935 
 936         hd->next = NULL;        /* build a linked list of all HBAs */
 937         hd->prev = last_HBA;
 938         if(hd->prev != NULL)
 939             SD(hd->prev)->next = sh;
 940         last_HBA = sh;
 941         if (first_HBA == NULL)
 942             first_HBA = sh;
 943         registered_HBAs++;
 944     }
 945     return (1);
 946 }
 947 
 948 
 949 long find_EISA(struct get_conf *buf)
     /* [previous][next][first][last][top][bottom][index][help] */
 950 {
 951     struct eata_register *base;
 952     int i;
 953 
 954 #if CHECKPAL
 955     unsigned char pal1, pal2, pal3, *p;
 956 #endif
 957 
 958     for (i = 0; i < MAXEISA; i++) {
 959         if (EISAbases[i] == TRUE) {     /* Still a possibility ?          */
 960 
 961             base = (void *)0x1c88 + (i * 0x1000);
 962 #if CHECKPAL
 963             p = (char *)base;
 964             pal1 = *(p - 8);
 965             pal2 = *(p - 7);
 966             pal3 = *(p - 6);
 967 
 968             if (((pal1 == 0x12) && (pal2 == 0x14)) ||
 969                 ((pal1 == 0x38) && (pal2 == 0xa3) && (pal3 == 0x82)) ||
 970                 ((pal1 == 0x06) && (pal2 == 0x94) && (pal3 == 0x24))) {
 971                 DBG(DBG_PROBE, printk("EISA EATA id tags found: %x %x %x \n",
 972                         (int)pal1, (int)pal2, (int)pal3));
 973 #endif
 974                 if (get_conf_PIO(base, buf) == TRUE) {
 975                     DBG(DBG_PROBE&&DBG_EISA,print_config(buf));
 976                     if (buf->IRQ) {          /* We'll check the 
 977                                               * primary/secondary stuff
 978                                               * later
 979                                               */
 980                         EISAbases[i] = 0;
 981                         return ((ulong)base);
 982                     } 
 983                     printk("No valid IRQ. HBA removed from list\n");
 984                 } 
 985                 /* Nothing found here so we take it from the list */
 986                 EISAbases[i] = 0;  
 987 #if CHECKPAL
 988             } 
 989 #endif
 990         }
 991     }
 992     return (0l);                /* Nothing found  :-(             */
 993 }
 994 
 995 long find_ISA(struct get_conf *buf)
     /* [previous][next][first][last][top][bottom][index][help] */
 996 {
 997     int l;
 998     long ret;
 999 
1000     for (l = 0; l < MAXISA; l++) {      
1001         if (ISAbases[l]) {      
1002             if (get_conf_PIO((struct eata_register *)ISAbases[l],buf) == TRUE){
1003                 ret = ISAbases[l];
1004                 ISAbases[l] = 0;
1005                 return (ret);
1006             } else
1007                 ISAbases[l] = 0;
1008         }
1009     }
1010     return ((long)NULL);
1011 }
1012 
1013 void find_PCI(struct get_conf *buf, Scsi_Host_Template * tpnt)
     /* [previous][next][first][last][top][bottom][index][help] */
1014 {
1015 
1016 #ifndef CONFIG_PCI
1017     printk("Kernel PCI support not enabled. Skipping scan for PCI HBAs.\n");
1018 #else
1019 
1020     unchar pci_bus, pci_device_fn;
1021     static short pci_index = 0; /* Device index to PCI BIOS calls */
1022     ulong base = 0;
1023     ushort com_adr;
1024     ushort rev_device;
1025     uint error, i, x;
1026 
1027     if (pcibios_present()) {
1028         for (i = 0; i <= MAXPCI; ++i, ++pci_index) {
1029 
1030             if (pcibios_find_device(PCI_VENDOR_ID_DPT, PCI_DEVICE_ID_DPT, 
1031                                     pci_index, &pci_bus, &pci_device_fn))
1032                 break;
1033             DBG(DBG_PROBE && DBG_PCI, printk("eata_dma: HBA at bus %d, device %d,"
1034                                 " function %d, index %d\n", (int)pci_bus, 
1035                                 (int)((pci_device_fn & 0xf8) >> 3),
1036                                 (int)(pci_device_fn & 7), pci_index));
1037 
1038             if (!(error = pcibios_read_config_word(pci_bus, pci_device_fn, 
1039                                                  PCI_CLASS_DEVICE, &rev_device))) {
1040                 if (rev_device == PCI_CLASS_STORAGE_SCSI) {
1041                     if (!(error = pcibios_read_config_word(pci_bus, 
1042                                                            pci_device_fn, PCI_COMMAND, 
1043                                                            (ushort *) & com_adr))) {
1044                         if (!((com_adr & PCI_COMMAND_IO) && 
1045                               (com_adr & PCI_COMMAND_MASTER))) {
1046                             printk("HBA has IO or BUSMASTER mode disabled\n");
1047                             continue;
1048                         }
1049                     } else
1050                         printk("error %x while reading PCI_COMMAND\n", error);
1051                 } else
1052                   printk("DEVICECLASSID %x didn't match\n", rev_device);
1053             } else {
1054               printk("error %x while reading PCI_CLASS_BASE\n", error);
1055               continue;
1056             }
1057 
1058             if (!(error = pcibios_read_config_dword(pci_bus, pci_device_fn,
1059                                                   PCI_BASE_ADDRESS_0, &base))){
1060 
1061                 /* Check if the address is valid */
1062                 if (base & 0x01) {
1063                     base &= 0xfffffffe;
1064                                         /* EISA tag there ? */
1065                     if ((inb(base) == 0x12) && (inb(base + 1) == 0x14))
1066                         continue;       /* Jep, it's forced, so move on  */
1067                     base += 0x10;       /* Now, THIS is the real address */
1068                     if (base != 0x1f8) {
1069                         /* We didn't find it in the primary search */
1070                         if (get_conf_PIO((struct eata_register *)base, buf)) {
1071                             if (buf->FORCADR)   /* If the address is forced */
1072                                 continue;       /* we'll find it later      */
1073 
1074                             /* OK. We made it till here, so we can go now  
1075                              * and register it. We  only have to check and 
1076                              * eventually remove it from the EISA and ISA list 
1077                              */
1078 
1079                             register_HBA(base, buf, tpnt);
1080 
1081                             if (base < 0x1000) {
1082                                 for (x = 0; x < MAXISA; ++x) {
1083                                     if (ISAbases[x] == base) {
1084                                         ISAbases[x] = 0;
1085                                         break;
1086                                     }
1087                                 }
1088                             } else if ((base & 0x0fff) == 0x0c88) {
1089                                 x = (base >> 12) & 0x0f;
1090                                 EISAbases[x] = 0;
1091                             }
1092                             continue;  /*break;*/
1093                         } else if (check_blink_state(base)) {
1094                             printk("HBA is in BLINK state. Consult your HBAs "
1095                                    " Manual to correct this.\n");
1096                         }
1097                     }
1098                 }
1099             } else
1100               printk("error %x while reading PCI_BASE_ADDRESS_0\n", error);
1101         }
1102     } else
1103     printk("No BIOS32 extensions present. This release still depends on it."
1104              " Sorry.\n");
1105 #endif /* #ifndef CONFIG_PCI */
1106     return;
1107 }
1108 
1109 int eata_detect(Scsi_Host_Template * tpnt)
     /* [previous][next][first][last][top][bottom][index][help] */
1110 {
1111     struct Scsi_Host *HBA_ptr;
1112     struct get_conf gc;
1113     ulong base = 0;
1114     int i;
1115  
1116     geometry.drv[0].trans = geometry.drv[1].trans = 0;
1117 
1118     DBG((DBG_PROBE && DBG_DELAY)|| DPT_DEBUG,
1119         printk("Using lots of delays to let you read the debugging output\n"));
1120 
1121     status = scsi_init_malloc(512, GFP_ATOMIC | GFP_DMA);
1122     dma_scratch = scsi_init_malloc(512, GFP_ATOMIC | GFP_DMA);
1123 
1124     find_PCI(&gc, tpnt);
1125 
1126     for (i = 0; i < MAXEISA; i++) {
1127         base = find_EISA(&gc);
1128         if (base)
1129             register_HBA(base, &gc, tpnt);
1130     }
1131 
1132     for (i = 0; i <= MAXISA; i++) {
1133         base = find_ISA(&gc);
1134         if (base)
1135             register_HBA(base, &gc, tpnt);
1136     }
1137 
1138     for (i = 0; i <= MAXIRQ; i++)
1139         if (reg_IRQ[i]){
1140             free_irq(i);
1141             request_irq(i, eata_int_handler, SA_INTERRUPT, "EATA-DMA");
1142         }
1143 
1144     HBA_ptr = first_HBA;
1145 
1146     if (registered_HBAs != 0) {
1147         printk("EATA (Extended Attachment) driver version: %d.%d%s\n"
1148                "developed in co-operation with DPT\n"             
1149                "(c) 1993-95 Michael Neuffer  neuffer@goofy.zdv.uni-mainz.de\n",
1150                VER_MAJOR, VER_MINOR, VER_SUB);
1151     printk("Registered HBAs:\n");
1152     printk("HBA no. Boardtype: Revis: EATA: Bus: BaseIO: IRQ: DMA: Ch: ID: Pr: QS: SG: CPL:\n");
1153     for (i = 1; i <= registered_HBAs; i++) {
1154             printk("scsi%-2d: %.10s v%s 2.0%c  %s %#.4lx   %2d",
1155                HBA_ptr->host_no, SD(HBA_ptr)->name, SD(HBA_ptr)->revision,
1156                SD(HBA_ptr)->EATA_revision, (SD(HBA_ptr)->bustype == 'P')? 
1157                "PCI ":(SD(HBA_ptr)->bustype == 'E')?"EISA":"ISA ",
1158                    (u32) HBA_ptr->base, HBA_ptr->irq);
1159             if(HBA_ptr->dma_channel != 0xff)
1160                 printk("   %2x ", HBA_ptr->dma_channel);
1161             else
1162                 printk("  %s", "BMST");
1163             printk("  %d   %d   %c  %2d  %2d   %2d\n", SD(HBA_ptr)->channel, 
1164                    HBA_ptr->this_id, (SD(HBA_ptr)->primary == TRUE)?'Y':'N', 
1165                HBA_ptr->can_queue, HBA_ptr->sg_tablesize, HBA_ptr->cmd_per_lun);
1166         HBA_ptr = SD(HBA_ptr)->next;
1167     }
1168     } else 
1169         scsi_init_free((void *)status, 512);
1170     
1171     scsi_init_free((void *)dma_scratch, 512);
1172 
1173     DBG(DPT_DEBUG,DELAY(1200));
1174 
1175     return (registered_HBAs);
1176 }
1177 
1178 #ifdef MODULE
1179 /* Eventually this will go into an include file, but this will be later */
1180 Scsi_Host_Template driver_template = EATA_DMA;
1181 
1182 #include "scsi_module.c"
1183 #endif
1184  
1185 

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