Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

317 lines
9.1 KiB

  1. /*-----------------------------------------------------------------------
  2. opstr.c - Option Strings. These are strings which define the options
  3. associated with the driver at the three levels: driver, device, port.
  4. This code is special, in that the source may be used for both driver
  5. and setup program, so consists only of the strings which can be shared
  6. in source code.
  7. This has expanded to other code which should be shared by
  8. both setup program and driver.
  9. Copyright 1998 Comtrol(TM) Corporation.
  10. |-----------------------------------------------------------------------*/
  11. #include "precomp.h"
  12. // driver options
  13. const char szVerboseLog[] = {"VerboseLog"};
  14. const char szNumDevices[] = {"NumDevices"};
  15. const char szNoPnpPorts[] = {"NoPnpPorts"};
  16. const char szScanRate[] = {"ScanRate"};
  17. const char szModemCountry[] = {"ModemCountry"};
  18. const char szGlobalRS485[] = {"GlobalRS485Options"};
  19. // device options
  20. //const char szStartComIndex[] = {"StartComIndex"};
  21. const char szNumPorts[] = {"NumPorts"};
  22. const char szMacAddr[] = {"MacAddr"};
  23. const char szBackupServer[] = {"BackupServer"};
  24. const char szBackupTimer[] = {"BackupTimer"};
  25. const char szName[] = {"Name"};
  26. const char szModelName[] = {"ModelName"};
  27. const char szIoAddress[] = {"IoAddress"};
  28. const char szModemDevice[] = {"ModemDevice"};
  29. const char szHubDevice[] = {"HubDevice"};
  30. const char szClkRate[] = {"ClkRate"};
  31. const char szClkPrescaler[] = {"ClkPrescaler"};
  32. // port options
  33. const char szWaitOnTx[] = {"WaitOnTx"};
  34. const char szRS485Override[] = {"RS485Override"};
  35. const char szRS485Low[] = {"RS485Low"};
  36. const char szTxCloseTime[] = {"TxCloseTime"};
  37. const char szLockBaud[] = {"LockBaud"};
  38. const char szMap2StopsTo1[] = {"Map2StopsTo1"};
  39. const char szMapCdToDsr[] = {"MapCdToDsr"};
  40. const char szRingEmulate[] = {"RingEmulate"};
  41. Our_Options driver_options[] = {
  42. // driver options
  43. {szVerboseLog, OP_VerboseLog , OP_T_DWORD, OP_F_VSRK},
  44. {szNumDevices, OP_NumDevices , OP_T_DWORD, OP_F_VSRK},
  45. #ifdef NT50
  46. {szNoPnpPorts, OP_NoPnpPorts , OP_T_DWORD, OP_F_VSRK},
  47. #endif
  48. {szScanRate, OP_ScanRate , OP_T_DWORD, OP_F_VSRK},
  49. {szModemCountry, OP_ModemCountry , OP_T_DWORD, OP_F_VSRK},
  50. {szGlobalRS485, OP_GlobalRS485 , OP_T_DWORD, OP_F_VSRK},
  51. {NULL,0,0,0}
  52. };
  53. Our_Options device_options[] = {
  54. // device options
  55. // {szStartComIndex, OP_StartComIndex, OP_T_DWORD , OP_F_VSRK},
  56. {szNumPorts, OP_NumPorts , OP_T_DWORD , OP_F_VSRK},
  57. #ifdef S_VS
  58. {szMacAddr, OP_MacAddr , OP_T_STRING, OP_F_VS},
  59. {szBackupServer, OP_BackupServer , OP_T_DWORD , OP_F_VS},
  60. {szBackupTimer, OP_BackupTimer , OP_T_DWORD , OP_F_VS},
  61. #endif
  62. {szName, OP_Name , OP_T_STRING, OP_F_VSRK},
  63. {szModelName, OP_ModelName , OP_T_STRING, OP_F_VSRK},
  64. #ifdef S_RK
  65. #ifndef NT50
  66. {szIoAddress, OP_IoAddress , OP_T_DWORD , OP_F_RK},
  67. #endif
  68. #endif
  69. {szModemDevice, OP_ModemDevice , OP_T_DWORD , OP_F_VSRK},
  70. {szHubDevice, OP_HubDevice , OP_T_DWORD , OP_F_VS},
  71. {szClkRate, OP_ClkRate , OP_T_DWORD , OP_F_VSRK},
  72. {szClkPrescaler, OP_ClkPrescaler , OP_T_DWORD , OP_F_VSRK},
  73. {NULL,0,0,0}
  74. };
  75. Our_Options port_options[] = {
  76. // port options
  77. {szWaitOnTx, OP_WaitOnTx , OP_T_DWORD, OP_F_VSRK},
  78. {szRS485Override, OP_RS485Override, OP_T_DWORD, OP_F_VSRK},
  79. {szRS485Low, OP_RS485Low , OP_T_DWORD, OP_F_VSRK},
  80. {szTxCloseTime, OP_TxCloseTime , OP_T_DWORD, OP_F_VSRK},
  81. {szLockBaud, OP_LockBaud , OP_T_DWORD, OP_F_VSRK},
  82. {szMap2StopsTo1, OP_Map2StopsTo1 , OP_T_DWORD, OP_F_VSRK},
  83. {szMapCdToDsr, OP_MapCdToDsr , OP_T_DWORD, OP_F_VSRK},
  84. {szName, OP_PortName , OP_T_STRING, OP_F_VSRK},
  85. {szRingEmulate, OP_RingEmulate , OP_T_DWORD, OP_F_VSRK},
  86. {NULL,0,0,0}
  87. };
  88. #define INFO_WANT_NUMPORTS 0
  89. #define INFO_WANT_MODEM_DEVICE 1
  90. #define INFO_WANT_HUB_DEVICE 2
  91. #define INFO_WANT_PORTS_PER_AIOP 3
  92. #define INFO_WANT_DEF_CLOCK_PRESC 4
  93. static int IdToInfo(int id, int *ret_dword, int info_wanted);
  94. /*-----------------------------------------------------------------
  95. IdToInfo -
  96. |------------------------------------------------------------------*/
  97. static int IdToInfo(int id, int *ret_val, int info_wanted)
  98. {
  99. int num_ports = 8;
  100. int modem_device = 0;
  101. int hub_device = 0;
  102. int ret_stat = 0; // ok
  103. switch (id)
  104. {
  105. case PCI_DEVICE_RPLUS2:
  106. case PCI_DEVICE_422RPLUS2:
  107. num_ports = 2;
  108. break;
  109. case PCI_DEVICE_RPLUS4:
  110. num_ports = 4;
  111. break;
  112. case PCI_DEVICE_4Q :
  113. num_ports = 4;
  114. break;
  115. case PCI_DEVICE_RMODEM4:
  116. num_ports = 4;
  117. modem_device = 1;
  118. break;
  119. case PCI_DEVICE_4RJ :
  120. num_ports = 4;
  121. break;
  122. case PCI_DEVICE_8RJ :
  123. num_ports = 8;
  124. break;
  125. case PCI_DEVICE_8O :
  126. num_ports = 8;
  127. break;
  128. case PCI_DEVICE_8I :
  129. num_ports = 8;
  130. break;
  131. case PCI_DEVICE_RPLUS8:
  132. num_ports = 8;
  133. break;
  134. case PCI_DEVICE_SIEMENS8:
  135. num_ports = 8;
  136. break;
  137. case PCI_DEVICE_16I :
  138. num_ports = 16;
  139. break;
  140. case PCI_DEVICE_SIEMENS16:
  141. num_ports = 16;
  142. break;
  143. case PCI_DEVICE_32I :
  144. num_ports = 32;
  145. break;
  146. case PCI_DEVICE_RMODEM6 :
  147. num_ports = 6;
  148. modem_device = 1;
  149. break;
  150. case ISA_DEVICE_RPORT4: // rocketport
  151. num_ports = 4;
  152. break;
  153. case ISA_DEVICE_RPORT8:
  154. num_ports = 8;
  155. break;
  156. case ISA_DEVICE_RPORT16:
  157. num_ports = 16;
  158. break;
  159. case ISA_DEVICE_RPORT32:
  160. num_ports = 32;
  161. break;
  162. case ISA_DEVICE_RMODEM4: // rocketmodem isa
  163. num_ports = 4;
  164. modem_device = 1;
  165. break;
  166. case ISA_DEVICE_RMODEM8: // rocketmodem isa
  167. num_ports = 8;
  168. modem_device = 1;
  169. break;
  170. case NET_DEVICE_VS1000:
  171. num_ports = 16; // vs1000, base is 16, expandable
  172. break;
  173. case NET_DEVICE_VS2000: // vs2000, base is 8?
  174. num_ports = 8;
  175. modem_device = 1;
  176. break;
  177. case NET_DEVICE_RHUB8: // vshub-8 port
  178. num_ports = 8;
  179. hub_device = 1;
  180. break;
  181. case NET_DEVICE_RHUB4: // vshub-4 port
  182. num_ports = 4;
  183. hub_device = 1;
  184. break;
  185. default:
  186. ret_stat = 1; // err, unknown device
  187. break;
  188. }
  189. switch (info_wanted)
  190. {
  191. case INFO_WANT_NUMPORTS:
  192. *ret_val = num_ports;
  193. break;
  194. case INFO_WANT_MODEM_DEVICE:
  195. *ret_val = modem_device;
  196. break;
  197. case INFO_WANT_HUB_DEVICE:
  198. *ret_val = hub_device;
  199. break;
  200. #if 0
  201. case INFO_WANT_PORTS_PER_AIOP:
  202. if (PortsPerAiop > num_ports)
  203. PortsPerAiop = num_ports;
  204. *ret_val = PortsPerAiop;
  205. case INFO_WANT_DEF_CLOCK_PRESC:
  206. *ret_val = clk_prescaler;
  207. break;
  208. #endif
  209. default:
  210. ret_stat = 2; // unkown info request
  211. break;
  212. }
  213. return ret_stat;
  214. }
  215. /*-----------------------------------------------------------------
  216. id_to_num_ports - pci model-id number used, rest come from NT5 .inf
  217. files.
  218. |------------------------------------------------------------------*/
  219. int id_to_num_ports(int id)
  220. {
  221. int stat;
  222. int num_ports;
  223. stat = IdToInfo(id, &num_ports, INFO_WANT_NUMPORTS);
  224. return num_ports;
  225. }
  226. /*-----------------------------------------------------------------
  227. IsHubDevice -
  228. |------------------------------------------------------------------*/
  229. int IsHubDevice(int Hardware_ID)
  230. {
  231. int stat;
  232. int ishub;
  233. stat = IdToInfo(Hardware_ID, &ishub, INFO_WANT_HUB_DEVICE);
  234. return ishub;
  235. }
  236. /*-----------------------------------------------------------------
  237. IsModemDevice -
  238. |------------------------------------------------------------------*/
  239. int IsModemDevice(int Hardware_ID)
  240. {
  241. int stat;
  242. int ismodemdev;
  243. stat = IdToInfo(Hardware_ID, &ismodemdev, INFO_WANT_MODEM_DEVICE);
  244. return ismodemdev;
  245. }
  246. /*-----------------------------------------------------------------
  247. HdwIDStrToID - Parse the hardware ID string obtained by the WinNT
  248. Pnp system.
  249. This is broke if we ever get ID's starting digit >= HEX(A,B..)
  250. |------------------------------------------------------------------*/
  251. int HdwIDStrToID(int *Hardware_ID, char *idstr)
  252. {
  253. char *s = idstr;
  254. #define _IS_STR_DIGIT(c) ((c >= '0') && (c <= '9'))
  255. #define _IS_STR_LET_D(c) ((c == 'D') || (c == 'd'))
  256. if (strlen(s) < 12) // a isa hardware id
  257. {
  258. while ( (*s != 0) && (!_IS_STR_DIGIT(*s)) ) // find digit
  259. ++s;
  260. }
  261. else // a pci hardware id
  262. {
  263. while ( (*s != 0) && (!_IS_STR_LET_D(*s)) ) // find "DEV_
  264. ++s;
  265. if (*s != 0)
  266. ++s; // pass up the 'D'
  267. while ( (*s != 0) && (!_IS_STR_DIGIT(*s)) ) // find digit
  268. ++s;
  269. // asume we found "DEV_000X"
  270. }
  271. if (*s == 0)
  272. {
  273. *Hardware_ID = 0; // unknown
  274. return 1; // err
  275. }
  276. *Hardware_ID = gethint(s, NULL);
  277. return 0; // ok
  278. }