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.

118 lines
3.0 KiB

  1. /************************************************************************
  2. intecfg.cpp
  3. -- Intellio board configuration function
  4. History: Date Author Comment
  5. 8/14/00 Casper Wrote it.
  6. *************************************************************************/
  7. #include "stdafx.h"
  8. #include <setupapi.h>
  9. #include <cfgmgr32.h>
  10. #include "moxacfg.h"
  11. #include "intetype.h"
  12. /*
  13. compare two Intellio MoxaOneCfg struct.
  14. return 0: equal,
  15. return <> 0 : not equal
  16. */
  17. int Inte_CompConfig(LPMoxaOneCfg cfg1, LPMoxaOneCfg cfg2)
  18. {
  19. int j, m;
  20. if ((cfg1->BoardType != cfg2->BoardType) ||
  21. (cfg1->BusType != cfg2->BusType))
  22. return(1);
  23. if(cfg1->BusType == MX_BUS_PCI){
  24. if((cfg1->Pci.BusNum != cfg2->Pci.BusNum) ||
  25. (cfg1->Pci.DevNum != cfg2->Pci.DevNum))
  26. return 1;
  27. }
  28. if ( cfg1->Irq != cfg2->Irq )
  29. return(11);
  30. if ( cfg1->MemBank != cfg2->MemBank )
  31. return(12);
  32. if (cfg1->NPort != cfg2->NPort)
  33. return 20;
  34. m = cfg1->NPort;
  35. for ( j=0; j<m; j++ ) {
  36. if ( cfg1->ComNo[j] != cfg2->ComNo[j] )
  37. return(21);
  38. }
  39. for ( j=0; j<m; j++ ) {
  40. if ( cfg1->DisableFiFo[j] != cfg2->DisableFiFo[j] )
  41. return(22);
  42. }
  43. for ( j=0; j<m; j++ ) {
  44. if ( cfg1->NormalTxMode[j] != cfg2->NormalTxMode[j] )
  45. return(23);
  46. }
  47. return(0);
  48. }
  49. /*
  50. Get Intellio board FIFO setting & Transmission mode
  51. */
  52. BOOL Inte_GetFifo(HDEVINFO DeviceInfoSet,
  53. PSP_DEVINFO_DATA DeviceInfoData,
  54. LPMoxaOneCfg cfg)
  55. {
  56. HKEY hkey, hkey2;
  57. char tmp[MAX_PATH];
  58. DWORD type;
  59. DWORD len;
  60. hkey = SetupDiOpenDevRegKey(
  61. DeviceInfoSet, DeviceInfoData,
  62. DICS_FLAG_GLOBAL, 0, DIREG_DRV, KEY_READ);
  63. if(hkey!=INVALID_HANDLE_VALUE){
  64. wsprintf( tmp, TEXT("Parameters") );
  65. if(RegOpenKeyEx( hkey, tmp, 0, KEY_READ, &hkey2)
  66. != ERROR_SUCCESS){
  67. RegCloseKey(hkey);
  68. return TRUE;
  69. }
  70. type = REG_DWORD;
  71. len = MAX_PATH;
  72. RegQueryValueEx( hkey2,
  73. TEXT("NumPorts"), 0, &type, (LPBYTE)&(cfg->NPort), &len);
  74. RegCloseKey(hkey2);
  75. for(int i=0; i<cfg->NPort; i++){
  76. wsprintf( tmp, TEXT("Parameters\\port%03d"), i+1 );
  77. if(RegOpenKeyEx( hkey, tmp, 0, KEY_READ, &hkey2)
  78. != ERROR_SUCCESS)
  79. continue;
  80. type = REG_DWORD;
  81. len = sizeof(DWORD);
  82. RegQueryValueEx( hkey2,
  83. TEXT("DisableFiFo"), 0, &type, (LPBYTE)&(cfg->DisableFiFo[i]), &len);
  84. type = REG_DWORD;
  85. len = sizeof(DWORD);
  86. RegQueryValueEx( hkey2,
  87. TEXT("TxMode"), 0, &type, (LPBYTE)&(cfg->NormalTxMode[i]), &len);
  88. type = REG_DWORD;
  89. len = sizeof(DWORD);
  90. RegQueryValueEx( hkey2,
  91. TEXT("PollingPeriod"), 0, &type, (LPBYTE)&(cfg->polling[i]), &len);
  92. RegCloseKey(hkey2);
  93. }
  94. }
  95. RegCloseKey(hkey);
  96. return TRUE;
  97. }