Import 2.1.42pre1
[davej-history.git] / drivers / scsi / g_NCR5380.c
blob5bffb2762e27d5372fe7b40a5fd148e3e4a56c35
1 /*
2 * Generic Generic NCR5380 driver
3 *
4 * Copyright 1993, Drew Eckhardt
5 * Visionary Computing
6 * (Unix and Linux consulting and custom programming)
7 * drew@colorado.edu
8 * +1 (303) 440-4894
10 * NCR53C400 extensions (c) 1994,1995,1996, Kevin Lentin
11 * K.Lentin@cs.monash.edu.au
13 * ALPHA RELEASE 1.
15 * For more information, please consult
17 * NCR 5380 Family
18 * SCSI Protocol Controller
19 * Databook
21 * NCR Microelectronics
22 * 1635 Aeroplaza Drive
23 * Colorado Springs, CO 80916
24 * 1+ (719) 578-3400
25 * 1+ (800) 334-5454
28 /*
29 * TODO : flesh out DMA support, find some one actually using this (I have
30 * a memory mapped Trantor board that works fine)
34 * Options :
36 * PARITY - enable parity checking. Not supported.
38 * SCSI2 - enable support for SCSI-II tagged queueing. Untested.
40 * USLEEP - enable support for devices that don't disconnect. Untested.
42 * The card is detected and initialized in one of several ways :
43 * 1. With command line overrides - NCR5380=port,irq may be
44 * used on the LILO command line to override the defaults.
46 * 2. With the GENERIC_NCR5380_OVERRIDE compile time define. This is
47 * specified as an array of address, irq, dma, board tuples. Ie, for
48 * one board at 0x350, IRQ5, no dma, I could say
49 * -DGENERIC_NCR5380_OVERRIDE={{0xcc000, 5, DMA_NONE, BOARD_NCR5380}}
51 * -1 should be specified for no or DMA interrupt, -2 to autoprobe for an
52 * IRQ line if overridden on the command line.
54 * 3. When included as a module, with arguments passed on the command line:
55 * ncr_irq=xx the interrupt
56 * ncr_addr=xx the port or base address (for port or memory
57 * mapped, resp.)
58 * ncr_dma=xx the DMA
59 * ncr_5380=1 to set up for a NCR5380 board
60 * ncr_53c400=1 to set up for a NCR53C400 board
61 * e.g.
62 * modprobe g_NCR5380 ncr_irq=5 ncr_addr=0x350 ncr_5380=1
63 * for a port mapped NCR5380 board or
64 * modprobe g_NCR5380 ncr_irq=255 ncr_addr=0xc8000 ncr_53c400=1
65 * for a memory mapped NCR53C400 board with interrupts disabled.
67 * 255 should be specified for no or DMA interrupt, 254 to autoprobe for an
68 * IRQ line if overridden on the command line.
73 * $Log: generic_NCR5380.c,v $
76 #define AUTOPROBE_IRQ
77 #define AUTOSENSE
79 #include <linux/config.h>
81 #ifdef CONFIG_SCSI_GENERIC_NCR53C400
82 #define NCR53C400_PSEUDO_DMA 1
83 #define PSEUDO_DMA
84 #define NCR53C400
85 #define NCR5380_STATS
86 #undef NCR5380_STAT_LIMIT
87 #endif
88 #if defined(CONFIG_SCSI_G_NCR5380_PORT) && defined(CONFIG_SCSI_G_NCR5380_MEM)
89 #error You can not configure the Generic NCR 5380 SCSI Driver for memory mapped I/O and port mapped I/O at the same time (yet)
90 #endif
91 #if !defined(CONFIG_SCSI_G_NCR5380_PORT) && !defined(CONFIG_SCSI_G_NCR5380_MEM)
92 #error You must configure the Generic NCR 5380 SCSI Driver for one of memory mapped I/O and port mapped I/O.
93 #endif
95 #include <asm/system.h>
96 #include <asm/io.h>
97 #include <linux/signal.h>
98 #include <linux/sched.h>
99 #include <linux/blk.h>
100 #include "scsi.h"
101 #include "hosts.h"
102 #include "g_NCR5380.h"
103 #include "NCR5380.h"
104 #include "constants.h"
105 #include "sd.h"
106 #include <linux/stat.h>
107 #include <linux/init.h>
109 struct proc_dir_entry proc_scsi_g_ncr5380 = {
110 PROC_SCSI_GENERIC_NCR5380, 9, "g_NCR5380",
111 S_IFDIR | S_IRUGO | S_IXUGO, 2
114 #define NCR_NOT_SET 0
115 static int ncr_irq=NCR_NOT_SET;
116 static int ncr_dma=NCR_NOT_SET;
117 static int ncr_addr=NCR_NOT_SET;
118 static int ncr_5380=NCR_NOT_SET;
119 static int ncr_53c400=NCR_NOT_SET;
121 static struct override {
122 NCR5380_implementation_fields;
123 int irq;
124 int dma;
125 int board; /* Use NCR53c400, Ricoh, etc. extensions ? */
126 } overrides
127 #ifdef GENERIC_NCR5380_OVERRIDE
128 [] __initdata = GENERIC_NCR5380_OVERRIDE
129 #else
130 [1] __initdata = {{0,},};
131 #endif
133 #define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override))
136 * Function : static internal_setup(int board, char *str, int *ints)
138 * Purpose : LILO command line initialization of the overrides array,
140 * Inputs : board - either BOARD_NCR5380 for a normal NCR5380 board,
141 * or BOARD_NCR53C400 for a NCR53C400 board. str - unused, ints -
142 * array of integer parameters with ints[0] equal to the number of ints.
146 __initfunc(static void internal_setup(int board, char *str, int *ints)) {
147 static int commandline_current = 0;
148 switch (board) {
149 case BOARD_NCR5380:
150 if (ints[0] != 2 && ints[0] != 3) {
151 printk("generic_NCR5380_setup : usage ncr5380=" STRVAL(NCR5380_map_name) ",irq,dma\n");
152 return;
154 case BOARD_NCR53C400:
155 if (ints[0] != 2) {
156 printk("generic_NCR53C400_setup : usage ncr53c400=" STRVAL(NCR5380_map_name) ",irq\n");
157 return;
161 if (commandline_current < NO_OVERRIDES) {
162 overrides[commandline_current].NCR5380_map_name = (NCR5380_map_type)ints[1];
163 overrides[commandline_current].irq = ints[2];
164 if (ints[0] == 3)
165 overrides[commandline_current].dma = ints[3];
166 else
167 overrides[commandline_current].dma = DMA_NONE;
168 overrides[commandline_current].board = board;
169 ++commandline_current;
174 * Function : generic_NCR5380_setup (char *str, int *ints)
176 * Purpose : LILO command line initialization of the overrides array,
178 * Inputs : str - unused, ints - array of integer parameters with ints[0]
179 * equal to the number of ints.
182 __initfunc(void generic_NCR5380_setup (char *str, int *ints)) {
183 internal_setup (BOARD_NCR5380, str, ints);
187 * Function : generic_NCR53C400_setup (char *str, int *ints)
189 * Purpose : LILO command line initialization of the overrides array,
191 * Inputs : str - unused, ints - array of integer parameters with ints[0]
192 * equal to the number of ints.
195 __initfunc(void generic_NCR53C400_setup (char *str, int *ints)) {
196 internal_setup (BOARD_NCR53C400, str, ints);
200 * Function : int generic_NCR5380_detect(Scsi_Host_Template * tpnt)
202 * Purpose : initializes generic NCR5380 driver based on the
203 * command line / compile time port and irq definitions.
205 * Inputs : tpnt - template for this SCSI adapter.
207 * Returns : 1 if a host adapter was found, 0 if not.
211 __initfunc(int generic_NCR5380_detect(Scsi_Host_Template * tpnt)) {
212 static int current_override = 0;
213 int count;
214 int flags = 0;
215 struct Scsi_Host *instance;
217 if (ncr_irq != NCR_NOT_SET)
218 overrides[0].irq=ncr_irq;
219 if (ncr_dma != NCR_NOT_SET)
220 overrides[0].dma=ncr_dma;
221 if (ncr_addr != NCR_NOT_SET)
222 overrides[0].NCR5380_map_name=(NCR5380_map_type)ncr_addr;
223 if (ncr_5380 != NCR_NOT_SET)
224 overrides[0].board=BOARD_NCR5380;
225 else if (ncr_53c400 != NCR_NOT_SET)
226 overrides[0].board=BOARD_NCR53C400;
228 tpnt->proc_dir = &proc_scsi_g_ncr5380;
230 for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
231 if (!(overrides[current_override].NCR5380_map_name))
232 continue;
234 switch (overrides[current_override].board) {
235 case BOARD_NCR5380:
236 flags = FLAG_NO_PSEUDO_DMA;
237 break;
238 case BOARD_NCR53C400:
239 flags = FLAG_NCR53C400;
240 break;
243 instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
244 instance->NCR5380_instance_name = overrides[current_override].NCR5380_map_name;
246 NCR5380_init(instance, flags);
248 if (overrides[current_override].irq != IRQ_AUTO)
249 instance->irq = overrides[current_override].irq;
250 else
251 instance->irq = NCR5380_probe_irq(instance, 0xffff);
253 if (instance->irq != IRQ_NONE)
254 if (request_irq(instance->irq, generic_NCR5380_intr, SA_INTERRUPT, "NCR5380", NULL)) {
255 printk("scsi%d : IRQ%d not free, interrupts disabled\n",
256 instance->host_no, instance->irq);
257 instance->irq = IRQ_NONE;
260 if (instance->irq == IRQ_NONE) {
261 printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
262 printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
265 printk("scsi%d : at " STRVAL(NCR5380_map_name) " 0x%x", instance->host_no, (unsigned int)instance->NCR5380_instance_name);
266 if (instance->irq == IRQ_NONE)
267 printk (" interrupts disabled");
268 else
269 printk (" irq %d", instance->irq);
270 printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
271 CAN_QUEUE, CMD_PER_LUN, GENERIC_NCR5380_PUBLIC_RELEASE);
272 NCR5380_print_options(instance);
273 printk("\n");
275 ++current_override;
276 ++count;
278 return count;
281 const char * generic_NCR5380_info (struct Scsi_Host* host) {
282 static const char string[]="Generic NCR5380/53C400 Driver";
283 return string;
286 int generic_NCR5380_release_resources(struct Scsi_Host * instance)
288 NCR5380_local_declare();
290 NCR5380_setup(instance);
292 if (instance->irq != IRQ_NONE)
293 free_irq(instance->irq, NULL);
295 return 0;
298 #ifdef BIOSPARAM
300 * Function : int generic_NCR5380_biosparam(Disk * disk, kdev_t dev, int *ip)
302 * Purpose : Generates a BIOS / DOS compatible H-C-S mapping for
303 * the specified device / size.
305 * Inputs : size = size of device in sectors (512 bytes), dev = block device
306 * major / minor, ip[] = {heads, sectors, cylinders}
308 * Returns : always 0 (success), initializes ip
313 * XXX Most SCSI boards use this mapping, I could be incorrect. Some one
314 * using hard disks on a trantor should verify that this mapping corresponds
315 * to that used by the BIOS / ASPI driver by running the linux fdisk program
316 * and matching the H_C_S coordinates to what DOS uses.
319 int generic_NCR5380_biosparam(Disk * disk, kdev_t dev, int *ip)
321 int size = disk->capacity;
322 ip[0] = 64;
323 ip[1] = 32;
324 ip[2] = size >> 11;
325 return 0;
327 #endif
329 #if NCR53C400_PSEUDO_DMA
330 static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst, int len)
332 int blocks = len / 128;
333 int start = 0;
334 int bl;
335 #ifdef CONFIG_SCSI_G_NCR5380_PORT
336 int i;
337 #endif
339 NCR5380_local_declare();
341 NCR5380_setup(instance);
343 #if (NDEBUG & NDEBUG_C400_PREAD)
344 printk("53C400r: About to read %d blocks for %d bytes\n", blocks, len);
345 #endif
347 NCR5380_write(C400_CONTROL_STATUS_REG, CSR_BASE | CSR_TRANS_DIR);
348 NCR5380_write(C400_BLOCK_COUNTER_REG, blocks);
349 while (1) {
351 #if (NDEBUG & NDEBUG_C400_PREAD)
352 printk("53C400r: %d blocks left\n", blocks);
353 #endif
355 if ((bl=NCR5380_read(C400_BLOCK_COUNTER_REG)) == 0) {
356 #if (NDEBUG & NDEBUG_C400_PREAD)
357 if (blocks)
358 printk("53C400r: blocks still == %d\n", blocks);
359 else
360 printk("53C400r: Exiting loop\n");
361 #endif
362 break;
365 #if 1
366 if (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ) {
367 printk("53C400r: Got 53C80_IRQ start=%d, blocks=%d\n", start, blocks);
368 return -1;
370 #endif
372 #if (NDEBUG & NDEBUG_C400_PREAD)
373 printk("53C400r: Waiting for buffer, bl=%d\n", bl);
374 #endif
376 while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY)
378 #if (NDEBUG & NDEBUG_C400_PREAD)
379 printk("53C400r: Transferring 128 bytes\n");
380 #endif
382 #ifdef CONFIG_SCSI_G_NCR5380_PORT
383 for (i=0; i<128; i++)
384 dst[start+i] = NCR5380_read(C400_HOST_BUFFER);
385 #else
386 /* implies CONFIG_SCSI_G_NCR5380_MEM */
387 memmove(dst+start,NCR53C400_host_buffer+NCR5380_map_name,128);
388 #endif
389 start+=128;
390 blocks--;
393 if (blocks) {
394 #if (NDEBUG & NDEBUG_C400_PREAD)
395 printk("53C400r: EXTRA: Waiting for buffer\n");
396 #endif
397 while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY)
400 #if (NDEBUG & NDEBUG_C400_PREAD)
401 printk("53C400r: Transferring EXTRA 128 bytes\n");
402 #endif
403 #ifdef CONFIG_SCSI_G_NCR5380_PORT
404 for (i=0; i<128; i++)
405 dst[start+i] = NCR5380_read(C400_HOST_BUFFER);
406 #else
407 /* implies CONFIG_SCSI_G_NCR5380_MEM */
408 memmove(dst+start,NCR53C400_host_buffer+NCR5380_map_name,128);
409 #endif
410 start+=128;
411 blocks--;
413 #if (NDEBUG & NDEBUG_C400_PREAD)
414 else
415 printk("53C400r: No EXTRA required\n");
416 #endif
418 #if (NDEBUG & NDEBUG_C400_PREAD)
419 printk("53C400r: Final values: blocks=%d start=%d\n", blocks, start);
420 #endif
422 if (!(NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ))
423 printk("53C400r: no 53C80 gated irq after transfer");
424 #if (NDEBUG & NDEBUG_C400_PREAD)
425 else
426 printk("53C400r: Got 53C80 interrupt and tried to clear it\n");
427 #endif
429 /* DON'T DO THIS - THEY NEVER ARRIVE!
430 printk("53C400r: Waiting for 53C80 registers\n");
431 while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_53C80_REG)
435 if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_END_DMA_TRANSFER))
436 printk("53C400r: no end dma signal\n");
437 #if (NDEBUG & NDEBUG_C400_PREAD)
438 else
439 printk("53C400r: end dma as expected\n");
440 #endif
442 NCR5380_write(MODE_REG, MR_BASE);
443 NCR5380_read(RESET_PARITY_INTERRUPT_REG);
444 return 0;
447 static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src, int len)
449 int blocks = len / 128;
450 int start = 0;
451 int i;
452 int bl;
453 NCR5380_local_declare();
455 NCR5380_setup(instance);
457 #if (NDEBUG & NDEBUG_C400_PWRITE)
458 printk("53C400w: About to write %d blocks for %d bytes\n", blocks, len);
459 #endif
461 NCR5380_write(C400_CONTROL_STATUS_REG, CSR_BASE);
462 NCR5380_write(C400_BLOCK_COUNTER_REG, blocks);
463 while (1) {
464 if (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ) {
465 printk("53C400w: Got 53C80_IRQ start=%d, blocks=%d\n", start, blocks);
466 return -1;
469 if ((bl=NCR5380_read(C400_BLOCK_COUNTER_REG)) == 0) {
470 #if (NDEBUG & NDEBUG_C400_PWRITE)
471 if (blocks)
472 printk("53C400w: exiting loop, blocks still == %d\n", blocks);
473 else
474 printk("53C400w: exiting loop\n");
475 #endif
476 break;
479 #if (NDEBUG & NDEBUG_C400_PWRITE)
480 printk("53C400w: %d blocks left\n", blocks);
482 printk("53C400w: waiting for buffer, bl=%d\n", bl);
483 #endif
484 while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY)
487 #if (NDEBUG & NDEBUG_C400_PWRITE)
488 printk("53C400w: transferring 128 bytes\n");
489 #endif
490 #ifdef CONFIG_SCSI_G_NCR5380_PORT
491 for (i=0; i<128; i++)
492 NCR5380_write(C400_HOST_BUFFER, src[start+i]);
493 #else
494 /* implies CONFIG_SCSI_G_NCR5380_MEM */
495 memmove(NCR53C400_host_buffer+NCR5380_map_name,src+start,128);
496 #endif
497 start+=128;
498 blocks--;
500 if (blocks) {
501 #if (NDEBUG & NDEBUG_C400_PWRITE)
502 printk("53C400w: EXTRA waiting for buffer\n");
503 #endif
504 while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY)
507 #if (NDEBUG & NDEBUG_C400_PWRITE)
508 printk("53C400w: transferring EXTRA 128 bytes\n");
509 #endif
510 #ifdef CONFIG_SCSI_G_NCR5380_PORT
511 for (i=0; i<128; i++)
512 NCR5380_write(C400_HOST_BUFFER, src[start+i]);
513 #else
514 /* implies CONFIG_SCSI_G_NCR5380_MEM */
515 memmove(NCR53C400_host_buffer+NCR5380_map_name,src+start,128);
516 #endif
517 start+=128;
518 blocks--;
520 #if (NDEBUG & NDEBUG_C400_PWRITE)
521 else
522 printk("53C400w: No EXTRA required\n");
523 #endif
525 #if (NDEBUG & NDEBUG_C400_PWRITE)
526 printk("53C400w: Final values: blocks=%d start=%d\n", blocks, start);
527 #endif
529 #if 0
530 printk("53C400w: waiting for registers to be available\n");
531 THEY NEVER DO!
532 while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_53C80_REG)
534 printk("53C400w: Got em\n");
535 #endif
537 /* Let's wait for this instead - could be ugly */
538 /* All documentation says to check for this. Maybe my hardware is too
539 * fast. Waiting for it seems to work fine! KLL
541 while (!(i = NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ))
545 * I know. i is certainly != 0 here but the loop is new. See previous
546 * comment.
548 if (i) {
549 #if (NDEBUG & NDEBUG_C400_PWRITE)
550 printk("53C400w: got 53C80 gated irq (last block)\n");
551 #endif
552 if (!((i=NCR5380_read(BUS_AND_STATUS_REG)) & BASR_END_DMA_TRANSFER))
553 printk("53C400w: No END OF DMA bit - WHOOPS! BASR=%0x\n",i);
554 #if (NDEBUG & NDEBUG_C400_PWRITE)
555 else
556 printk("53C400w: Got END OF DMA\n");
557 #endif
559 else
560 printk("53C400w: no 53C80 gated irq after transfer (last block)\n");
562 #if 0
563 if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_END_DMA_TRANSFER)) {
564 printk("53C400w: no end dma signal\n");
566 #endif
568 #if (NDEBUG & NDEBUG_C400_PWRITE)
569 printk("53C400w: waiting for last byte...\n");
570 #endif
571 while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT))
574 #if (NDEBUG & NDEBUG_C400_PWRITE)
575 printk("53C400w: got last byte.\n");
576 printk("53C400w: pwrite exiting with status 0, whoopee!\n");
577 #endif
578 return 0;
580 #endif /* PSEUDO_DMA */
582 #include "NCR5380.c"
584 #define PRINTP(x) len += sprintf(buffer+len, x)
585 #define ANDP ,
587 static int sprint_opcode(char* buffer, int len, int opcode) {
588 int start = len;
589 PRINTP("0x%02x " ANDP opcode);
590 return len-start;
593 static int sprint_command (char* buffer, int len, unsigned char *command) {
594 int i,s,start=len;
595 len += sprint_opcode(buffer, len, command[0]);
596 for ( i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
597 PRINTP("%02x " ANDP command[i]);
598 PRINTP("\n");
599 return len-start;
602 static int sprint_Scsi_Cmnd (char* buffer, int len, Scsi_Cmnd *cmd) {
603 int start = len;
604 PRINTP("host number %d destination target %d, lun %d\n" ANDP
605 cmd->host->host_no ANDP
606 cmd->target ANDP
607 cmd->lun);
608 PRINTP(" command = ");
609 len += sprint_command (buffer, len, cmd->cmnd);
610 return len-start;
613 int generic_NCR5380_proc_info(char* buffer, char** start, off_t offset, int length, int hostno, int inout)
615 int len = 0;
616 NCR5380_local_declare();
617 unsigned char status;
618 int i;
619 struct Scsi_Host *scsi_ptr;
620 Scsi_Cmnd *ptr;
621 struct NCR5380_hostdata *hostdata;
623 cli();
625 for (scsi_ptr = first_instance; scsi_ptr; scsi_ptr=scsi_ptr->next)
626 if (scsi_ptr->host_no == hostno)
627 break;
628 NCR5380_setup(scsi_ptr);
629 hostdata = (struct NCR5380_hostdata *)scsi_ptr->hostdata;
631 PRINTP("SCSI host number %d : %s\n" ANDP scsi_ptr->host_no ANDP scsi_ptr->hostt->name);
632 PRINTP("Generic NCR5380 driver version %d\n" ANDP GENERIC_NCR5380_PUBLIC_RELEASE);
633 PRINTP("NCR5380 core version %d\n" ANDP NCR5380_PUBLIC_RELEASE);
634 #ifdef NCR53C400
635 PRINTP("NCR53C400 extension version %d\n" ANDP NCR53C400_PUBLIC_RELEASE);
636 PRINTP("NCR53C400 card%s detected\n" ANDP (((struct NCR5380_hostdata *)scsi_ptr->hostdata)->flags & FLAG_NCR53C400)?"":" not");
637 # if NCR53C400_PSEUDO_DMA
638 PRINTP("NCR53C400 pseudo DMA used\n");
639 # endif
640 #else
641 PRINTP("NO NCR53C400 driver extensions\n");
642 #endif
643 PRINTP("Using %s mapping at %s 0x%x, " ANDP STRVAL(NCR5380_map_config) ANDP STRVAL(NCR5380_map_name) ANDP scsi_ptr->NCR5380_instance_name);
644 if (scsi_ptr->irq == IRQ_NONE)
645 PRINTP("no interrupt\n");
646 else
647 PRINTP("on interrupt %d\n" ANDP scsi_ptr->irq);
649 #ifdef NCR5380_STATS
650 if (hostdata->connected || hostdata->issue_queue || hostdata->disconnected_queue)
651 PRINTP("There are commands pending, transfer rates may be crud\n");
652 if (hostdata->pendingr)
653 PRINTP(" %d pending reads" ANDP hostdata->pendingr);
654 if (hostdata->pendingw)
655 PRINTP(" %d pending writes" ANDP hostdata->pendingw);
656 if (hostdata->pendingr || hostdata->pendingw)
657 PRINTP("\n");
658 for (dev = scsi_devices; dev; dev=dev->next) {
659 if (dev->host == scsi_ptr) {
660 unsigned long br = hostdata->bytes_read[dev->id];
661 unsigned long bw = hostdata->bytes_write[dev->id];
662 long tr = hostdata->time_read[dev->id] / HZ;
663 long tw = hostdata->time_write[dev->id] / HZ;
665 PRINTP(" T:%d %s " ANDP dev->id ANDP (dev->type < MAX_SCSI_DEVICE_CODE) ? scsi_device_types[(int)dev->type] : "Unknown");
666 for (i=0; i<8; i++)
667 if (dev->vendor[i] >= 0x20)
668 *(buffer+(len++)) = dev->vendor[i];
669 *(buffer+(len++)) = ' ';
670 for (i=0; i<16; i++)
671 if (dev->model[i] >= 0x20)
672 *(buffer+(len++)) = dev->model[i];
673 *(buffer+(len++)) = ' ';
674 for (i=0; i<4; i++)
675 if (dev->rev[i] >= 0x20)
676 *(buffer+(len++)) = dev->rev[i];
677 *(buffer+(len++)) = ' ';
679 PRINTP("\n%10ld kb read in %5ld secs" ANDP br/1024 ANDP tr);
680 if (tr)
681 PRINTP(" @ %5ld bps" ANDP br / tr);
683 PRINTP("\n%10ld kb written in %5ld secs" ANDP bw/1024 ANDP tw);
684 if (tw)
685 PRINTP(" @ %5ld bps" ANDP bw / tw);
686 PRINTP("\n");
689 #endif
691 status = NCR5380_read(STATUS_REG);
692 if (!(status & SR_REQ))
693 PRINTP("REQ not asserted, phase unknown.\n");
694 else {
695 for (i = 0; (phases[i].value != PHASE_UNKNOWN) &&
696 (phases[i].value != (status & PHASE_MASK)); ++i)
698 PRINTP("Phase %s\n" ANDP phases[i].name);
701 if (!hostdata->connected) {
702 PRINTP("No currently connected command\n");
703 } else {
704 len += sprint_Scsi_Cmnd (buffer, len, (Scsi_Cmnd *) hostdata->connected);
707 PRINTP("issue_queue\n");
709 for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr;
710 ptr = (Scsi_Cmnd *) ptr->host_scribble)
711 len += sprint_Scsi_Cmnd (buffer, len, ptr);
713 PRINTP("disconnected_queue\n");
715 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr;
716 ptr = (Scsi_Cmnd *) ptr->host_scribble)
717 len += sprint_Scsi_Cmnd (buffer, len, ptr);
719 *start = buffer + offset;
720 len -= offset;
721 if (len > length)
722 len = length;
723 sti();
724 return len;
727 #undef PRINTP
728 #undef ANDP
730 #ifdef MODULE
731 /* Eventually this will go into an include file, but this will be later */
732 Scsi_Host_Template driver_template = GENERIC_NCR5380;
734 #include <linux/module.h>
735 #include "scsi_module.c"
736 #endif