home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / DASD / IBM / IBM2SCSI / IBM2SCPR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-14  |  10.9 KB  |  249 lines

  1. /*DDK*************************************************************************/
  2. /*                                                                           */
  3. /* COPYRIGHT (C) Microsoft Corporation, 1989                                 */
  4. /* COPYRIGHT    Copyright (C) 1995 IBM Corporation                           */
  5. /*                                                                           */
  6. /*    The following IBM OS/2 WARP source code is provided to you solely for  */
  7. /*    the purpose of assisting you in your development of OS/2 WARP device   */
  8. /*    drivers. You may use this code in accordance with the IBM License      */
  9. /*    Agreement provided in the IBM Device Driver Source Kit for OS/2. This  */
  10. /*    Copyright statement may not be removed.                                */
  11. /*                                                                           */
  12. /*****************************************************************************/
  13. /*static char *SCCSID = "src/dev/dasd/ibm/ibm2scsi/ibm2scpr.c, scsi, r206, 6.506 93/03/20";*/
  14. /**************************************************************************
  15.  *
  16.  * SOURCE FILE NAME = IBM2SCPR.C
  17.  *
  18.  * DESCRIPTIVE NAME = IBM2SCSI.ADD - Adapter Driver for ABIOS SCB Devices
  19.  *
  20.  *
  21.  *
  22.  * VERSION = V2.0
  23.  *
  24.  * DATE
  25.  *
  26.  * DESCRIPTION : Calling sequences for TESTCFG Device Driver
  27.  *
  28.  *
  29. */
  30. #define INCL_DOSDEVICES
  31. #include <os2def16.h>
  32. #include <bsedos16.h>
  33.  
  34.  
  35. #define TSTCFG_CAT              0x80
  36. #define TSTCFG_FCN_READBIOS     0x40
  37. #define TSTCFG_FCN_INPUT        0x41
  38. #define TSTCFG_FCN_OUTPUT       0x42
  39. #define TSTCFG_FCN_BUSTYPE      0x60
  40. #define TSTCFG_FCN_RETURNPOSIDS 0x61
  41.  
  42. #define OEMHLP_CAT              0x80                                 /*@V96790*/
  43. #define OEMHLP_FCN_QUERYROMBIOS 0x05                                 /*@V96790*/
  44.  
  45. #define MODEL_PS2               0xF8                                 /*@V96790*/
  46. #define SUBMODEL_8556           0x25   /* SCSI I */                  /*@V96790*/
  47. #define SUBMODEL_8556_8557      0x26   /* SCSI I */                  /*@V96790*/
  48. #define SUBMODEL_BAHAMA         0x27   /* SCSI I */                  /*@V96790*/
  49. #define SUBMODEL_MIDWAY_CAT_CAY 0x35   /* SCSI I */                  /*@V96790*/
  50. #define SUBMODEL_CANERY         0x38   /* SCSI I */                  /*@V96790*/
  51. #define SUBMODEL_9576_9577      0x41   /* SCSI I */                  /*@V96790*/
  52. #define SUBMODEL_8585           0x48   /* SCSI I */                  /*@V96790*/
  53. #define SUBMODEL_SERVER85       0xB4   /* Corvette SCSI II */        /*@V96790*/
  54.  
  55. #define MAX_POS_IDS             16
  56.  
  57. #define BUSTYPE_MCA              1
  58.  
  59. #define PRESENT                  0
  60. #define NOT_PRESENT             -1
  61.  
  62.  
  63. USHORT  AdapterIds[] =
  64. {
  65.   0x8EFC,               /* IBM PS/2 SCSI-2 Adapter              */
  66.   0x8EFE,               /* IBM PS/2 SCSI-1 Adapter (w/o  cache) */
  67.   0x8EFF                /* IBM PS/2 SCSI-1 Adapter (w/   cache) */
  68. };
  69.  
  70. #define MAX_ADAPTER_IDS  (sizeof(AdapterIds)/sizeof(AdapterIds[0]))
  71.  
  72. typedef struct _OEMHLP_QueryRomBIOS {                               /*@V96790*/
  73.    USHORT     Model;                                                /*@V96790*/
  74.    USHORT     SubModel;                                             /*@V96790*/
  75.    USHORT     BIOSRevLevel;                                         /*@V96790*/
  76.    USHORT     flags;                                                /*@V96790*/
  77. } OEMHLP_QueryRomBIOS_t;                                            /*@V96790*/
  78.  
  79. OEMHLP_QueryRomBIOS_t OEMHLP_DataPacket  = { 0 };                   /*@V96790*/
  80.  
  81. /*----------------------------------------*/
  82. /*                                        */
  83. /* Presence Check for IBM SCSI Adapters   */
  84. /*                                        */
  85. /*----------------------------------------*/
  86.  
  87. main()
  88. {
  89.   HFILE         hTESTCFG;
  90.   HFILE         hIBMSCSI;
  91.   HFILE         hOEMHLP;                                           /*@V96790*/
  92.   USHORT        rc;
  93.   USHORT        action;
  94.  
  95.   USHORT        i;
  96.   USHORT        j;
  97.  
  98.   USHORT        pos_ids[MAX_POS_IDS];
  99.   USHORT        pos_id_count;
  100.   USHORT        pos;
  101.  
  102.   USHORT        Present = NOT_PRESENT;
  103.  
  104.   ULONG         Command = 0;
  105.   ULONG         BusType;
  106.  
  107.   OEMHLP_QueryRomBIOS_t OEMHLP_DataPacket;                          /*@V96790*/
  108.   USHORT                Model;                                      /*@V96790*/
  109.   USHORT                SubModel;                                   /*@V96790*/
  110.  
  111.   /*-----------------------------------------------*/               /*@V98451*/
  112.   /* If IBM2SCSI.ADD driver is loaded, then IBM    */               /*@V98451*/
  113.   /* SCSI adapters(s) are present.                 */               /*@V98451*/
  114.   /*                                               */               /*@V98451*/
  115.   /*-----------------------------------------------*/               /*@V98451*/
  116.  
  117.   if (!(rc=                                                         /*@V98451*/
  118.          DosOpen("IBMSCSI$",&hIBMSCSI,&action,0L,0,1,0x40,0L)))     /*@V98451*/
  119.   {                                                                 /*@V98451*/
  120.      DosClose( hIBMSCSI );                                          /*@V98451*/
  121.      return( 0 );                                                   /*@V98451*/
  122.   }                                                                 /*@V98451*/
  123.  
  124.   /*------------------------*/
  125.   /* Open TESTCFG Driver    */
  126.   /*------------------------*/
  127.  
  128.   if ( rc=DosOpen( "TESTCFG$",
  129.                    &hTESTCFG,
  130.                    &action,
  131.                    0L,
  132.                    0,
  133.                    1,
  134.                    0x40,
  135.                    0L          ) )
  136.  
  137.   {
  138.     goto ExitPresenceCheck;
  139.   }
  140.  
  141.   /*----------------------------*/
  142.   /* Determine Machine Bus Type */
  143.   /*----------------------------*/
  144.  
  145.   rc = DosDevIOCtl( (PVOID) &BusType,
  146.                     (PVOID) &Command,
  147.                     (USHORT) TSTCFG_FCN_BUSTYPE,
  148.                     (USHORT) TSTCFG_CAT,
  149.                     (HFILE)  hTESTCFG           );
  150.  
  151.   if ( rc || BusType != BUSTYPE_MCA )
  152.   {
  153.     DosClose(hTESTCFG);                                             /*@V96790*/
  154.     goto ExitPresenceCheck;
  155.   }
  156.  
  157.   /*----------------------------*/
  158.   /* Scan POS IDs               */
  159.   /*----------------------------*/
  160.  
  161.   for (i=0; i < MAX_POS_IDS; i++ )
  162.   {
  163.     pos_ids[i] = 0;
  164.   }
  165.  
  166.   rc = DosDevIOCtl( (PVOID)  pos_ids,
  167.                     (PVOID)  &Command,
  168.                     (USHORT) TSTCFG_FCN_RETURNPOSIDS,
  169.                     (USHORT) TSTCFG_CAT,
  170.                     (HFILE)  hTESTCFG                 );
  171.  
  172.   if ( !rc )
  173.   {
  174.     for ( i=1; i < MAX_POS_IDS && (Present == NOT_PRESENT); i++ )
  175.     {
  176.       pos = pos_ids[i];
  177.  
  178.       if ( pos && (pos != 0xffff) )
  179.       {
  180.         for (j = 0; j < MAX_ADAPTER_IDS; j++ )
  181.         {
  182.           if ( AdapterIds[j] == pos )
  183.           {
  184.             Present = PRESENT;
  185.             break;
  186.           }
  187.         }
  188.       }
  189.     }
  190.   }
  191.  
  192.   DosClose(hTESTCFG);
  193.  
  194.   /***************************************************/             /*@V96790*/
  195.   /*  Scan the Model/submodel bits for on Board SCSI */             /*@V96790*/
  196.   /***************************************************/             /*@V96790*/
  197.  
  198.   if (!rc)                                                          /*@V96790*/
  199.   {                                                                 /*@V96790*/
  200.      /*------------------------*/                                   /*@V96790*/
  201.      /* Open OEMHLP Driver     */                                   /*@V96790*/
  202.      /*------------------------*/                                   /*@V96790*/
  203.                                                                     /*@V96790*/
  204.      if ( rc=DosOpen( "OEMHLP$",                                    /*@V96790*/
  205.                       &hOEMHLP,                                     /*@V96790*/
  206.                       &action,                                      /*@V96790*/
  207.                       0L,                                           /*@V96790*/
  208.                       0,                                            /*@V96790*/
  209.                       1,                                            /*@V96790*/
  210.                       0x40,                                         /*@V96790*/
  211.                       0L          ) )                               /*@V96790*/
  212.                                                                     /*@V96790*/
  213.      {                                                              /*@V96790*/
  214.        goto ExitPresenceCheck;                                      /*@V96790*/
  215.      }                                                              /*@V96790*/
  216.                                                                     /*@V96790*/
  217.      if ( !(rc=DosDevIOCtl( &OEMHLP_DataPacket,                     /*@V96790*/
  218.                             &Command,                               /*@V96790*/
  219.                             OEMHLP_FCN_QUERYROMBIOS,                /*@V96790*/
  220.                             OEMHLP_CAT,                             /*@V96790*/
  221.                             hOEMHLP )))                             /*@V96790*/
  222.      {                                                              /*@V96790*/
  223.         Model = OEMHLP_DataPacket.Model;                            /*@V96790*/
  224.         SubModel = OEMHLP_DataPacket.SubModel;                      /*@V96790*/
  225.                                                                     /*@V96790*/
  226.         /* PS/2 Machines with onboard SCSI chips */                 /*@V96790*/
  227.                                                                     /*@V96790*/
  228.         if ( ( Model==MODEL_PS2 ) &&                                /*@V96790*/
  229.              ( ( SubModel==SUBMODEL_8556          ) ||              /*@V96790*/
  230.                ( SubModel==SUBMODEL_8556_8557     ) ||              /*@V96790*/
  231.                ( SubModel==SUBMODEL_BAHAMA        ) ||              /*@V96790*/
  232.                ( SubModel==SUBMODEL_MIDWAY_CAT_CAY) ||              /*@V96790*/
  233.                ( SubModel==SUBMODEL_CANERY        ) ||              /*@V96790*/
  234.                ( SubModel==SUBMODEL_9576_9577     ) ||              /*@V96790*/
  235.                ( SubModel==SUBMODEL_8585          ) ||              /*@V96790*/
  236.                ( SubModel==SUBMODEL_SERVER85      )   ) )           /*@V96790*/
  237.         {                                                           /*@V96790*/
  238.            Present = PRESENT;                                       /*@V96790*/
  239.         }                                                           /*@V96790*/
  240.      }                                                              /*@V96790*/
  241.   }                                                                 /*@V96790*/
  242.                                                                     /*@V96790*/
  243.   DosClose(hOEMHLP);                                                /*@V96790*/
  244.  
  245. ExitPresenceCheck:
  246.  
  247.   return( Present );
  248. }
  249.