linux-old/drivers/char/ip2/ip2stat.c
<<
>>
Prefs
   1/*******************************************************************************
   2*
   3*   (c) 1998 by Computone Corporation
   4*
   5********************************************************************************
   6*
   7*
   8*   PACKAGE:     Linux tty Device Driver for IntelliPort family of multiport
   9*                serial I/O controllers.
  10*
  11*   DESCRIPTION: Status display utility
  12*
  13*******************************************************************************/
  14
  15#include <sys/time.h>
  16#include <sys/types.h>
  17#include <unistd.h>
  18#include <stdio.h>
  19#include <signal.h>
  20#include <sys/stat.h>
  21#include <fcntl.h>
  22#include <ctype.h>
  23#include <linux/timer.h>
  24#include <linux/termios.h>
  25
  26#include "i2ellis.h"
  27#include "i2lib.h"
  28
  29i2eBordStr Board[2];
  30i2ChanStr  Port[2];
  31
  32struct driver_stats
  33{
  34        ULONG ref_count;
  35        ULONG irq_counter;
  36        ULONG bh_counter;
  37} Driver;
  38
  39char    devname[20];
  40
  41int main (int argc, char *argv[])
  42{
  43   int   fd;
  44   int   dev, i;
  45        i2eBordStrPtr pB  = Board;
  46        i2ChanStrPtr  pCh = Port;
  47
  48        if ( argc != 2 ) 
  49        {
  50                printf ( "Usage: %s <port>\n", argv[0] );
  51                exit(1);
  52        }
  53        i = sscanf ( argv[1], "/dev/ttyF%d", &dev );
  54
  55        if ( i != 1 ) exit(1);
  56
  57        //printf("%s: board %d, port %d\n", argv[1], dev / 64, dev % 64 );
  58
  59        sprintf ( devname, "/dev/ip2stat%d", dev / 64 );
  60        if( 0 > ( fd = open ( devname, O_RDONLY ) ) ) {
  61                // Conventional name failed - try devfs name
  62                sprintf ( devname, "/dev/ip2/stat%d", dev / 64 );
  63                if( 0 > ( fd = open ( devname, O_RDONLY ) ) ) {
  64                        // Where is our board???
  65                        printf( "Unable to open board %d to retrieve stats\n",
  66                                dev / 64 );
  67                        exit( 255 );
  68                }
  69        }
  70
  71        ioctl ( fd,  64, &Driver );
  72        ioctl ( fd,  65, Board );
  73        ioctl ( fd,  dev % 64, Port );
  74
  75        printf ( "Driver statistics:-\n" );
  76        printf ( " Reference Count:  %d\n", Driver.ref_count );
  77        printf ( " Interrupts to date:   %ld\n", Driver.irq_counter );
  78        printf ( " Bottom half to date:  %ld\n", Driver.bh_counter );
  79
  80        printf ( "Board statistics(%d):-\n",dev/64 );
  81        printf ( "FIFO: remains = %d%s\n", pB->i2eFifoRemains, 
  82                                pB->i2eWaitingForEmptyFifo ? ", busy" : "" );
  83        printf ( "Mail: out mail = %02x\n", pB->i2eOutMailWaiting ); 
  84        printf ( "  Input interrupts : %d\n", pB->i2eFifoInInts );
  85        printf ( "  Output interrupts: %d\n", pB->i2eFifoOutInts );
  86        printf ( "  Flow queued      : %ld\n", pB->debugFlowQueued );
  87        printf ( "  Bypass queued    : %ld\n", pB->debugBypassQueued );
  88        printf ( "  Inline queued    : %ld\n", pB->debugInlineQueued );
  89        printf ( "  Data queued      : %ld\n", pB->debugDataQueued );
  90        printf ( "  Flow packets     : %ld\n", pB->debugFlowCount );
  91        printf ( "  Bypass packets   : %ld\n", pB->debugBypassCount );
  92        printf ( "  Inline packets   : %ld\n", pB->debugInlineCount );
  93        printf ( "  Mail status      : %x\n",  pB->i2eStatus );
  94        printf ( "  Output mail      : %x\n",  pB->i2eOutMailWaiting );
  95        printf ( "  Fatal flag       : %d\n",  pB->i2eFatal );
  96
  97        printf ( "Channel statistics(%s:%d):-\n",argv[1],dev%64 );
  98        printf ( "ibuf: stuff = %d strip = %d\n", pCh->Ibuf_stuff, pCh->Ibuf_strip );
  99        printf ( "obuf: stuff = %d strip = %d\n", pCh->Obuf_stuff, pCh->Obuf_strip );
 100        printf ( "pbuf: stuff = %d\n", pCh->Pbuf_stuff );
 101        printf ( "cbuf: stuff = %d strip = %d\n", pCh->Cbuf_stuff, pCh->Cbuf_strip );
 102        printf ( "infl: count = %d room = %d\n", pCh->infl.asof, pCh->infl.room );
 103        printf ( "outfl: count = %d room = %d\n", pCh->outfl.asof, pCh->outfl.room );
 104        printf ( "throttled = %d ",pCh->throttled);
 105        printf ( "bookmarks = %d ",pCh->bookMarks);
 106        printf ( "flush_flags = %x\n",pCh->flush_flags);
 107        printf ( "needs: ");
 108        if (pCh->channelNeeds & NEED_FLOW)   printf("FLOW ");
 109        if (pCh->channelNeeds & NEED_INLINE) printf("INLINE ");
 110        if (pCh->channelNeeds & NEED_BYPASS) printf("BYPASS ");
 111        if (pCh->channelNeeds & NEED_CREDIT) printf("CREDIT ");
 112        printf ( "\n");
 113        printf ( "dss: in = %x, out = %x\n",pCh->dataSetIn,pCh->dataSetOut);
 114        
 115}
 116
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.