home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / drivers / scsi / futrdomn / samples / oemprint.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-20  |  3.5 KB  |  121 lines

  1. /*********************** OEMPRINT.C **********************/
  2.  
  3.   #include <string.h>
  4.   #include <dos.h>
  5.   #include <stdio.h>
  6.   #include <stdlib.h>
  7.   #include <fcntl.h>
  8.   #include <io.h>
  9.  
  10.  
  11.   struct oemtable
  12.     {
  13.     unsigned char (far *cmdblock)[];
  14.     unsigned char (far *datablock)[];
  15.     long expectlen;
  16.     long actuallen;
  17.     int timeout;
  18.     int blkfactora;
  19.     int blkfactorb;
  20.     unsigned char scsistatus;
  21.     unsigned char scsimsg;
  22.     unsigned char scsibits;
  23.     unsigned char scsiaddress;
  24.     unsigned char scsiparity;
  25.     int adaptererr;
  26.     } ;
  27.  
  28. oemprint(oemtbl)
  29.   struct oemtable *oemtbl ;
  30.   {
  31.   int i,ierr;
  32.   int j,k;
  33.   long sect,x;
  34.   int unit;
  35.   unsigned char cc,ic;
  36.   struct SREGS segregs ;
  37.   union
  38.     {
  39.     unsigned char (far *point)[];
  40.     long longval;
  41.     int intval[2];
  42.     unsigned char ch [4];
  43.     } cnvtr ;
  44.   segread(&segregs) ;
  45.   for(i=0;i<25;i++)printf("\n");  /* clear screen */
  46.   printf("\nCurrent segments  CS=%04X  DS=%04X  ES=%04X  SS=%04X\n",
  47.     segregs.cs,segregs.ds,segregs.es,segregs.ss);
  48.   cnvtr.point=oemtbl->cmdblock;
  49.   printf("Command Buffer @  %04X:%04X  ",cnvtr.intval[1],cnvtr.intval[0]);
  50.   for(i=0;i<10;i++)printf(" %02X",(*cnvtr.point)[i]&255);
  51.   printf("\n");
  52.   cnvtr.point=oemtbl->datablock;
  53.   printf("Data Buffer @  %04X:%04X\n",cnvtr.intval[1],cnvtr.intval[0]);
  54.   printf("Expected length = %lu\n",oemtbl->expectlen);
  55.   printf("Actual length = %lu\n",oemtbl->actuallen);
  56.   printf("Timeout factor is %u seconds.\n",oemtbl->timeout);
  57.   printf("Blocking factors A and B are %u  &  %u\n",oemtbl->blkfactora,
  58.     oemtbl->blkfactorb);
  59.   printf("SCSI Status byte is %02X\n",oemtbl->scsistatus&255);
  60.   printf("SCSI Message byte is %02X\n",oemtbl->scsimsg&255);
  61.   ic=oemtbl->scsibits;
  62.   printf("Adapter status byte is %02X\n",ic&255);
  63.   if(ic!=0)
  64.     {
  65.     if((ic&0x1)!=0)
  66.       printf("  SCSI Busy status asserted\n");
  67.     if((ic&0x2)!=0)
  68.       printf("  SCSI Message status asserted\n");
  69.     if((ic&0x4)!=0)
  70.       printf("  SCSI I/O status asserted\n");
  71.     if((ic&0x8)!=0)
  72.       printf("  SCSI C/D status asserted\n");
  73.     if((ic&0x10)!=0)
  74.       printf("  SCSI Request status asserted\n");
  75.     if((ic&0x20)!=0)
  76.       printf("  SCSI Select status asserted\n");
  77.     if((ic&0x40)!=0)
  78.       printf("  Adapter Parity Error status asserted\n");
  79.     }
  80.   printf("SCSI Address is %u\n",oemtbl->scsiaddress&255);
  81.   if(oemtbl->scsiparity==0)printf("Adapter parity checking disabled.\n");
  82.   else printf("Adapter parity checking enabled.\n");
  83.   i=oemtbl->adaptererr;
  84.   printf("Request error status is %d\n",i);
  85.   switch (i)
  86.     {
  87.     case -1:
  88.       printf("  Timeout waiting for bus free state.\n");
  89.       break;
  90.     case -2:
  91.       printf("  Timeout during selection phase.\n");
  92.       break;
  93.     case -3:
  94.       printf("  Timeout during command phase.\n");
  95.       break;
  96.     case -4:
  97.       printf("  Timeout during data phase.\n");
  98.       break;
  99.     case -5:
  100.       printf("  Timeout during status phase.\n");
  101.       break;
  102.     case -6:
  103.       printf("  Timeout during message phase.\n");
  104.       break;
  105.     case -7:
  106.       printf("  Parity error detected by adapter.\n");
  107.       break;
  108.     case -16:
  109.       printf("  Unable to locate the adapter in the system.\n");
  110.       break;
  111.     case 2:
  112.       printf("  Buffer underflow.  Data phase shorter than expected length.\n");
  113.       break;
  114.     case 1:
  115.       printf("  Buffer overflow.  Data phase longer than expected length.\n");
  116.       break;
  117.     }
  118.   printf("\n");
  119.   return(0);
  120.   }
  121.