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.

296 lines
7.6 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1992 - 1999
  3. Module Name:
  4. cdromkd.c
  5. Abstract:
  6. Debugger Extension Api for interpretting cdrom structure
  7. Author:
  8. Henry Gabryjelski (henrygab) 16-Feb-1999
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "pch.h"
  14. #include "classpnp.h" // #defines ALLOCATE_SRB_FROM_POOL as needed
  15. #include "classp.h" // Classpnp's private definitions
  16. #include "cdrom.h"
  17. #include "classkd.h" // routines that are useful for all class drivers
  18. FLAG_NAME XAFlags[] = {
  19. FLAG_NAME(XA_USE_6_BYTE), // 0x01
  20. FLAG_NAME(XA_USE_10_BYTE), // 0x02
  21. FLAG_NAME(XA_USE_READ_CD), // 0x04
  22. FLAG_NAME(XA_NOT_SUPPORTED), // 0x08
  23. FLAG_NAME(XA_PLEXTOR_CDDA), // 0x10
  24. FLAG_NAME(XA_NEC_CDDA), // 0x20
  25. {0,0}
  26. };
  27. VOID
  28. ClassDumpCdromData(
  29. ULONG64 Address,
  30. ULONG Detail,
  31. ULONG Depth
  32. );
  33. DECLARE_API(cdromext)
  34. /*++
  35. Routine Description:
  36. Dumps the cdrom specific data for a given device object or
  37. given device extension
  38. Arguments:
  39. args - string containing the address of the device object or device
  40. extension
  41. Return Value:
  42. none
  43. --*/
  44. {
  45. ULONG64 address;
  46. ULONG result;
  47. ULONG detail = 0;
  48. ULONG length;
  49. BOOLEAN IsFdo;
  50. ULONG64 DriverData;
  51. ASSERTMSG("data block too small to hold CDROM_DATA\n",
  52. sizeof(FUNCTIONAL_DEVICE_EXTENSION) > sizeof(CDROM_DATA));
  53. ASSERTMSG("data block too small to hold DEVICE_OBJECT\n",
  54. sizeof(FUNCTIONAL_DEVICE_EXTENSION) > sizeof(DEVICE_OBJECT));
  55. GetAddressAndDetailLevel64(args, &address, &detail);
  56. //
  57. // Convert the supplied address into a device extension if it is
  58. // the address of a device object.
  59. //
  60. address = GetDeviceExtension(address);
  61. //
  62. // Get the IsFdo flag which we use to determine how many bytes
  63. // to actually read.
  64. //
  65. result = GetFieldData(address,
  66. "cdrom!COMMON_DEVICE_EXTENSION",
  67. "IsFdo",
  68. sizeof(BOOLEAN),
  69. &IsFdo);
  70. if (result) {
  71. SCSIKD_PRINT_ERROR(result);
  72. return E_FAIL;
  73. }
  74. if(!IsFdo) {
  75. xdprintfEx(0, ("Not an FDO\n"));
  76. return E_FAIL;
  77. }
  78. //
  79. // Dump the class-specific information
  80. //
  81. if (detail != 0) {
  82. ClassDumpCommonExtension(address,
  83. detail,
  84. 0);
  85. }
  86. //
  87. // Now grab the pointer to our driver-specific data.
  88. //
  89. result = GetFieldData(address,
  90. "cdrom!_COMMON_DEVICE_EXTENSION",
  91. "DriverData",
  92. sizeof(ULONG64),
  93. &DriverData);
  94. if (result) {
  95. SCSIKD_PRINT_ERROR(result);
  96. return E_FAIL;
  97. }
  98. //
  99. // And dump the driver-specific data.
  100. //
  101. ClassDumpCdromData(DriverData,
  102. detail,
  103. 0);
  104. return S_OK;
  105. }
  106. VOID
  107. ClassDumpCdromData(
  108. IN ULONG64 Address,
  109. IN ULONG Detail,
  110. IN ULONG Depth
  111. )
  112. {
  113. ULONG result;
  114. ULONG offset;
  115. ULONG CdDataXAFlags;
  116. BOOLEAN PlayActive;
  117. BOOLEAN RawAccess;
  118. BOOLEAN IsDecRrd;
  119. ULONG64 DelayedRetrySpinLock;
  120. ULONG64 DelayedRetryIrp;
  121. BOOLEAN DelayedRetryResend;
  122. ULONG DelayedRetryInterval;
  123. ULONG PickDvdRegion;
  124. BOOLEAN DvdRpc0Device;
  125. UCHAR Rpc0SystemRegion;
  126. UCHAR Rpc0SystemRegionResetCount;
  127. FIELD_INFO deviceFields[] = {
  128. {"XAFlags", NULL, 0, COPY, 0, (PVOID) &CdDataXAFlags},
  129. {"PlayActive", NULL, 0, COPY, 0, (PVOID) &PlayActive},
  130. {"RawAccess", NULL, 0, COPY, 0, (PVOID) &RawAccess},
  131. {"IsDecRrd", NULL, 0, COPY, 0, (PVOID) &IsDecRrd},
  132. {"DelayedRetrySpinLock", NULL, 0, COPY, 0, (PVOID) &DelayedRetrySpinLock},
  133. {"DelayedRetryIrp", NULL, 0, COPY, 0, (PVOID) &DelayedRetryIrp},
  134. {"DelayedRetryResend", NULL, 0, COPY, 0, (PVOID) &DelayedRetryIrp},
  135. {"DelayedRetryResend", NULL, 0, COPY, 0, (PVOID) &DelayedRetryResend},
  136. {"DelayedRetryInterval", NULL, 0, COPY, 0, (PVOID) &DelayedRetryInterval},
  137. {"PickDvdRegion", NULL, 0, COPY, 0, (PVOID) &PickDvdRegion},
  138. {"DvdRpc0Device", NULL, 0, COPY, 0, (PVOID) &DvdRpc0Device},
  139. {"Rpc0SystemRegion", NULL, 0, COPY, 0, (PVOID) &Rpc0SystemRegion},
  140. {"Rpc0SystemRegionResetCount", NULL, 0, COPY, 0, (PVOID) &Rpc0SystemRegionResetCount},
  141. };
  142. SYM_DUMP_PARAM DevSym = {
  143. sizeof (SYM_DUMP_PARAM),
  144. "cdrom!_CDROM_DATA",
  145. DBG_DUMP_NO_PRINT,
  146. Address,
  147. NULL, NULL, NULL,
  148. sizeof (deviceFields) / sizeof (FIELD_INFO),
  149. &deviceFields[0]
  150. };
  151. result = Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size);
  152. if (result) {
  153. SCSIKD_PRINT_ERROR(result);
  154. return;
  155. }
  156. xdprintfEx(Depth, ("CdData @ %p:\n", Address));
  157. Depth +=1;
  158. DumpFlags(Depth, "XAFlags", CdDataXAFlags, XAFlags);
  159. if (TEST_FLAG(CdDataXAFlags,XA_USE_6_BYTE)) {
  160. result = GetFieldOffset("cdrom!CDROM_DATA",
  161. "Header",
  162. &offset);
  163. if (result) {
  164. SCSIKD_PRINT_ERROR(result);
  165. return;
  166. }
  167. xdprintfEx(Depth, ("%s-byte mode switching, buffer @ %p\n", "6",
  168. Address + offset));
  169. } else if (TEST_FLAG(CdDataXAFlags,XA_USE_10_BYTE)) {
  170. result = GetFieldOffset("cdrom!CDROM_DATA",
  171. "Header10",
  172. &offset);
  173. if (result) {
  174. SCSIKD_PRINT_ERROR(result);
  175. return;
  176. }
  177. xdprintfEx(Depth, ("%s-byte mode switching, buffer @ %p\n", "10",
  178. Address + offset));
  179. }
  180. { // sanity check the XA flags
  181. ULONG readBits = 0;
  182. if (TEST_FLAG(CdDataXAFlags,XA_USE_6_BYTE)) readBits++;
  183. if (TEST_FLAG(CdDataXAFlags,XA_USE_10_BYTE)) readBits++;
  184. if (TEST_FLAG(CdDataXAFlags,XA_USE_READ_CD)) readBits++;
  185. if (TEST_FLAG(CdDataXAFlags,XA_NOT_SUPPORTED)) readBits++;
  186. if (readBits > 1) {
  187. xdprintfEx(Depth, ("INVALID combination of XAFlags\n"));
  188. }
  189. }
  190. xdprintfEx(Depth, ("PlayActive: %x RawAccess %x IsDecRrd: %x\n",
  191. (PlayActive ? 1 : 0),
  192. (RawAccess ? 1 : 0),
  193. (IsDecRrd ? 1 : 0)));
  194. if (DelayedRetrySpinLock) {
  195. xdprintfEx(Depth, ("RetryIrp data in intermediate state\n"));
  196. } else if (DelayedRetryIrp) {
  197. xdprintfEx(Depth, ("RetryIrp @ %p will be sent to %s in %x seconds\n",
  198. DelayedRetryIrp,
  199. (DelayedRetryResend ? "lower driver" : "startio"),
  200. DelayedRetryInterval));
  201. } else {
  202. xdprintfEx(Depth, ("No RetryIrp currently waiting\n"));
  203. }
  204. if (PickDvdRegion) {
  205. xdprintfEx(Depth, ("DVD Region has not been selected or unneeded yet.\n"));
  206. } else {
  207. xdprintfEx(Depth, ("DVD Region already chosen.\n"));
  208. }
  209. if (DvdRpc0Device) {
  210. xdprintfEx(Depth, ("DVD Info is faked due to Rpc0 device):\n"));
  211. xdprintfEx(Depth+1, ("Region: %x (%x) Region Reset Count: %x\n",
  212. (UCHAR)(Rpc0SystemRegion),
  213. (UCHAR)(~Rpc0SystemRegion),
  214. Rpc0SystemRegionResetCount));
  215. result = GetFieldOffset("cdrom!CDROM_DATA",
  216. "Rpc0RegionMutex",
  217. &offset);
  218. if (result) {
  219. SCSIKD_PRINT_ERROR(result);
  220. return;
  221. }
  222. xdprintfEx(Depth+1, ("Mutex at %p\n",
  223. Address + offset));
  224. } else {
  225. xdprintfEx(Depth, ("Not an RPC0 DVD device\n"));
  226. }
  227. return;
  228. }