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
6.2 KiB

  1. //***************************************************************************
  2. // Debug
  3. //
  4. //***************************************************************************
  5. #include "common.h"
  6. typedef struct tagPack {
  7. DWORD pack_start_code;
  8. BYTE scr_byte[6];
  9. DWORD program_mux_rate; // ���ۂɂ͓����� 3 �o�C�g
  10. } PACK, *PPACK;
  11. #if DBG
  12. void DebugDumpWriteData( PHW_STREAM_REQUEST_BLOCK pSrb )
  13. {
  14. ULONG i;
  15. unsigned char *p;
  16. PKSSTREAM_HEADER pStruc;
  17. // PHYSICAL_ADDRESS phyadd;
  18. static DWORD scr;
  19. // PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  20. DebugPrint( (DebugLevelVerbose, "TOSDVD: SRB pointer 0x%x\r\n", pSrb ) );
  21. DebugPrint( (DebugLevelVerbose, "TOSDVD: NumberOfPhysicalPages %d\r\n", pSrb->NumberOfPhysicalPages ) );
  22. for( i = 0; i < pSrb->NumberOfPhysicalPages; i++ ) {
  23. DebugPrint( (DebugLevelVerbose, "TOSDVD: PhysicalAddress[%d] 0x%x\r\n", i, pSrb->ScatterGatherBuffer[i].PhysicalAddress ) );
  24. DebugPrint( (DebugLevelVerbose, "TOSDVD: Length[%d] %d(0x%x)\r\n", i, pSrb->ScatterGatherBuffer[i].Length, pSrb->ScatterGatherBuffer[i].Length ) );
  25. }
  26. DebugPrint( (DebugLevelVerbose, "TOSDVD:NumberOfBuffers %d\r\n", pSrb->NumberOfBuffers ) );
  27. DebugPrint( (DebugLevelVerbose, "TOSDVD:NumberOfBytesToTransfer %d\r\n", pSrb->NumberOfBytesToTransfer ) );
  28. for( i = 0; i < pSrb->NumberOfBuffers; i++ ) {
  29. DebugPrint( (DebugLevelVerbose, "TOSDVD:DataBufferArray[%d] 0x%x\r\n", i, &(pSrb->CommandData.DataBufferArray[i]) ) );
  30. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[i];
  31. DebugPrint( (DebugLevelVerbose, "TOSDVD: Time 0x%x 0x%x\r\n", (DWORD)( ((ULONGLONG)pStruc->PresentationTime.Time) >> 32 ), (DWORD)( pStruc->PresentationTime.Time ) ) );
  32. DebugPrint( (DebugLevelVerbose, "TOSDVD: Numerator 0x%x\r\n", pStruc->PresentationTime.Numerator ) );
  33. DebugPrint( (DebugLevelVerbose, "TOSDVD: Denominator 0x%x\r\n", pStruc->PresentationTime.Denominator ) );
  34. if( pStruc->PresentationTime.Denominator != 0 ) {
  35. DebugPrint( (DebugLevelVerbose, "TOSDVD: ? Time ? %d\r\n",
  36. (DWORD)( pStruc->PresentationTime.Time * pStruc->PresentationTime.Numerator / pStruc->PresentationTime.Denominator )
  37. ) );
  38. }
  39. DebugPrint( (DebugLevelVerbose, "TOSDVD: Duration 0x%x 0x%x\r\n", (DWORD)( ((ULONGLONG)pStruc->Duration) >> 32), (DWORD)(pStruc->Duration) ) );
  40. // kato //DebugPrint( (DebugLevelVerbose, "TOSDVD: DataSize %d\r\n", pStruc->DataSize ) );
  41. DebugPrint( (DebugLevelVerbose, "TOSDVD: DataUsed %d\r\n", pStruc->DataUsed ) );
  42. DebugPrint( (DebugLevelVerbose, "TOSDVD: Data 0x%x\r\n", pStruc->Data ) );
  43. //phyadd = MmGetPhysicalAddress( pStruc->Data );
  44. //DebugPrint( (DebugLevelVerbose, "TOSDVD: Physical address 0x%x\r\n", phyadd.LowPart ) );
  45. p = (PUCHAR)pStruc->Data;
  46. // BGP - HACK - this should be fixed
  47. p += 14;
  48. DebugPrint( (DebugLevelVerbose, "TOSDVD: %02x %02x %02x %02x %02x %02x %02x %02x\r\n",
  49. *(p+0), *(p+1), *(p+2), *(p+3),
  50. *(p+4), *(p+5), *(p+6), *(p+7)
  51. ) );
  52. if( p != NULL ) {
  53. scr = GgetSCR( p - 14 );
  54. DebugPrint( (DebugLevelVerbose, "TOSDVD: SCR 0x%x( %d )\r\n", scr, scr ) );
  55. }
  56. // if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY ) {
  57. // TRAP;
  58. // }
  59. // if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_TIMEDISCONTINUITY ) {
  60. // TRAP;
  61. // }
  62. // if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_FLUSHONPAUSE ) {
  63. // TRAP;
  64. // }
  65. }
  66. // if( pSrb->NumberOfBuffers > 1 )
  67. // TRAP;
  68. }
  69. //void DebugDumpPackHeader( PHW_STREAM_REQUEST_BLOCK pSrb )
  70. //{
  71. // ULONG i, j;
  72. // unsigned char *p;
  73. // PKSSTREAM_HEADER pStruc;
  74. // DWORD scr;
  75. // PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  76. // static int count = 0;
  77. //
  78. // for( i = 0; i < pSrb->NumberOfBuffers; i++ ) {
  79. // pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[i];
  80. // p = pStruc->Data;
  81. // if( p != NULL ) {
  82. // scr = GgetSCR( p);
  83. //
  84. // if( scr < 0x100 ) {
  85. // for( j = 0; j < 32; j++ )
  86. // pHwDevExt->dmp[count++] = 0xaa;
  87. // }
  88. // if( count >= 32*10000 )
  89. // TRAP;
  90. //
  91. // for( j = 0; j < 32; j++ )
  92. // pHwDevExt->dmp[count++] = *(p+j);
  93. // if( count >= 32*10000 )
  94. // TRAP;
  95. // pHwDevExt->dmp[count] = 0xff;
  96. // pHwDevExt->dmp[count+1] = 0xff;
  97. // pHwDevExt->dmp[count+2] = 0xff;
  98. // pHwDevExt->dmp[count+3] = 0xff;
  99. // }
  100. // }
  101. //}
  102. //void DebugDumpKSTIME( PHW_STREAM_REQUEST_BLOCK pSrb )
  103. //{
  104. // int j;
  105. // PKSSTREAM_HEADER pStruc;
  106. // PUCHAR p;
  107. // PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  108. // static int count = 0;
  109. //
  110. // pStruc = (PKSSTREAM_HEADER)pSrb->CommandData.DataBufferArray;
  111. //
  112. // if( pStruc->OptionsFlags == 0 ) {
  113. // p = (PUCHAR)&pStruc[0];
  114. //
  115. // for( j = 0; j < 16; j++ )
  116. // pHwDevExt->dmp2[count++] = *(p+j);
  117. // if( count >= 16*10000 ) {
  118. // TRAP;
  119. // count = 0;
  120. // }
  121. // }
  122. //}
  123. char * DebugLLConvtoStr( ULONGLONG val, int base )
  124. {
  125. static char str[5][100];
  126. static int cstr = -1;
  127. int count = 0;
  128. int digit;
  129. char tmp[100];
  130. int i;
  131. if( ++cstr >= 5 )
  132. cstr = 0;
  133. if( base == 10 ) {
  134. for( ; ; ) {
  135. digit = (int)( val % 10 );
  136. tmp[count++] = (char)( digit + '0' );
  137. val /= 10;
  138. if( val == 0 )
  139. break;
  140. }
  141. }
  142. else if( base == 16 ) {
  143. for( ; ; ) {
  144. digit = (int)( val & 0xF );
  145. if( digit < 10 )
  146. tmp[count++] = (char)( digit + '0' );
  147. else
  148. tmp[count++] = (char)( digit - 10 + 'a' );
  149. val >>= 4;
  150. if( val == 0 )
  151. break;
  152. }
  153. }
  154. else
  155. TRAP;
  156. for( i = 0; i < count; i++ ) {
  157. str[cstr][i] = tmp[count-i-1];
  158. }
  159. str[cstr][i] = '\0';
  160. return str[cstr];
  161. }
  162. #endif
  163. DWORD GgetSCR( void *pBuf )
  164. {
  165. PPACK pPack = (PPACK)pBuf;
  166. DWORD scr;
  167. if( ( (DWORD)pPack->scr_byte[0] & 0xc0L ) == 0 ) { // MPEG1
  168. scr = ( (DWORD)pPack->scr_byte[0] & 0x6L ) << 29;
  169. scr |= ( (DWORD)pPack->scr_byte[1] ) << 22;
  170. scr |= ( (DWORD)pPack->scr_byte[2] & 0xfeL ) << 14;
  171. scr |= ( (DWORD)pPack->scr_byte[3] ) << 7;
  172. scr |= ( (DWORD)pPack->scr_byte[4] & 0xfeL ) >> 1;
  173. }
  174. else { // MPEG2 or DVD
  175. scr = ( (DWORD)pPack->scr_byte[0] & 0x18L ) << 27;
  176. scr |= ( (DWORD)pPack->scr_byte[0] & 0x3L ) << 28;
  177. scr |= ( (DWORD)pPack->scr_byte[1] ) << 20;
  178. scr |= ( (DWORD)pPack->scr_byte[2] & 0xf8L ) << 12;
  179. scr |= ( (DWORD)pPack->scr_byte[2] & 0x3L ) << 13;
  180. scr |= ( (DWORD)pPack->scr_byte[3] ) << 5;
  181. scr |= ( (DWORD)pPack->scr_byte[4] & 0xf8L ) >> 3;
  182. }
  183. return scr;
  184. }