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.

217 lines
4.8 KiB

  1. //**************************************************************************
  2. //
  3. // Title : WDMBuff.cpp
  4. //
  5. // Date : 1997.12.08 1st making
  6. //
  7. // Author : Toshiba [PCS](PSY) Hideki Yagi
  8. //
  9. // Copyright 1997 Toshiba Corporation. All Rights Reserved.
  10. //
  11. // -------------------------------------------------------------------------
  12. //
  13. // Change log :
  14. //
  15. // Date Revision Description
  16. // ------------ ---------- -----------------------------------------------
  17. // 1997.12.08 000.0000 1st making.
  18. //
  19. //**************************************************************************
  20. #include "includes.h"
  21. #include "wdmbuff.h"
  22. #include "dvdinit.h"
  23. CWDMBuffer::CWDMBuffer( void )
  24. {
  25. m_pSrb = NULL;
  26. m_WDMBuffNext = NULL;
  27. #ifndef REARRANGEMENT
  28. m_EndFlag = TRUE; //TRUE:last buffer FALSE:non last buffer
  29. m_BuffNumber = 0;
  30. m_StartPacketNumber = 0;
  31. m_PacketNum = 0;
  32. m_BeforePacketNum = 0;
  33. m_Enable = FALSE;
  34. #endif REARRANGEMENT
  35. }
  36. CWDMBuffer::~CWDMBuffer( void )
  37. {
  38. m_pSrb = NULL;
  39. m_WDMBuffNext = NULL;
  40. #ifndef REARRANGEMENT
  41. //�lj����ϐ��̏�����
  42. m_EndFlag = TRUE;
  43. m_BuffNumber = 0;
  44. m_StartPacketNumber = 0;
  45. m_PacketNum = 0;
  46. m_BeforePacketNum = 0;
  47. m_Enable = FALSE;
  48. #endif REARRANGEMENT
  49. }
  50. IMBoardListItem *CWDMBuffer::GetNext( void )
  51. {
  52. return( m_WDMBuffNext );
  53. }
  54. void CWDMBuffer::SetNext( IMBoardListItem *item )
  55. {
  56. m_WDMBuffNext = item;
  57. }
  58. DWORD CWDMBuffer::GetPageNum( void )
  59. {
  60. ASSERT( m_pSrb != NULL );
  61. #ifndef REARRANGEMENT
  62. return ((DWORD) m_PacketNum);
  63. #else
  64. return( (DWORD)(m_pSrb->NumberOfPhysicalPages) ); // Is it OK??????
  65. #endif REARRANGEMENT
  66. // return( (DWORD)(m_pSrb->NumberOfBuffers) ); // Is it OK??????
  67. }
  68. DWORD CWDMBuffer::GetPageSize( DWORD pagenum )
  69. {
  70. ULONG PageSize;
  71. // DWORD i, j;
  72. // PKSSTREAM_HEADER pStruc;
  73. ASSERT( m_pSrb != NULL );
  74. #ifndef REARRANGEMENT
  75. ASSERT( m_PacketNum >= pagenum );
  76. #else
  77. ASSERT( m_pSrb->NumberOfPhysicalPages >= pagenum );
  78. #endif REARRANGEMENT
  79. ASSERT( pagenum != 0 );
  80. #ifndef REARRANGEMENT
  81. PageSize = m_pSrb->ScatterGatherBuffer[m_BeforePacketNum + pagenum - 1].Length;
  82. #else
  83. PageSize = m_pSrb->ScatterGatherBuffer[pagenum-1].Length;
  84. #endif REARRANGEMENT
  85. // DBG_PRINTF( ("WDMBUFF: PageSzie = 0x%0x\n\r", PageSize ) );
  86. /*
  87. j = 0;
  88. for( i=0; i<(m_pSrb->NumberOfBuffers); i++ ){
  89. pStruc = &((PKSSTREAM_HEADER)(m_pSrb->CommandData.DataBufferArray))[i];
  90. if( pStruc->DataUsed != 0 ){
  91. if( !(pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_TYPECHANGED ) ){
  92. // DVD valid data to transfer to decoder board.
  93. PageSize = m_pSrb->ScatterGatherBuffer[j].Length;
  94. j++;
  95. }
  96. if( j>=pagenum )
  97. break;
  98. }
  99. }
  100. */
  101. ASSERT( (PageSize % 2048) == 0 );
  102. return( (DWORD)PageSize );
  103. }
  104. BOOL CWDMBuffer::GetPagePointer( DWORD pagenum, DWORD *LinAddr, DWORD *PhysAddr )
  105. {
  106. PHYSICAL_ADDRESS pAdd;
  107. DWORD i, j;
  108. PKSSTREAM_HEADER pStruc;
  109. ASSERT( m_pSrb != NULL );
  110. #ifndef REARRANGEMENT
  111. ASSERT( m_PacketNum >= pagenum );
  112. #else
  113. ASSERT( m_pSrb->NumberOfPhysicalPages >= pagenum );
  114. #endif REARRANGEMENT
  115. ASSERT( pagenum != 0 );
  116. #ifndef REARRANGEMENT
  117. pAdd = m_pSrb->ScatterGatherBuffer[m_BeforePacketNum + pagenum - 1].PhysicalAddress;
  118. #else
  119. pAdd = m_pSrb->ScatterGatherBuffer[pagenum-1].PhysicalAddress;
  120. #endif REARRANGEMENT
  121. *PhysAddr = (DWORD)(pAdd.LowPart);
  122. *LinAddr = (DWORD)0;
  123. // Linear address is validate?
  124. j = 0;
  125. for( i=0; i<(m_pSrb->NumberOfBuffers); i++ ){
  126. pStruc = &((PKSSTREAM_HEADER)(m_pSrb->CommandData.DataBufferArray))[i];
  127. ASSERT( pStruc != NULL );
  128. if( pStruc->DataUsed != 0 ){
  129. if( !(pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_TYPECHANGED) )
  130. {
  131. // DVD valid data to transfer to decoder board.
  132. *LinAddr = (DWORD)(pStruc->Data);
  133. j++;
  134. }
  135. if( j>=pagenum )
  136. break;
  137. }
  138. }
  139. ASSERT( j != 0 );
  140. ASSERT( *LinAddr != 0 );
  141. return( TRUE );
  142. }
  143. DWORD CWDMBuffer::GetBufferFlag( void )
  144. {
  145. return( (DWORD)0 );
  146. // return( (DWORD)m_pSrb->Flags );
  147. }
  148. BOOL CWDMBuffer::SetSRB( PHW_STREAM_REQUEST_BLOCK pSrb )
  149. {
  150. ASSERT( pSrb != NULL );
  151. if( pSrb == NULL ){
  152. return( FALSE );
  153. }
  154. m_pSrb = pSrb;
  155. return( TRUE );
  156. }
  157. PHW_STREAM_REQUEST_BLOCK CWDMBuffer::GetSRB( void )
  158. {
  159. ASSERT( m_pSrb != NULL );
  160. return( m_pSrb );
  161. }
  162. VOID CWDMBuffer::Init( void )
  163. {
  164. m_pSrb = NULL;
  165. m_WDMBuffNext = NULL;
  166. #ifndef REARRANGEMENT
  167. m_EndFlag = TRUE;
  168. m_BuffNumber = 0;
  169. m_StartPacketNumber = 0;
  170. m_PacketNum = 0;
  171. m_BeforePacketNum = 0;
  172. m_Enable = FALSE;
  173. #endif REARRANGEMENT
  174. }