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.

134 lines
4.1 KiB

  1. #pragma once
  2. #include "netcfgx.h"
  3. #include "global.h"
  4. #include "param.h"
  5. const int c_nMaxLCStrLen = 128;
  6. const int c_nMaxResStrLen = 50;
  7. const int c_nMaxResCtls = 4;
  8. // Holds a possible IRQ value.
  9. typedef struct tagIRQ_LIST_ELEMENT {
  10. DWORD dwIRQ; // A possible value for the IRQ.
  11. BOOL fConflict; // Is there a conflict with another device?
  12. BOOL fAllocated; // Is this the IRQ we're currently allocated?
  13. } IRQ_LIST_ELEMENT, *PIRQ_LIST_ELEMENT;
  14. // Holds a possible DMA value.
  15. typedef struct tagDMA_LIST_ELEMENT {
  16. DWORD dwDMA; // A possible value for the DMA.
  17. BOOL fConflict; // Is there a conflict with another device?
  18. BOOL fAllocated; // Is this the IRQ we're currently allocated?
  19. } DMA_LIST_ELEMENT, *PDMA_LIST_ELEMENT;
  20. // Holds a possible IO base/end pair.
  21. typedef struct tagIO_LIST_ELEMENT {
  22. DWORD dwIO_Base;
  23. DWORD dwIO_End;
  24. BOOL fConflict;
  25. BOOL fAllocated;
  26. } IO_LIST_ELEMENT, *PIO_LIST_ELEMENT;
  27. // Holds a possible Mem base/end pair.
  28. typedef struct tagMEM_LIST_ELEMENT {
  29. DWORD dwMEM_Base;
  30. DWORD dwMEM_End;
  31. BOOL fConflict;
  32. BOOL fAllocated;
  33. } MEM_LIST_ELEMENT, *PMEM_LIST_ELEMENT;
  34. // Define the different types of lists.
  35. typedef vector<PIRQ_LIST_ELEMENT> IRQ_LIST;
  36. typedef IRQ_LIST* PIRQ_LIST;
  37. typedef vector<PDMA_LIST_ELEMENT> DMA_LIST;
  38. typedef DMA_LIST* PDMA_LIST;
  39. typedef vector<PIO_LIST_ELEMENT> IO_LIST;
  40. typedef IO_LIST* PIO_LIST;
  41. typedef vector<PMEM_LIST_ELEMENT> MEM_LIST;
  42. typedef MEM_LIST* PMEM_LIST;
  43. typedef struct {
  44. RESOURCEID ResourceType;
  45. RES_DES ResDes;
  46. union {
  47. PIRQ_LIST pIRQList; // These really are STL vectors
  48. PDMA_LIST pDMAList;
  49. PIO_LIST pIOList;
  50. PMEM_LIST pMEMList;
  51. };
  52. size_t pos; // current index within vector
  53. size_t applied_pos; // pos that was last applied (the "in-memory" state);
  54. } RESOURCE, *PRESOURCE;
  55. typedef struct tagCONFIGURATION {
  56. LOG_CONF LogConf;
  57. BOOL fBoot;
  58. BOOL fAlloc;
  59. RESOURCE aResource[c_nMaxResCtls];
  60. UINT cResource; // number of elements in aResource;
  61. } CONFIGURATION, *PCONFIGURATION;
  62. typedef vector<PCONFIGURATION> CONFIGURATION_LIST;
  63. class CHwRes {
  64. public:
  65. CHwRes();
  66. ~CHwRes();
  67. HRESULT HrInit(const DEVNODE& devnode);
  68. VOID UseAnswerFile(const WCHAR * const szAnswerfile,
  69. const WCHAR * const szSection);
  70. HRESULT HrValidateAnswerfileSettings(BOOL fDisplayUI);
  71. BOOL FCommitAnswerfileSettings();
  72. private:
  73. CONFIGURATION_LIST m_ConfigList;
  74. RESOURCE m_Resource[c_nMaxResCtls];
  75. // Config Manager stuff
  76. DEVNODE m_DevNode; // devnode for this netcard
  77. // COM stuff
  78. INetCfgComponent* m_pnccItem;
  79. // state flags
  80. BOOL m_fInitialized;
  81. BOOL m_fHrInitCalled;
  82. BOOL m_fDirty; // Do we need to save?
  83. // holds answerfile values
  84. CValue m_vAfDma;
  85. CValue m_vAfIrq;
  86. CValue m_vAfMem;
  87. CValue m_vAfIo;
  88. CValue m_vAfMemEnd;
  89. CValue m_vAfIoEnd;
  90. private:
  91. HRESULT HrInitConfigList ();
  92. BOOL FInitResourceList(PCONFIGURATION pConfiguration);
  93. VOID InitIRQList(PIRQ_LIST* ppIRQList, PIRQ_RESOURCE pIRQResource);
  94. VOID InitDMAList(PDMA_LIST* ppDMAList, PDMA_RESOURCE pDMAResource);
  95. VOID InitMEMList(PMEM_LIST* ppMEMList, PMEM_RESOURCE pMEMResource);
  96. VOID InitIOList(PIO_LIST* ppIOList, PIO_RESOURCE pIOResource);
  97. VOID GetNextElement(PRESOURCE pResource, PVOID *ppeList, BOOL fNext);
  98. BOOL FValidateAnswerfileResources();
  99. BOOL FCreateBootConfig(
  100. CValue * pvMEM,
  101. CValue * pvMEMEnd,
  102. CValue * pvIO,
  103. CValue * pvIOEnd,
  104. CValue * pvDMA,
  105. CValue * pvIRQ);
  106. BOOL FValidateIRQ(PCONFIGURATION pConfig, ULONG ulIRQ);
  107. BOOL FValidateDMA(PCONFIGURATION pConfig, ULONG ulDMA);
  108. BOOL FGetIOEndPortGivenBasePort(PCONFIGURATION pConfig, DWORD dwBase,
  109. DWORD* pdwEnd);
  110. BOOL FGetMEMEndGivenBase(PCONFIGURATION pConfig, DWORD dwBase,
  111. DWORD* pdwEnd);
  112. };