Source code of Windows XP (NT5)
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.

255 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. regresls.cxx
  5. Abstract:
  6. This module contains the definitions of the member functions
  7. of IO_REQUIREMENTS_LIST class.
  8. Author:
  9. Jaime Sasson (jaimes) 02-Dec-1993
  10. Environment:
  11. ULIB, User Mode
  12. --*/
  13. #include "regioreq.hxx"
  14. #include "iterator.hxx"
  15. #include "regiodsc.hxx"
  16. #include "regiodls.hxx"
  17. DEFINE_CONSTRUCTOR ( IO_REQUIREMENTS_LIST, OBJECT );
  18. IO_REQUIREMENTS_LIST::~IO_REQUIREMENTS_LIST (
  19. )
  20. /*++
  21. Routine Description:
  22. Destroy a IO_REQUIREMENTS_LIST.
  23. Arguments:
  24. None.
  25. Return Value:
  26. None.
  27. --*/
  28. {
  29. Destroy();
  30. }
  31. VOID
  32. IO_REQUIREMENTS_LIST::Construct (
  33. )
  34. /*++
  35. Routine Description:
  36. Construct an IO_REQUIREMENTS_LIST object.
  37. Arguments:
  38. None.
  39. Return Value:
  40. None.
  41. --*/
  42. {
  43. _InterfaceType = Internal;
  44. _BusNumber = 0;
  45. _SlotNumber = 0;
  46. _Reserved1 = 0;
  47. _Reserved2 = 0;
  48. _Reserved3 = 0;
  49. _AlternativeLists = NULL;
  50. }
  51. VOID
  52. IO_REQUIREMENTS_LIST::Destroy (
  53. )
  54. /*++
  55. Routine Description:
  56. Worker method for object destruction.
  57. Arguments:
  58. None.
  59. Return Value:
  60. None.
  61. --*/
  62. {
  63. if( _AlternativeLists != NULL ) {
  64. _AlternativeLists->DeleteAllMembers();
  65. DELETE( _AlternativeLists );
  66. }
  67. _AlternativeLists = NULL;
  68. }
  69. BOOLEAN
  70. IO_REQUIREMENTS_LIST::Initialize(
  71. IN PCBYTE Data,
  72. IN ULONG Size
  73. )
  74. /*++
  75. Routine Description:
  76. Initialize an object of type IO_REQUIREMENTS_LIST.
  77. Arguments:
  78. Data - Pointer to a buffer that contains a IO_RESOURCE_REQUIREMETS_LIST.
  79. Size - Buffer size.
  80. Return Value:
  81. BOOLEAN - Returns TRUE if the initialization succeeds.
  82. --*/
  83. {
  84. PIO_RESOURCE_LIST ResourceList;
  85. ULONG Count;
  86. ULONG i;
  87. PARRAY TmpList;
  88. ULONG BufferSize;
  89. ULONG ResourceListSize;
  90. if( Data == NULL ) {
  91. return( FALSE );
  92. }
  93. Count = ( ( PIO_RESOURCE_REQUIREMENTS_LIST )Data )->AlternativeLists;
  94. ResourceList = ( ( PIO_RESOURCE_REQUIREMENTS_LIST )Data )->List;
  95. TmpList = ( PARRAY )NEW( ARRAY );
  96. DebugPtrAssert( TmpList );
  97. if( ( TmpList == NULL ) ||
  98. ( !TmpList->Initialize() ) ) {
  99. DebugPrintTrace(("REGEDT32: Out of memory" ));
  100. DELETE( TmpList );
  101. return( FALSE );
  102. }
  103. //
  104. // For each IO_RESOURCE_LIST in the current value...
  105. //
  106. BufferSize = Size - // Data size
  107. sizeof( ULONG ) - // ListSize
  108. sizeof( INTERFACE_TYPE ) - // InterfaceType
  109. sizeof( ULONG ) - // BusNumber
  110. sizeof( ULONG ) - // SlotNumber
  111. 3*sizeof( ULONG ) - // Reserved1, 2 and 3
  112. sizeof( ULONG ); // AlternativeLists
  113. for( i = 0; i < Count; i++ ) {
  114. PIO_DESCRIPTOR_LIST IoDescriptorList;
  115. IoDescriptorList = ( PIO_DESCRIPTOR_LIST )NEW( IO_DESCRIPTOR_LIST );
  116. if( ( IoDescriptorList == NULL ) ||
  117. !IoDescriptorList->Initialize( ( PCBYTE )ResourceList,
  118. BufferSize,
  119. &ResourceListSize )
  120. ) {
  121. DebugPrint( "REGEDT32: Unable to create or initialize IoDescriptorList \n" );
  122. DELETE( IoDescriptorList );
  123. TmpList->DeleteAllMembers();
  124. DELETE( TmpList );
  125. return( FALSE );
  126. }
  127. TmpList->Put( IoDescriptorList );
  128. #if DBG
  129. if( BufferSize < ResourceListSize ) {
  130. DebugPrintTrace(( "REGEDT32: incorrect sizes, BufferSize = %d, ResourceListSize = %d \n",
  131. BufferSize, ResourceListSize ));
  132. }
  133. #endif
  134. ResourceList = ( PIO_RESOURCE_LIST )( ( ULONG_PTR )ResourceList + ResourceListSize );
  135. BufferSize -= ResourceListSize;
  136. }
  137. _AlternativeLists = TmpList;
  138. _InterfaceType = ( ( PIO_RESOURCE_REQUIREMENTS_LIST )Data )->InterfaceType;
  139. _BusNumber = ( ( PIO_RESOURCE_REQUIREMENTS_LIST )Data )->BusNumber;
  140. _SlotNumber = ( ( PIO_RESOURCE_REQUIREMENTS_LIST )Data )->SlotNumber;
  141. return( TRUE );
  142. }
  143. #if DBG
  144. VOID
  145. IO_REQUIREMENTS_LIST::DbgDumpObject(
  146. )
  147. /*++
  148. Routine Description:
  149. Print an IO_REQUIREMENTS_LIST object.
  150. Arguments:
  151. None.
  152. Return Value:
  153. None.
  154. --*/
  155. {
  156. PITERATOR Iterator;
  157. PIO_DESCRIPTOR_LIST DescriptorList;
  158. DebugPrintTrace(( "*** Dumping IO_REQUIREMENTS_LIST \n\n" ));
  159. DebugPrintTrace(( "InterfaceType = %d \n", _InterfaceType ));
  160. DebugPrintTrace(( "BusNumber = %#lx \n", _BusNumber ));
  161. DebugPrintTrace(( "SlotNumber = %#lx \n", _SlotNumber ));
  162. DebugPrintTrace(( "Reserved1 = %#x \n", _Reserved1 ));
  163. DebugPrintTrace(( "Reserved2 = %#x \n", _Reserved2 ));
  164. DebugPrintTrace(( "Reserved3 = %#x \n", _Reserved3 ));
  165. if( _AlternativeLists != NULL ) {
  166. Iterator = _AlternativeLists->QueryIterator();
  167. while( DescriptorList = ( PIO_DESCRIPTOR_LIST ) Iterator->GetNext() ) {
  168. DescriptorList->DbgDumpObject();
  169. }
  170. DELETE( Iterator );
  171. } else {
  172. DebugPrintTrace(( "IO_REQUIREMENTS_LIST is empty \n\n" ));
  173. }
  174. }
  175. #endif