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.

224 lines
3.9 KiB

  1. //***************************************************************************
  2. // Device queue process
  3. //
  4. //***************************************************************************
  5. #include "common.h"
  6. #include "que.h"
  7. void DeviceQueue::init( void )
  8. {
  9. count = 0;
  10. top = bottom = NULL;
  11. }
  12. void DeviceQueue::put( PHW_STREAM_REQUEST_BLOCK pOrigin, PHW_STREAM_REQUEST_BLOCK pSrb )
  13. {
  14. pSrb->NextSRB = NULL;
  15. if ( top == NULL ) {
  16. top = bottom = pSrb;
  17. count++;
  18. return;
  19. }
  20. bottom->NextSRB = pSrb;
  21. bottom = pSrb;
  22. count++;
  23. return;
  24. }
  25. void DeviceQueue::put_first( PHW_STREAM_REQUEST_BLOCK pSrb )
  26. {
  27. // This routine does not called
  28. }
  29. void DeviceQueue::put_from_bottom( PHW_STREAM_REQUEST_BLOCK pSrb )
  30. {
  31. // This routine does not called
  32. }
  33. void DeviceQueue::put_video( PHW_STREAM_REQUEST_BLOCK pSrb )
  34. {
  35. SRBIndex( pSrb ) = 0;
  36. SRBpfnEndSrb( pSrb ) = NULL;
  37. SRBparamSrb( pSrb ) = NULL;
  38. put( top, pSrb );
  39. }
  40. void DeviceQueue::put_audio( PHW_STREAM_REQUEST_BLOCK pSrb )
  41. {
  42. SRBIndex( pSrb ) = 0;
  43. SRBpfnEndSrb( pSrb ) = NULL;
  44. SRBparamSrb( pSrb ) = NULL;
  45. put( top, pSrb );
  46. }
  47. void DeviceQueue::put_subpic( PHW_STREAM_REQUEST_BLOCK pSrb )
  48. {
  49. SRBIndex( pSrb ) = 0;
  50. SRBpfnEndSrb( pSrb ) = NULL;
  51. SRBparamSrb( pSrb ) = NULL;
  52. put( top, pSrb );
  53. }
  54. PHW_STREAM_REQUEST_BLOCK DeviceQueue::get( PULONG index, PBOOLEAN last )
  55. {
  56. PHW_STREAM_REQUEST_BLOCK srb;
  57. if ( top == NULL )
  58. return NULL;
  59. srb = top;
  60. (*index) = SRBIndex( srb );
  61. // debug
  62. #if DBG
  63. if( srb->NumberOfPhysicalPages == 0 )
  64. TRAP;
  65. #endif
  66. if ( SRBIndex( srb ) != ( srb->NumberOfPhysicalPages - 1 ) ) {
  67. (*last) = FALSE;
  68. SRBIndex( srb )++;
  69. return srb;
  70. }
  71. (*last) = TRUE;
  72. top = top->NextSRB;
  73. count--;
  74. if ( count == 0 )
  75. top = bottom = NULL;
  76. return srb;
  77. }
  78. PHW_STREAM_REQUEST_BLOCK DeviceQueue::refer1st( PULONG index, PBOOLEAN last )
  79. {
  80. PHW_STREAM_REQUEST_BLOCK srb;
  81. if( top == NULL )
  82. return NULL;
  83. srb = top;
  84. (*index) = SRBIndex( srb );
  85. if ( SRBIndex( srb ) != ( srb->NumberOfPhysicalPages - 1 ) ) {
  86. (*last) = FALSE;
  87. }
  88. else {
  89. (*last) = TRUE;
  90. }
  91. return srb;
  92. }
  93. PHW_STREAM_REQUEST_BLOCK DeviceQueue::refer2nd( PULONG index, PBOOLEAN last )
  94. {
  95. PHW_STREAM_REQUEST_BLOCK srb;
  96. if( top == NULL )
  97. return NULL;
  98. srb = top;
  99. if( SRBIndex( srb ) != ( srb->NumberOfPhysicalPages - 1) ) {
  100. (*index) = SRBIndex( srb ) + 1;
  101. if( (SRBIndex( srb ) + 1) != ( srb->NumberOfPhysicalPages - 1 ) ) {
  102. (*last) = FALSE;
  103. }
  104. else {
  105. (*last) = TRUE;
  106. }
  107. }
  108. else {
  109. srb = srb->NextSRB;
  110. if( srb == NULL )
  111. return NULL;
  112. (*index) = SRBIndex( srb );
  113. if( SRBIndex( srb ) != ( srb->NumberOfPhysicalPages - 1 ) ) {
  114. (*last) = FALSE;
  115. }
  116. else {
  117. (*last) = TRUE;
  118. }
  119. }
  120. return srb;
  121. }
  122. void DeviceQueue::remove( PHW_STREAM_REQUEST_BLOCK pSrb )
  123. {
  124. if ( top == NULL )
  125. return;
  126. if( top == pSrb ) {
  127. top = top->NextSRB;
  128. count--;
  129. if ( count == 0 )
  130. top = bottom = NULL;
  131. DebugPrint(( DebugLevelTrace, "TOSDVD:DeviceQueue::remove srb = 0x%x\r\n", pSrb ));
  132. return;
  133. }
  134. PHW_STREAM_REQUEST_BLOCK srbPrev;
  135. PHW_STREAM_REQUEST_BLOCK srb;
  136. srbPrev = top;
  137. srb = srbPrev->NextSRB;
  138. while ( srb != NULL ) {
  139. if( srb == pSrb ) {
  140. srbPrev->NextSRB = srb->NextSRB;
  141. if( srbPrev->NextSRB == bottom )
  142. bottom = srbPrev;
  143. count--;
  144. DebugPrint(( DebugLevelTrace, "TOSDVD:DeviceQueue::remove srb = 0x%x\r\n", pSrb ));
  145. break;
  146. }
  147. srbPrev = srb;
  148. srb = srbPrev->NextSRB;
  149. }
  150. }
  151. BOOL DeviceQueue::setEndAddress( PHW_TIMER_ROUTINE pfn, PHW_STREAM_REQUEST_BLOCK pSrb )
  152. {
  153. PHW_STREAM_REQUEST_BLOCK srb;
  154. srb = top;
  155. while( srb != NULL ) {
  156. if( srb->NextSRB == NULL ) {
  157. SRBpfnEndSrb( srb ) = pfn;
  158. SRBparamSrb( srb ) = pSrb;
  159. DebugPrint(( DebugLevelTrace, "TOSDVD:setEndAddress srb = 0x%x\r\n", srb ));
  160. return TRUE;
  161. }
  162. srb = srb->NextSRB;
  163. }
  164. return FALSE;
  165. }
  166. //--- 97.09.14 K.Chujo
  167. BOOL DeviceQueue::isEmpty( void )
  168. {
  169. if( top==NULL )
  170. return TRUE;
  171. else
  172. return FALSE;
  173. }
  174. ULONG DeviceQueue::getCount( void )
  175. {
  176. return( count );
  177. }
  178. //--- End.