home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / SYSUTL / IRQR.ZIP / IRQR.C next >
Encoding:
C/C++ Source or Header  |  1988-04-17  |  1.8 KB  |  97 lines

  1. /*
  2.    IRQR -- Report status of IRQs in the H248 computer, PC/AT or compatibles.
  3.    Copyright 1988 by Lawrence R. Steeger
  4.  
  5.    Based upon IRQS by Joseph Katz (Copyright 1988 by Joseph Katz), which
  6.    was published in Katz's "C Notes" in SEXTANT No. 34 - Late Spring 1988.
  7.  
  8.    (Microsoft C Version 5)
  9.  
  10.  */
  11.  
  12. #include "stdio.h"
  13. #include "conio.h"
  14.  
  15. #define NUMPORTS 2
  16.  
  17. typedef struct {
  18.         unsigned int number;
  19.         char* name;
  20.     } irqport;
  21.  
  22. unsigned int    status,
  23.         bit,
  24.         p8259;
  25.  
  26. static irqport  port[] = {{0x21,"0x21"},
  27.               {0xA1,"0xA1"}};
  28.  
  29. static char     free[] = ">FREE",
  30.         used[] = " used";
  31.  
  32. static char*    ibm[] = {"Timer",
  33.              "Keyboard",
  34.              "2nd 8259",
  35.              "COM2",
  36.              "COM1",
  37.              "LPT2",
  38.              "Floppy Disk",
  39.              "LPT1",
  40.              "Clock",
  41.              "Redirected IRQ2",
  42.              "(reserved)",
  43.              "(reserved)",
  44.              "(reserved)",
  45.              "Coprocessor",
  46.              "Hard Disk",
  47.              "(reserved)"};
  48.  
  49. static char*    oem[] = {"",
  50.              "",
  51.              "Autofax Imager",
  52.              "",
  53.              "",
  54.              "MS Bus Mouse",
  55.              "",
  56.              "",
  57.              "",
  58.              "",
  59.              "",
  60.              "",
  61.              "",
  62.              "",
  63.              "",
  64.              ""};
  65.  
  66. main()
  67. {
  68.     puts("IRQR --\tReport Status of 8259 Hardware Interrupt Channels");
  69.     puts("\tCopyright 1988 by Lawrence R. Steeger\n");
  70.     puts("\t8259  IRQ  Status   IBM Assignments  OEM Assignments");
  71.     puts("\t----  ---  ------   ---------------  ---------------");
  72.  
  73.     /* display status of 8259 IRQs */
  74.  
  75.     for (p8259 = 0; p8259 < NUMPORTS; p8259++) {
  76.  
  77.         /* get 8259 status port information */
  78.  
  79.         status = inp(port[p8259].number);
  80.  
  81.         for (bit = 0; bit <= 7; bit++) {
  82.             printf("\t%-4s  %3d  %6s   %-15s  %s\n",
  83.             ((bit == 0) ? port[p8259].name : ""),
  84.             (bit + (p8259 * 8)),
  85.             ((status >> bit) & 1) ? free : used,
  86.             ibm[(bit + (p8259 * 8))], oem[(bit + (p8259 * 8))]);
  87.         }
  88.  
  89.         if ((p8259 + 1) < NUMPORTS) puts("");
  90.     }
  91.  
  92.     exit(0);
  93. }
  94.  
  95. /* end of IRQR.C */
  96.  
  97.