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.

489 lines
14 KiB

  1. /*++
  2. Copyright (c) 1997-1998 Microsoft Corporation
  3. Module Name:
  4. isapnp.c
  5. Abstract:
  6. WinDbg Extension Api for ISAPNP
  7. Author:
  8. Robert Nelson 4/99
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. #define FLAG_NAME(flag) {flag, #flag}
  16. FLAG_NAME IsapnpExtensionFlags[] = {
  17. FLAG_NAME(DF_DELETED), // 00000001
  18. FLAG_NAME(DF_REMOVED), // 00000002
  19. FLAG_NAME(DF_NOT_FUNCTIONING), // 00000004
  20. FLAG_NAME(DF_ENUMERATED), // 00000008
  21. FLAG_NAME(DF_ACTIVATED), // 00000010
  22. FLAG_NAME(DF_QUERY_STOPPED), // 00000020
  23. FLAG_NAME(DF_SURPRISE_REMOVED), // 00000040
  24. FLAG_NAME(DF_PROCESSING_RDP), // 00000080
  25. FLAG_NAME(DF_STOPPED), // 00000100
  26. FLAG_NAME(DF_RESTARTED_MOVED), // 00000200
  27. FLAG_NAME(DF_RESTARTED_NOMOVE), // 00000400
  28. FLAG_NAME(DF_REQ_TRIMMED), // 00000800
  29. FLAG_NAME(DF_READ_DATA_PORT), // 40000000
  30. FLAG_NAME(DF_BUS), // 80000000
  31. {0,0}
  32. };
  33. PUCHAR DevExtIsapnpSystemPowerState[] = {
  34. "Unspecified",
  35. "Working",
  36. "Sleeping1",
  37. "Sleeping2",
  38. "Sleeping3",
  39. "Hibernate",
  40. "Shutdown"
  41. };
  42. PUCHAR DevExtIsapnpDevicePowerState[] = {
  43. "Unspecified",
  44. "D0",
  45. "D1",
  46. "D2",
  47. "D3"
  48. };
  49. PUCHAR IsapnpStates[] = {
  50. "Unknown",
  51. "WaitForKey",
  52. "Sleep",
  53. "Isolation",
  54. "Config"
  55. };
  56. extern
  57. VOID
  58. DevExtIsapnp(
  59. ULONG64 Extension
  60. );
  61. BOOL
  62. DumpIsaBusInfo(
  63. ULONG Depth,
  64. ULONG64 BusInformation,
  65. BOOL Verbose,
  66. BOOL DumpCards,
  67. BOOL DumpDevices
  68. );
  69. BOOL
  70. DumpIsaCardInfo(
  71. ULONG Depth,
  72. ULONG64 CardInformation,
  73. BOOL Verbose,
  74. BOOL DumpCards,
  75. BOOL DumpDevices
  76. );
  77. BOOL
  78. DumpIsaDeviceInfo(
  79. ULONG Depth,
  80. ULONG64 DeviceInformation,
  81. BOOL Verbose,
  82. BOOL DumpDevices
  83. );
  84. VOID
  85. DevExtIsapnp(
  86. ULONG64 Extension
  87. )
  88. /*++
  89. Routine Description:
  90. Dump an ISAPNP Device extension.
  91. Arguments:
  92. Extension Address of the extension to be dumped.
  93. Return Value:
  94. None.
  95. --*/
  96. {
  97. ULONG flags, result;
  98. if (!ReadMemory(Extension, &flags, sizeof(flags), &result) ) {
  99. dprintf("Could not read Device Extension flags at 0x%08p\n", Extension);
  100. return;
  101. }
  102. if (flags & DF_BUS) {
  103. DumpIsaBusInfo( 0, Extension, TRUE, FALSE, FALSE );
  104. } else {
  105. DumpIsaDeviceInfo( 0, Extension, TRUE, FALSE );
  106. }
  107. }
  108. DECLARE_API( isainfo )
  109. /*++
  110. Routine Description:
  111. Dumps a CARD_INFORMATION structure.
  112. Arguments:
  113. args Address of the CARD_INFORMATION structure
  114. Return Value:
  115. None.
  116. --*/
  117. {
  118. ULONG64 cardInfo = 0;
  119. ULONG64 addr, entry;
  120. BOOL continueDump = TRUE;
  121. ULONG flags = 0;
  122. if (GetExpressionEx(args, &cardInfo, &args)) {
  123. flags = (ULONG) GetExpression(args);
  124. }
  125. if (cardInfo == 0) {
  126. addr = GetExpression("isapnp!PipBusExtension");
  127. if (addr == 0) {
  128. dprintf("Error retrieving address of PipBusExtension\n");
  129. return E_INVALIDARG;
  130. }
  131. if (!ReadPointer(addr, &entry) ) {
  132. dprintf("Could not read PipBusExtension at 0x%08p\n", addr);
  133. return E_INVALIDARG;
  134. }
  135. while (continueDump && entry != 0) {
  136. if (CheckControlC()) {
  137. continueDump = FALSE;
  138. break;
  139. }
  140. if (InitTypeRead(entry, isapnp!_BUS_EXTENSION_LIST) ) {
  141. dprintf("Could not read isapnp!_BUS_EXTENSION_LIST at 0x%08p\n", entry);
  142. return E_INVALIDARG;
  143. }
  144. entry = ReadField(Next);
  145. continueDump = DumpIsaBusInfo( 0,
  146. ReadField(BusExtension),
  147. flags & 1,
  148. TRUE,
  149. TRUE);
  150. }
  151. } else {
  152. DumpIsaCardInfo(0, cardInfo, TRUE, FALSE, FALSE);
  153. }
  154. return S_OK;
  155. } // isainfo
  156. BOOL
  157. DumpIsaBusInfo(
  158. ULONG Depth,
  159. ULONG64 BusInformation,
  160. BOOL Verbose,
  161. BOOL DumpCards,
  162. BOOL DumpDevices
  163. )
  164. {
  165. ULONG64 cardInformation;
  166. ULONG64 addr;
  167. ULONG64 PipRDPNode;
  168. ULONG Off;
  169. ULONG state;
  170. BOOL continueDump = TRUE;
  171. ULONG64 CardNext;
  172. //
  173. // device extension for ISAPNP FDO
  174. //
  175. if (CheckControlC()) {
  176. return FALSE;
  177. }
  178. if (InitTypeRead(BusInformation, isapnp!_PI_BUS_EXTENSION)) {
  179. dprintf("Could not read Card Information at 0x%08p\n", BusInformation);
  180. return FALSE;
  181. }
  182. xdprintf(Depth,"");
  183. dprintf(
  184. "ISA PnP FDO @ 0x%08p, DevExt @ 0x%08p, Bus # %d\n",
  185. ReadField(FunctionalBusDevice),
  186. BusInformation,
  187. (ULONG) ReadField(BusNumber));
  188. DumpFlags( Depth, "Flags", (ULONG) ReadField(Flags), IsapnpExtensionFlags);
  189. dprintf("\n");
  190. if (Verbose) {
  191. addr = GetExpression("isapnp!PipState");
  192. if (addr != 0) {
  193. if (state = GetUlongFromAddress(addr)) {// , "PNPISA_STATE", NULL, state)) {
  194. xdprintf(
  195. Depth,
  196. "State - %s\n",
  197. IsapnpStates[state]);
  198. }
  199. }
  200. xdprintf(Depth,"");
  201. dprintf( "NumberCSNs - %d\n", (ULONG) ReadField(NumberCSNs));
  202. xdprintf(Depth,"");
  203. dprintf(
  204. "ReadDataPort - 0x%08p (%smapped)\n",
  205. ReadField(ReadDataPort),
  206. ReadField(DataPortMapped) ? "" : "not ");
  207. xdprintf(Depth,"");
  208. dprintf(
  209. "AddressPort - 0x%08p (%smapped)\n",
  210. ReadField(AddressPort),
  211. ReadField(AddrPortMapped) ? "" : "not ");
  212. xdprintf(Depth,"");
  213. dprintf(
  214. "CommandPort - 0x%08p (%smapped)\n",
  215. ReadField(CommandPort),
  216. ReadField(CmdPortMapped) ? "" : "not ");
  217. xdprintf(Depth,"");dprintf( "DeviceList - 0x%08p\n", ReadField(DeviceList));
  218. xdprintf(Depth,"");dprintf( "CardList - 0x%08p\n", ReadField(CardList));
  219. xdprintf(Depth,"");dprintf( "PhysicalBusDevice - 0x%08p\n", ReadField(PhysicalBusDevice));
  220. xdprintf(Depth,"");dprintf( "AttachedDevice - 0x%08p\n", ReadField(AttachedDevice));
  221. xdprintf(Depth,"");dprintf( "SystemPowerState - %s\n",
  222. DevExtIsapnpSystemPowerState[(ULONG) ReadField(SystemPowerState)]);
  223. xdprintf(Depth,"");dprintf( "DevicePowerState - %s\n\n",
  224. DevExtIsapnpDevicePowerState[(ULONG) ReadField(DevicePowerState)]);
  225. }
  226. CardNext = ReadField(CardList.Next);
  227. if (DumpDevices && ReadField(BusNumber) == 0) {
  228. addr = GetExpression("isapnp!PipRDPNode");
  229. if (addr != 0) {
  230. if (!ReadPointer(addr, &PipRDPNode)) {
  231. dprintf("Could not read PipRDPNode at 0x%08p\n", addr);
  232. return FALSE;
  233. }
  234. continueDump = DumpIsaDeviceInfo( Depth + 1, PipRDPNode, Verbose, DumpDevices );
  235. } else {
  236. dprintf("Error retrieving address of PipBusExtension\n");
  237. }
  238. }
  239. GetFieldOffset("isapnp!_CARD_INFORMATION_", "CardList", &Off);
  240. if (DumpCards && CardNext != 0) {
  241. cardInformation = CardNext - Off;
  242. continueDump = DumpIsaCardInfo( Depth + 1, cardInformation, Verbose, DumpCards, DumpDevices );
  243. }
  244. return continueDump;
  245. }
  246. BOOL
  247. DumpIsaCardInfo(
  248. ULONG Depth,
  249. ULONG64 CardInformation,
  250. BOOL Verbose,
  251. BOOL DumpCards,
  252. BOOL DumpDevices
  253. )
  254. {
  255. ULONG64 deviceInformation;
  256. UCHAR idString[8], *compressedID;
  257. BOOL continueDump = TRUE;
  258. ULONG VenderId;
  259. ULONG DevOff, CardOff;
  260. static UCHAR HexDigits[16] = "0123456789ABCDEF";
  261. GetFieldOffset("isapnp!_DEVICE_INFORMATION_", "LogicalDeviceList", &DevOff);
  262. GetFieldOffset("isapnp!_CARD_INFORMATION_", "CardList", &CardOff);
  263. do {
  264. ULONG64 CardData, CardNext, LogNext, CardList;
  265. if (CheckControlC()) {
  266. continueDump = FALSE;
  267. break;
  268. }
  269. if (InitTypeRead(CardInformation, _CARD_INFORMATION_) ) {
  270. dprintf("Could not read Card Information at 0x%08p\n", CardInformation);
  271. return FALSE;
  272. }
  273. CardData = ReadField(CardData);
  274. xdprintf(Depth,"");
  275. dprintf("ISA PnP Card Information @ 0x%08p, CSN = %d, ID ", CardInformation, (ULONG) ReadField(CardSelectNumber));
  276. if (ReadField(CardDataLength) >= GetTypeSize("isapnp!_SERIAL_IDENTIFIER_")) {
  277. ULONG SerialNumber;
  278. if (GetFieldValue(CardData, "_SERIAL_IDENTIFIER_", "VenderId", VenderId) ) {
  279. dprintf("\nCould not read CardData at 0x%08p\n", CardData);
  280. return FALSE;
  281. }
  282. compressedID = (PUCHAR)&VenderId;
  283. idString[0] = (compressedID[0] >> 2) + 0x40;
  284. idString[1] = (((compressedID[0] & 0x03) << 3) | (compressedID[1] >> 5)) + 0x40;
  285. idString[2] = (compressedID[1] & 0x1f) + 0x40;
  286. idString[3] = HexDigits[compressedID[2] >> 4];
  287. idString[4] = HexDigits[compressedID[2] & 0x0F];
  288. idString[5] = HexDigits[compressedID[3] >> 4];
  289. idString[6] = HexDigits[compressedID[3] & 0x0F];
  290. idString[7] = 0x00;
  291. if (GetFieldValue(CardData, "_SERIAL_IDENTIFIER_", "SerialNumber",SerialNumber)) {
  292. dprintf("\nCould not read CardData at 0x%08p\n", CardData);
  293. return FALSE;
  294. }
  295. dprintf("= %s\\%X\n\n", idString, SerialNumber);
  296. } else {
  297. dprintf("isn't present\n\n");
  298. }
  299. if (Verbose) {
  300. xdprintf(Depth,""); dprintf( "Next Card (CardList) - %08p\n", CardData);
  301. xdprintf(Depth,""); dprintf( "NumberLogicalDevices - %d\n", (ULONG) ReadField(NumberLogicalDevices));
  302. xdprintf(Depth,""); dprintf( "LogicalDeviceList - 0x%08p\n", ReadField(LogicalDeviceList));
  303. xdprintf(Depth,""); dprintf( "CardData - 0x%08p\n", ReadField(CardData));
  304. xdprintf(Depth,"CardDataLength - %d\n", (ULONG) ReadField(CardDataLength));
  305. xdprintf(Depth,""); dprintf( "CardFlags - 0x%08p\n\n", ReadField(CardFlags));
  306. }
  307. CardNext = ReadField(CardList.Next);
  308. LogNext = ReadField(LogicalDeviceList.Next);
  309. if (DumpDevices && LogNext != 0) {
  310. deviceInformation = LogNext - DevOff;
  311. continueDump = DumpIsaDeviceInfo( Depth + 1, deviceInformation, Verbose, DumpDevices );
  312. }
  313. if (CardNext != 0) {
  314. CardInformation = CardNext - CardOff;
  315. } else {
  316. break;
  317. }
  318. } while (DumpCards);
  319. return continueDump;
  320. }
  321. BOOL
  322. DumpIsaDeviceInfo(
  323. ULONG Depth,
  324. ULONG64 DeviceInformation,
  325. BOOL Verbose,
  326. BOOL DumpDevices
  327. )
  328. {
  329. //
  330. // device extension for ISAPNP PDO
  331. //
  332. BOOL continueDump = TRUE;
  333. ULONG DevOff;
  334. ULONG64 Next;
  335. GetFieldOffset("isapnp!_DEVICE_INFORMATION_", "LogicalDeviceList", &DevOff);
  336. do {
  337. if (CheckControlC()) {
  338. continueDump = FALSE;
  339. break;
  340. }
  341. if (Next = InitTypeRead(DeviceInformation, _DEVICE_INFORMATION_)) {
  342. dprintf("Could not read Device Information at 0x%08p - %I64x\n", DeviceInformation, Next);
  343. return FALSE;
  344. }
  345. xdprintf(Depth,""); dprintf(
  346. "ISA PnP PDO @ 0x%08P, DevExt @ 0x%08P\n",
  347. ReadField(PhysicalDeviceObject),
  348. DeviceInformation);
  349. DumpFlags( Depth, "Flags", (ULONG) ReadField(Flags), IsapnpExtensionFlags);
  350. dprintf("\n");
  351. if (Verbose) {
  352. //xdprintf(Depth,""); dprintf( "SystemPowerState - %s\n", DevExtIsapnpSystemPowerState[(ULONG) ReadField(SystemPowerState]));
  353. xdprintf(Depth,""); dprintf( "DevicePowerState - %s\n", DevExtIsapnpDevicePowerState[(ULONG) ReadField(DevicePowerState)]);
  354. xdprintf(Depth,""); dprintf( "ParentDevExt - 0x%08P\n", ReadField(ParentDeviceExtension));
  355. xdprintf(Depth,""); dprintf( "DeviceList - 0x%08P\n", ReadField(DeviceList));
  356. xdprintf(Depth,""); dprintf( "EnumerationMutex - %sLocked\n", ReadField(EnumerationMutex.Header.SignalState) ? "Not " : "");
  357. xdprintf(Depth,""); dprintf( "ResourceRequirements - 0x%08P\n", ReadField(ResourceRequirements));
  358. xdprintf(Depth,""); dprintf( "CardInformation - 0x%08P\n", ReadField(CardInformation));
  359. xdprintf(Depth,""); dprintf( "LogicalDeviceList - 0x%08P\n", ReadField(LogicalDeviceList));
  360. xdprintf(Depth,""); dprintf( "LogicalDeviceNumber - %d\n", (ULONG) ReadField(LogicalDeviceNumber));
  361. xdprintf(Depth,""); dprintf( "DeviceData - 0x%08P\n", ReadField(DeviceData));
  362. xdprintf(Depth,""); dprintf( "DeviceDataLength - 0x%08P\n", ReadField(DeviceDataLength));
  363. xdprintf(Depth,""); dprintf( "BootResourceList - 0x%08P\n", ReadField(BootResources));
  364. xdprintf(Depth,""); dprintf( "BootResourceLength - 0x%08P\n", ReadField(BootResourcesLength));
  365. xdprintf(Depth,""); dprintf( "AllocatedResList - 0x%08P\n", ReadField(AllocatedResources));
  366. xdprintf(Depth,""); dprintf( "LogConfHandle - 0x%08P\n", ReadField(LogConfHandle));
  367. xdprintf(Depth,""); dprintf( "Paging/Crash Path - %d/%d\n\n", (ULONG) ReadField(Paging),
  368. (ULONG) ReadField(CrashDump));
  369. }
  370. Next = ReadField(LogicalDeviceList.Next);
  371. if (Next != 0) {
  372. DeviceInformation = Next - DevOff;
  373. } else {
  374. break;
  375. }
  376. } while (DumpDevices);
  377. return continueDump;
  378. }