root/drivers/scsi/eata_pio_proc.c

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

DEFINITIONS

This source file includes following definitions.
  1. eata_pio_set_info
  2. eata_pio_proc_info

   1 
   2 #define MAX_SCSI_DEVICE_CODE 10
   3 const char *const pio_scsi_dev_types[MAX_SCSI_DEVICE_CODE] =
   4 {
   5     "Direct-Access    ",
   6     "Sequential-Access",
   7     "Printer          ",
   8     "Processor        ",
   9     "WORM             ",
  10     "CD-ROM           ",
  11     "Scanner          ",
  12     "Optical Device   ",
  13     "Medium Changer   ",
  14     "Communications   "
  15 };
  16 
  17 /*
  18  * eata_set_info
  19  * buffer : pointer to the data that has been written to the hostfile
  20  * length : number of bytes written to the hostfile
  21  * HBA_ptr: pointer to the Scsi_Host struct
  22  */
  23 int eata_pio_set_info(char *buffer, int length, struct Scsi_Host *HBA_ptr)
     /* [previous][next][first][last][top][bottom][index][help] */
  24 {
  25     DBG(DBG_PROC_WRITE, printk("%s\n", buffer));
  26     return(-ENOSYS);  /* Currently this is a no-op */
  27 }
  28 
  29 /*
  30  * eata_proc_info
  31  * inout : decides on the direction of the dataflow and the meaning of the variables
  32  * buffer: If inout==FALSE data is beeing written to it else read from it
  33  * *start: If inout==FALSE start of the valid data in the buffer
  34  * offset: If inout==FALSE offset from the beginning of the imaginary file from which we start writing into the buffer
  35  * length: If inout==FALSE max number of bytes to be written into the buffer else number of bytes in the buffer
  36  */
  37 int eata_pio_proc_info(char *buffer, char **start, off_t offset, int length, int hostno, int inout)
     /* [previous][next][first][last][top][bottom][index][help] */
  38 {
  39 
  40     Scsi_Device *scd;
  41     struct Scsi_Host *HBA_ptr;
  42     static u8 buff[512];
  43     int i, x; 
  44     int   size, len = 0;
  45     off_t begin = 0;
  46     off_t pos = 0;
  47 
  48     HBA_ptr = first_HBA;
  49     for (i = 1; i <= registered_HBAs; i++) {
  50         if (HBA_ptr->host_no == hostno)
  51             break;
  52         HBA_ptr = SD(HBA_ptr)->next;
  53     }        
  54 
  55     if(inout == TRUE) /* Has data been writen to the file ? */ 
  56         return(eata_pio_set_info(buffer, length, HBA_ptr));
  57 
  58     if (offset == 0)
  59         memset(buff, 0, sizeof(buff));
  60 
  61     size = sprintf(buffer+len, "EATA (Extended Attachment) PIO driver version: "
  62                    "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB);
  63     len += size; pos = begin + len;
  64     size = sprintf(buffer + len, "queued commands:     %10ld\n"
  65                    "processed interrupts:%10ld\n", queue_counter, int_counter);
  66     len += size; pos = begin + len;
  67     
  68     size = sprintf(buffer + len, "\nscsi%-2d: HBA %.10s\n",
  69                    HBA_ptr->host_no, SD(HBA_ptr)->name);
  70     len += size; 
  71     pos = begin + len;
  72     size = sprintf(buffer + len, "Firmware revision: v%s\n", 
  73                    SD(HBA_ptr)->revision);
  74     len += size;
  75     pos = begin + len;
  76     size = sprintf(buffer + len, "IO: PIO\n");
  77     len += size; 
  78     pos = begin + len;
  79     size = sprintf(buffer + len, "Base IO : %#.4x\n", (u32) HBA_ptr->base);
  80     len += size; 
  81     pos = begin + len;
  82     size = sprintf(buffer + len, "Host Bus: %s\n", 
  83                    (SD(HBA_ptr)->bustype == 'P')?"PCI ":
  84                    (SD(HBA_ptr)->bustype == 'E')?"EISA":"ISA ");
  85     
  86     len += size; 
  87     pos = begin + len;
  88     
  89     if (pos < offset) {
  90         len = 0;
  91         begin = pos;
  92     }
  93     if (pos > offset + length)
  94         goto stop_output;
  95     
  96     scd = scsi_devices;
  97     
  98     size = sprintf(buffer+len,"Attached devices: %s\n", (scd)?"":"none");
  99     len += size; 
 100     pos = begin + len;
 101     
 102     while (scd) {
 103         if (scd->host == HBA_ptr) {
 104             
 105             size = sprintf(buffer + len, "Channel: %02d Id: %02d Lun: %02d\n  Vendor: ",
 106                            scd->channel, scd->id, scd->lun);
 107             for (x = 0; x < 8; x++) {
 108                 if (scd->vendor[x] >= 0x20)
 109                     size += sprintf(buffer + len + size, "%c", scd->vendor[x]);
 110                 else
 111                     size += sprintf(buffer + len + size," ");
 112             }
 113             size += sprintf(buffer + len + size, " Model: ");
 114             for (x = 0; x < 16; x++) {
 115                 if (scd->model[x] >= 0x20)
 116                     size +=  sprintf(buffer + len + size, "%c", scd->model[x]);
 117                 else
 118                     size += sprintf(buffer + len + size, " ");
 119             }
 120             size += sprintf(buffer + len + size, " Rev: ");
 121             for (x = 0; x < 4; x++) {
 122                 if (scd->rev[x] >= 0x20)
 123                     size += sprintf(buffer + len + size, "%c", scd->rev[x]);
 124                 else
 125                     size += sprintf(buffer + len + size, " ");
 126             }
 127             size += sprintf(buffer + len + size, "\n");
 128             
 129             size += sprintf(buffer + len + size, "  Type:   %s ",
 130                             scd->type < MAX_SCSI_DEVICE_CODE ? 
 131                             pio_scsi_dev_types[(int)scd->type] : "Unknown          " );
 132             size += sprintf(buffer + len + size, "               ANSI"
 133                             " SCSI revision: %02x", (scd->scsi_level < 3)?1:2);
 134             if (scd->scsi_level == 2)
 135                 size += sprintf(buffer + len + size, " CCS\n");
 136             else
 137                 size += sprintf(buffer + len + size, "\n");
 138             len += size; 
 139             pos = begin + len;
 140             
 141             if (pos < offset) {
 142                 len = 0;
 143                 begin = pos;
 144             }
 145             if (pos > offset + length)
 146                 goto stop_output;
 147         }
 148         scd = scd->next;
 149     }
 150     
 151  stop_output:
 152     DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len));
 153     *start=buffer+(offset-begin);   /* Start of wanted data */
 154     len-=(offset-begin);            /* Start slop */
 155     if(len>length)
 156         len = length;               /* Ending slop */
 157     DBG(DBG_PROC, printk("3pos: %ld offset: %ld len: %d\n", pos, offset, len));
 158     
 159     return (len);     
 160 }
 161 
 162 /*
 163  * Overrides for Emacs so that we follow Linus's tabbing style.
 164  * Emacs will notice this stuff at the end of the file and automatically
 165  * adjust the settings for this buffer only.  This must remain at the end
 166  * of the file.
 167  * ---------------------------------------------------------------------------
 168  * Local variables:
 169  * c-indent-level: 4
 170  * c-brace-imaginary-offset: 0
 171  * c-brace-offset: -4
 172  * c-argdecl-indent: 4
 173  * c-label-offset: -4
 174  * c-continued-statement-offset: 4
 175  * c-continued-brace-offset: 0
 176  * indent-tabs-mode: nil
 177  * tab-width: 8
 178  * End:
 179  */

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