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

  1. /*DDK*************************************************************************/
  2. /*                                                                           */
  3. /* COPYRIGHT    Copyright (C) 1995 IBM Corporation                           */
  4. /*                                                                           */
  5. /*    The following IBM OS/2 WARP source code is provided to you solely for  */
  6. /*    the purpose of assisting you in your development of OS/2 WARP device   */
  7. /*    drivers. You may use this code in accordance with the IBM License      */
  8. /*    Agreement provided in the IBM Device Driver Source Kit for OS/2. This  */
  9. /*    Copyright statement may not be removed.                                */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12. /*static char *SCCSID = "src/dev/dasd/os2aspi/aspidata.c, aspi, r206 93/03/20";*/
  13. /**************************************************************************
  14.  *
  15.  * SOURCE FILE NAME = ASPIDATA.C
  16.  *
  17.  * DESCRIPTIVE NAME = OS2ASPI.DMD - OS/2 ASPI Device Manager
  18.  *
  19.  *
  20.  *
  21.  * VERSION = V2.0
  22.  *
  23.  * DATE
  24.  *
  25.  * DESCRIPTION : ASPI Device Manager - Static/Initialization Data
  26.  *
  27.  *
  28.  *
  29. *///#define PDDENTRY PASCAL FAR32 // to declare PDD and VDD entry points
  30. //#define VDDENTRY _pascal _far _loadds
  31. //typedef unsigned short (VDDENTRY *FPFNVDD)(unsigned long, unsigned long, unsigned long);   /* fpfnvdd */
  32.  
  33. #define INCL_NOBASEAPI
  34. #define INCL_NOPMAPI
  35. #include <os2.h>
  36.  
  37. #include <devcmd.h>
  38. #include <devclass.h>
  39. #include <dskinit.h>
  40.  
  41. #define INCL_INITRP_ONLY
  42. #include <reqpkt.h>
  43.  
  44. #include <iorb.h>
  45. #include <addcalls.h>
  46. #include <scsi.h>
  47. #include <dhcalls.h>
  48.  
  49. #include <aspi.h>
  50. #include <aspicons.h>
  51. #include <aspitype.h>
  52. #include <aspipro.h>
  53. #include <cmdparse.h>
  54. #include <cmdpdefs.h>
  55.  
  56. /*--------------*/
  57. /* Static Data  */
  58. /*--------------*/
  59.  
  60. PFN                  Device_Help = 0;
  61.  
  62. PVOID                pDataSeg = 0L;           /* virt ptr of our data segment   */
  63. ULONG                ppDataSeg = 0L;          /* phys addr of our data segment  */
  64. UCHAR                numberOfASPIAdapters = 0;
  65.  
  66. USHORT               InitComplete = 0;
  67.  
  68. UCHAR                OS2ASPI_Text[17] = { "OS2ASPI Dev Mgr " };
  69. UCHAR                ASPI_PDDName[8] = "ASPI";
  70. NPACB                npACBAnchor = 0;
  71. USHORT               IORBWaitSem = 0;
  72. USHORT               virtSRBWaitSem = 0;
  73. USHORT               allocationOverride = FALSE;
  74. USHORT               shareTargets = FALSE;
  75. USHORT               VDDProc[3] =  {0};   /* addr of VDD entry point */
  76.  
  77. /* Assign a value to the first element to insure that the array is NOT */
  78. /* allocated at the end of the data segment.                           */
  79. SRB_WAIT_Q           SRBWaitQueue[25] = {0};                         /*@V61092*/
  80.  
  81. ULONG                maxPageCount = 0;
  82.  
  83. /*--------------------*/
  84. /* Configuration Data */
  85. /*--------------------*/
  86. NPSRB_LINK           npSRBLinkFreeList = 0;
  87. USHORT               freeSRBSpace = 0;
  88.  
  89. /**
  90.  ** Use GENDTBL.CMD to build these tables.
  91.  **
  92.  ** It will calculate the table contents and detect conflicts
  93.  ** between CDB direction settings.....
  94.  **/
  95.  
  96. UCHAR DirTableDASD[] =
  97. {
  98.   0x09, 0x20, 0x06, 0x84, 0x00, 0x22, 0xE0, 0xF5,
  99.   0xC0, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
  100.   0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0xE0, 0x00,
  101.   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  102. };
  103.  
  104. UCHAR DirTableTAPE[] =
  105. {
  106.   0x00, 0x20, 0x14, 0x84, 0x00, 0x00, 0x00, 0x70,
  107.   0x80, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
  108.   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  109.   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  110. };
  111.  
  112. UCHAR DirTablePROCESSOR[]=
  113. {
  114.   0x00, 0x20, 0x00, 0x84, 0x00, 0x00, 0x00, 0x70,
  115.   0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  116.   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  117.   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  118. };
  119.  
  120. UCHAR DirTablePRINTER[] =
  121. {
  122.   0x08, 0x30, 0x04, 0x84, 0x00, 0x00, 0x00, 0x70,
  123.   0x80, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
  124.   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  125.   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  126. };
  127.  
  128. UCHAR DirTableSCANNER[] =
  129. {
  130.   0x00, 0x00, 0x04, 0x84, 0x08, 0x20, 0x00, 0x70,
  131.   0x80, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
  132.   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  133.   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  134. };
  135.  
  136. UCHAR DirTableCHANGER[] =
  137. {
  138.   0x00, 0x00, 0x06, 0x04, 0x00, 0x00, 0x00, 0x10,
  139.   0x80, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
  140.   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
  141.   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  142. };
  143.  
  144. UCHAR DirTableCOMM[] =
  145. {
  146.   0x00, 0x20, 0x04, 0x04, 0x00, 0x20, 0x00, 0x10,
  147.   0x80, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
  148.   0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
  149.   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  150. };
  151.  
  152. /**
  153.  ** Direction exception list.
  154.  **
  155.  ** If a Vendor/Device is detected that matches one in this list,
  156.  ** then the exception list is scanned for an OpCode match before
  157.  ** using the default direction table.
  158.  **/
  159. UCHAR ExVendId01[] = "HP";
  160. UCHAR ExProdId01[] = "C17";
  161. UCHAR ExList01[]   = { 3, 0x0A, 1, 0x08, 0, 0x12, 0 };
  162.  
  163. UCHAR ExVendId02[] = "HP";
  164. UCHAR ExProdId02[] = "C25";
  165. UCHAR ExList02[]   = { 3, 0x0A, 1, 0x08, 0, 0x12, 0 };
  166.  
  167. DIREXCEPT DirTableExceptions[] =
  168. {
  169.    {ExVendId01, ExProdId01, ExList01},
  170.    {ExVendId02, ExProdId02, ExList02},
  171. };
  172.  
  173. USHORT MaxDirExceptions = (sizeof(DirTableExceptions) / sizeof(DIREXCEPT));
  174.  
  175. /* Assign a value to the first element to insure that the array is NOT */
  176. /* allocated at the end of the data segment.                           */
  177. BYTE                 ConfigPool[MAX_CONFIG_DATA]  = {0};
  178.  
  179. /*---------------------*/
  180. /* Initialization Data */
  181. /*---------------------*/
  182.  
  183. BYTE                 InitDataStart = 0;
  184. UCHAR                deviceTableBuffer[MAX_DT_SIZE]={0};
  185. DEVICETABLE          *pDeviceTable = (DEVICETABLE *) deviceTableBuffer;
  186. USHORT               ConfigPoolAvail = MAX_CONFIG_DATA;
  187. USHORT               numberOfSRBs;
  188. NPBYTE               npConfigPool = ConfigPool;
  189. USHORT               NumADDS = 0;
  190. UCHAR                numberOfASPITargets = 0;
  191. NPACB                npLastACB = 0;                                  /*@V55762*/
  192. NPATE                npFirstATE = 0;                                 /*@V55762*/
  193. NPATE                npLastATE = 0;                                  /*@V55762*/
  194. IORBH                InitIORB = {0};
  195. UCHAR                InitIORBPad[MAX_IORB_SIZE-sizeof(IORBH)] = {0};
  196. UCHAR                *invalidParameters = "Invalid parameters for OS2ASPI.DMD";
  197.  
  198. #define MSG_REPLACEMENT_STRING  1178
  199.  
  200. MSGTABLE  InitMsg = { MSG_REPLACEMENT_STRING,
  201.                       1,
  202.                       0,
  203.                           };
  204.  
  205. /* Unit control IORB for initialization */                           /*@V64399*/
  206. UCHAR UnitControlIORB[sizeof(IORB_UNIT_CONTROL)] ={0};               /*@V64399*/
  207. NPIORB_UNIT_CONTROL  npIORBUnitControl = (NPIORB_UNIT_CONTROL) &UnitControlIORB; /*@V64399*/
  208.  
  209. UCHAR InqIORB[sizeof(IORB_ADAPTER_PASSTHRU)+sizeof(SCSI_INQDATA)] = {0};
  210. NPIORB_ADAPTER_PASSTHRU npIORBInq = (NPIORB_ADAPTER_PASSTHRU) &InqIORB;
  211.  
  212.  
  213. /*-------------------------------------------------------------------*/
  214. /*                                                                   */
  215. /*      Command Line Parser Data                                     */
  216. /*                                                                   */
  217. /*                                                                   */
  218. /*-------------------------------------------------------------------*/
  219.  
  220. #define TOKVBUF_LEN 255
  221.  
  222. PSZ        pcmdline1              = 0;
  223. PSZ        pcmdline_slash         = 0;
  224. PSZ        pcmdline_start         = 0;
  225. INT        tokv_index             = 0;
  226. INT        state_index            = 0;
  227. INT        length                 = 0;
  228. CHARBYTE   tokvbuf[TOKVBUF_LEN]   = { 0 };
  229. POPT       pend_option            = 0;
  230. POPT       ptable_option          = 0;
  231. BYTE       *poutbuf1              = 0;
  232. BYTE       *poutbuf_end           = 0;
  233. CC         cc                     = { 0, 0 };
  234.  
  235. #define OUTBUF_LEN       255
  236.  
  237. BYTE     outbuf[OUTBUF_LEN] = {0};
  238. USHORT   outbuf_len         = OUTBUF_LEN + 1;
  239. PBYTE    poutbuf            = outbuf;
  240.  
  241. #define ENTRY_STATE        0
  242. #define MAX_STATES         2
  243.  
  244. //                                       opt.state[] initialization definitions
  245. //
  246. //                                              ____ entry state
  247. //                                              |                   previous
  248. //                                              v                     opt |
  249. //  ----Command Line Option --------           ----- STATE TABLE -----    |
  250. //  token id          string   type             0   1   2   3             |
  251. //                                                                        |
  252. //                                              *  /A:  /I  /U: <-----------
  253. //                                                          /GEO:
  254. //                                                          /T:
  255.  
  256. OPT OPT_ALL =
  257.     {TOK_ID_ALL,     "/ALL",    TYPE_0,        {0,  E,  E}};
  258.  
  259. OPT OPT_SHARE =
  260.     {TOK_ID_SHARE,   "/SHARE",  TYPE_0,        {0,  E,  E}};
  261.  
  262. OPT OPT_END =
  263.     {TOK_ID_END,     "\0",      TYPE_0,        {O,  O,  O}};
  264.  
  265. OPTIONTABLE  opttable =
  266.  
  267. {   ENTRY_STATE, MAX_STATES,
  268.     { (POPT) &OPT_ALL,
  269.       (POPT) &OPT_SHARE,
  270.       (POPT) &OPT_END
  271.     }
  272. };
  273.