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.

1167 lines
32 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. pcmcia.c
  5. Abstract:
  6. WinDbg Extension Api to dump PCMCIA driver structures.
  7. This module references some routines & types defined
  8. in devnode.c
  9. Author:
  10. Ravisankar Pudipeddi (ravisp) 1-Dec-1997
  11. Neil Sandlin (neilsa) 1-June-1999
  12. Environment:
  13. User Mode.
  14. --*/
  15. #include "precomp.h"
  16. #pragma hdrstop
  17. #define FLAG_NAME(flag) {flag, #flag}
  18. //
  19. // Table of PCMCIA device extension flags
  20. // update them from pcmcia.h
  21. //
  22. FLAG_NAME PcmciaDeviceFlags[] = {
  23. FLAG_NAME(PCMCIA_DEVICE_STARTED),
  24. FLAG_NAME(PCMCIA_DEVICE_LOGICALLY_REMOVED),
  25. FLAG_NAME(PCMCIA_DEVICE_PHYSICALLY_REMOVED),
  26. FLAG_NAME(PCMCIA_DEVICE_MULTIFUNCTION),
  27. FLAG_NAME(PCMCIA_DEVICE_WAKE_PENDING),
  28. FLAG_NAME(PCMCIA_DEVICE_LEGACY_DETECTED),
  29. FLAG_NAME(PCMCIA_DEVICE_DELETED),
  30. FLAG_NAME(PCMCIA_DEVICE_CARDBUS),
  31. FLAG_NAME(PCMCIA_FILTER_ADDED_MEMORY),
  32. FLAG_NAME(PCMCIA_MEMORY_24BIT),
  33. FLAG_NAME(PCMCIA_CARDBUS_NOT_SUPPORTED),
  34. FLAG_NAME(PCMCIA_USE_POLLED_CSC),
  35. FLAG_NAME(PCMCIA_ATTRIBUTE_MEMORY_MAPPED),
  36. FLAG_NAME(PCMCIA_SOCKET_REGISTER_BASE_MAPPED),
  37. FLAG_NAME(PCMCIA_INTMODE_COMPAQ),
  38. FLAG_NAME(PCMCIA_POWER_WORKER_POWERUP),
  39. FLAG_NAME(PCMCIA_SOCKET_POWER_REQUESTED),
  40. FLAG_NAME(PCMCIA_CONFIG_STATUS_DEFERRED),
  41. FLAG_NAME(PCMCIA_POWER_STATUS_DEFERRED),
  42. FLAG_NAME(PCMCIA_INT_ROUTE_INTERFACE),
  43. {0,0}
  44. };
  45. //
  46. // Table of PCMCIA socket structure flags
  47. // update them from pcmcia.h
  48. //
  49. FLAG_NAME PcmciaSocketFlags[] = {
  50. FLAG_NAME(SOCKET_CARD_IN_SOCKET),
  51. FLAG_NAME(SOCKET_CARD_INITIALIZED),
  52. FLAG_NAME(SOCKET_CARD_POWERED_UP),
  53. FLAG_NAME(SOCKET_CARD_CONFIGURED),
  54. FLAG_NAME(SOCKET_CARD_MULTIFUNCTION),
  55. FLAG_NAME(SOCKET_CARD_CARDBUS),
  56. FLAG_NAME(SOCKET_CARD_MEMORY),
  57. FLAG_NAME(SOCKET_CHANGE_INTERRUPT),
  58. FLAG_NAME(SOCKET_CUSTOM_INTERFACE),
  59. FLAG_NAME(SOCKET_INSERTED_SOUND_PENDING),
  60. FLAG_NAME(SOCKET_REMOVED_SOUND_PENDING),
  61. FLAG_NAME(SOCKET_SUPPORT_MESSAGE_SENT),
  62. FLAG_NAME(SOCKET_MEMORY_WINDOW_ENABLED),
  63. FLAG_NAME(SOCKET_CARD_STATUS_CHANGE),
  64. FLAG_NAME(SOCKET_POWER_STATUS_DEFERRED),
  65. {0,0}
  66. };
  67. ENUM_NAME PcmciaControllerTypeEnum[] = {
  68. ENUM_NAME(PcmciaIntelCompatible),
  69. ENUM_NAME(PcmciaCardBusCompatible),
  70. ENUM_NAME(PcmciaElcController),
  71. ENUM_NAME(PcmciaDatabook),
  72. ENUM_NAME(PcmciaPciPcmciaBridge),
  73. ENUM_NAME(PcmciaCirrusLogic),
  74. ENUM_NAME(PcmciaTI),
  75. ENUM_NAME(PcmciaTopic),
  76. ENUM_NAME(PcmciaRicoh),
  77. ENUM_NAME(PcmciaDatabookCB),
  78. ENUM_NAME(PcmciaOpti),
  79. ENUM_NAME(PcmciaTrid),
  80. ENUM_NAME(PcmciaO2Micro),
  81. ENUM_NAME(PcmciaNEC),
  82. ENUM_NAME(PcmciaNEC_98),
  83. ENUM_NAME(PcmciaInvalidControllerType),
  84. {0,0}
  85. };
  86. ENUM_NAME PcmciaSocketPowerWorkerStates[] = {
  87. ENUM_NAME(SPW_Stopped),
  88. ENUM_NAME(SPW_Exit),
  89. ENUM_NAME(SPW_RequestPower),
  90. ENUM_NAME(SPW_ReleasePower),
  91. ENUM_NAME(SPW_SetPowerOn),
  92. ENUM_NAME(SPW_SetPowerOff),
  93. ENUM_NAME(SPW_ParentPowerUp),
  94. ENUM_NAME(SPW_ParentPowerUpComplete),
  95. {0,0}
  96. };
  97. ENUM_NAME PcmciaPdoPowerWorkerStates[] = {
  98. ENUM_NAME(PPW_Stopped),
  99. ENUM_NAME(PPW_Exit),
  100. ENUM_NAME(PPW_InitialState),
  101. ENUM_NAME(PPW_PowerUp),
  102. ENUM_NAME(PPW_PowerUpComplete),
  103. ENUM_NAME(PPW_PowerDown),
  104. ENUM_NAME(PPW_PowerDownComplete),
  105. ENUM_NAME(PPW_SendIrpDown),
  106. ENUM_NAME(PPW_16BitConfigure),
  107. ENUM_NAME(PPW_Deconfigure),
  108. ENUM_NAME(PPW_VerifyCard),
  109. ENUM_NAME(PPW_CardBusRefresh),
  110. ENUM_NAME(PPW_CardBusDelay),
  111. {0,0}
  112. };
  113. PUCHAR DeviceTypeTable[] = {
  114. "Multifunction",
  115. "Memory card",
  116. "Serial",
  117. "Parallel",
  118. "ATA",
  119. "Video",
  120. "Network controller",
  121. "AIMS",
  122. "Scsi controller",
  123. "Modem"
  124. };
  125. VOID
  126. DumpEnum(
  127. ULONG EnumVal,
  128. PENUM_NAME EnumTable
  129. )
  130. /*++
  131. Routine Description:
  132. Prints the supplied enum value in a readable string format
  133. by looking it up in the supplied enum table
  134. Arguments:
  135. EnumVal - Enum to be printed
  136. EnumTable - Table in which the enum is looked up to find
  137. the string to be printed
  138. Return Value:
  139. None
  140. --*/
  141. {
  142. ULONG i;
  143. for (i=0; EnumTable[i].Name != NULL; i++) {
  144. if (EnumTable[i].EnumVal == EnumVal) {
  145. break;
  146. }
  147. }
  148. if (EnumTable[i].Name != NULL) {
  149. dprintf("%s", EnumTable[i].Name);
  150. } else {
  151. dprintf("Unknown ");
  152. }
  153. return;
  154. }
  155. ULONG64
  156. SocFld (ULONG64 Addr, PUCHAR Field) {
  157. ULONG64 Temp;
  158. GetFieldValue(Addr, "pcmcia!SOCKET", Field, Temp);
  159. return Temp;
  160. }
  161. VOID
  162. DumpSocket(ULONG64 Socket, ULONG Depth)
  163. /*++
  164. Routine Description
  165. Dumps the socket structure
  166. Arguments
  167. Socket - Pointer to the socket structure
  168. Depth - Indentation at which to print
  169. Return Value
  170. None
  171. --*/
  172. {
  173. ULONG64 tmp;
  174. dprintf("\n");
  175. xdprintf(Depth,""); dprintf("NextSocket 0x%p\n", SocFld(Socket, "NextSocket"));
  176. xdprintf(Depth,""); dprintf("SocketFnPtr 0x%p\n", SocFld(Socket, "SocketFnPtr"));
  177. xdprintf(Depth,""); dprintf("Fdo devext 0x%p\n", SocFld(Socket, "DeviceExtension"));
  178. xdprintf(Depth,""); dprintf("PdoList 0x%p\n", SocFld(Socket, "PdoList"));
  179. DumpFlags(Depth, "Socket Flags", (ULONG) SocFld(Socket, "Flags"), PcmciaSocketFlags);
  180. xdprintf(Depth,"Revision 0x%x\n", (ULONG) SocFld(Socket, "Revision"));
  181. xdprintf(Depth,"SocketNumber 0x%x\n", (ULONG) SocFld(Socket, "SocketNumber"));
  182. xdprintf(Depth,"NumberOfFunctions %d\n", (ULONG) SocFld(Socket, "NumberOfFunctions"));
  183. xdprintf(Depth,"AddressPort 0x%x\n", (ULONG) SocFld(Socket, "AddressPort"));
  184. xdprintf(Depth,"RegisterOffset 0x%x\n", (ULONG) SocFld(Socket, "RegisterOffset"));
  185. xdprintf(Depth,"CBReg Base 0x%I64x size 0x%x\n",
  186. SocFld(Socket, "CardBusSocketRegisterBase"),
  187. SocFld(Socket, "CardBusSocketRegisterSize"));
  188. xdprintf(Depth,"CisCache 0x%x\n", (ULONG) SocFld(Socket, "CisCache"));
  189. if (tmp = SocFld(Socket, "PciDeviceRelations")) {
  190. xdprintf(Depth,"PciDeviceRelations 0x%p\n", tmp);
  191. }
  192. xdprintf(Depth,"PowerRequests %d\n", (ULONG) SocFld(Socket, "PowerRequests"));
  193. xdprintf(Depth,"PowerWorker State: ");
  194. DumpEnum((ULONG) SocFld(Socket, "WorkerState"), PcmciaSocketPowerWorkerStates);
  195. dprintf("\n");
  196. if (SocFld(Socket, "WorkerState") != SPW_Stopped) {
  197. xdprintf(Depth," Worker Phase %d\n", (ULONG) SocFld(Socket, "WorkerPhase"));
  198. xdprintf(Depth," PowerData 0x%x\n", (ULONG) SocFld(Socket, "PowerData"));
  199. xdprintf(Depth,""); dprintf(" PowerCompletionRoutine 0x%p\n", SocFld(Socket, "PowerCompletionRoutine"));
  200. xdprintf(Depth,""); dprintf(" PowerCompletionContext 0x%p\n", SocFld(Socket, "PowerCompletionContext"));
  201. xdprintf(Depth," CallerStatus 0x%x\n", (ULONG) SocFld(Socket, "CallerStatus"));
  202. xdprintf(Depth," DeferredStatus 0x%x\n", (ULONG) SocFld(Socket, "DeferredStatus"));
  203. xdprintf(Depth," DeferredPowerRequests 0x%x\n", (ULONG) SocFld(Socket, "DeferredPowerRequests"));
  204. }
  205. dprintf("\n");
  206. return;
  207. }
  208. VOID
  209. DumpDevicePowerState(IN DEVICE_POWER_STATE PowerState)
  210. /*++
  211. Routine Description
  212. Converts the supplied enum device power state to a
  213. string & dumps it.
  214. Arguments
  215. PowerState - Device power state
  216. Return Value
  217. None
  218. --*/
  219. {
  220. dprintf(" DevicePowerState: ");
  221. switch (PowerState) {
  222. case PowerDeviceUnspecified: {
  223. dprintf("PowerDeviceUnspecfied\n");
  224. break;
  225. }
  226. case PowerDeviceD0: {
  227. dprintf("PowerDeviceD0\n");
  228. break;
  229. }
  230. case PowerDeviceD1: {
  231. dprintf("PowerDeviceD1\n");
  232. break;
  233. }
  234. case PowerDeviceD2: {
  235. dprintf("PowerDeviceD2\n");
  236. break;
  237. }
  238. case PowerDeviceD3: {
  239. dprintf("PowerDeviceD3\n");
  240. break;
  241. }
  242. default:
  243. dprintf("???\n");
  244. }
  245. }
  246. VOID
  247. DumpSystemPowerState(IN SYSTEM_POWER_STATE PowerState)
  248. /*++
  249. Routine Description
  250. Converts the supplied enum system power state to a
  251. string & dumps it.
  252. Arguments
  253. PowerState - System power state
  254. Return Value
  255. None
  256. --*/
  257. {
  258. dprintf(" SystemPowerState: ");
  259. switch (PowerState) {
  260. case PowerSystemUnspecified: {
  261. dprintf("PowerSystemUnspecfied\n");
  262. break;
  263. }
  264. case PowerSystemWorking:{
  265. dprintf("PowerSystemWorking\n");
  266. break;
  267. }
  268. case PowerSystemSleeping1: {
  269. dprintf("PowerSystemSleeping1\n");
  270. break;
  271. }
  272. case PowerSystemSleeping2: {
  273. dprintf("PowerSystemSleeping2\n");
  274. break;
  275. }
  276. case PowerSystemSleeping3: {
  277. dprintf("PowerSystemSleeping3\n");
  278. break;
  279. }
  280. case PowerSystemHibernate: {
  281. dprintf("PowerSystemHibernate\n");
  282. break;
  283. }
  284. case PowerSystemShutdown: {
  285. dprintf("PowerSystemShutdown\n");
  286. break;
  287. }
  288. default:
  289. dprintf("???\n");
  290. }
  291. }
  292. ULONG64
  293. ConfigFld (ULONG64 Addr, PUCHAR Field) {
  294. ULONG64 Temp;
  295. GetFieldValue(Addr, "pcmcia!SOCKET_CONFIGURATION", Field, Temp);
  296. return Temp;
  297. }
  298. VOID
  299. DumpSocketConfiguration(ULONG64 Config, ULONG Depth)
  300. /*++
  301. Routine Description
  302. Dumps the current configuration of the socket
  303. Arguments
  304. Config - Pointer to the current configuration for the socket
  305. Depth - Indentation at which to print
  306. Return Value
  307. None
  308. --*/
  309. {
  310. ULONG i;
  311. ULONG NumberOfIoPortRanges, NumberOfMemoryRanges;
  312. CHAR Buffer[40], Buffer2[40], Buffer3[40];
  313. xdprintf(Depth, "Irq 0x%x\n", (ULONG) ConfigFld(Config, "Irq"));
  314. xdprintf(Depth, "ReadyIrq 0x%x\n", (ULONG) ConfigFld(Config, "ReadyIrq"));
  315. if ((NumberOfIoPortRanges = (ULONG) ConfigFld(Config, "NumberOfIoPortRanges")) > 0) {
  316. xdprintf(Depth,
  317. "%x I/O range(s) configured, %s: ",
  318. NumberOfIoPortRanges,
  319. (ConfigFld(Config, "Io16BitAccess") ? "16-bit access" : "8-bit access"));
  320. for (i = 0; i < NumberOfIoPortRanges; i++) {
  321. if (CheckControlC()) {
  322. break;
  323. }
  324. sprintf(Buffer, "IoPortBase[%d]", i);
  325. sprintf(Buffer2, "IoPortLength[%d]", i);
  326. xdprintf(Depth+1, "Base 0x%x, length 0x%x\n",
  327. (ULONG) ConfigFld(Config, Buffer), (ULONG) ConfigFld(Config, Buffer2) +1);
  328. }
  329. }
  330. if ((NumberOfMemoryRanges = (ULONG) ConfigFld(Config, "NumberOfMemoryRanges")) > 0) {
  331. xdprintf(Depth, "%x memory range(s) configured", NumberOfMemoryRanges);
  332. if (ConfigFld(Config, "Mem16BitAccess")) {
  333. dprintf(", 16-bit access");
  334. } else {
  335. dprintf(", 8-bit access");
  336. }
  337. dprintf(":\n");
  338. for (i = 0; i < NumberOfMemoryRanges; i++) {
  339. if (CheckControlC()) {
  340. break;
  341. }
  342. sprintf(Buffer, "MemoryHostBase[%d]", i);
  343. sprintf(Buffer2, "MemoryCardBase[%d]", i);
  344. sprintf(Buffer3, "MemoryLength[%d]", i);
  345. xdprintf(Depth+1,"Host base 0x%x, card base 0x%x, length 0x%x\n",
  346. (ULONG) ConfigFld(Config, Buffer), (ULONG) ConfigFld(Config, Buffer2),
  347. (ULONG) ConfigFld(Config, Buffer3));
  348. }
  349. }
  350. }
  351. VOID
  352. DumpIrqMask(ULONG IrqMask)
  353. /*++
  354. Routine Description
  355. Dumps IRQ values as specified by the supplied mask.
  356. Arguments
  357. IrqMask - Values correspoinging to bits set to 1 in this mask are dumped:
  358. the value of a bit is 0-based, counted from LSB to MSB
  359. Return Value
  360. None
  361. --*/
  362. {
  363. ULONG temp, index, count;
  364. temp = 1;
  365. index = 0;
  366. count = 0;
  367. while (temp) {
  368. if (temp & IrqMask) {
  369. if (count > 0) {
  370. //
  371. // Print trailing comma
  372. //
  373. dprintf(",");
  374. }
  375. dprintf("%x", index);
  376. count++;
  377. }
  378. temp <<= 1; index++;
  379. }
  380. dprintf("\n");
  381. }
  382. ULONG64
  383. EntryFld (ULONG64 Addr, PUCHAR Field) {
  384. ULONG64 Temp;
  385. GetFieldValue(Addr, "pcmcia!CONFIG_ENTRY", Field, Temp);
  386. return Temp;
  387. }
  388. VOID
  389. DumpConfigEntry(ULONG64 Config, ULONG Depth)
  390. /*++
  391. Routine Description
  392. Dumps a single "config entry", i.e. the encapsulation of a
  393. CISTPL_CONFIG_ENTRY tuple on a pc-card
  394. Arguments
  395. Config - Pointer to the config entry
  396. Depth - Indentation at which to print
  397. Return Value
  398. None
  399. --*/
  400. {
  401. ULONG i;
  402. ULONG NumberOfIoPortRanges, NumberOfMemoryRanges, IrqMask;
  403. CHAR buffer[40], buffer2[40], buffer3[40];
  404. if (EntryFld(Config, "Flags") & PCMCIA_INVALID_CONFIGURATION) {
  405. xdprintf(Depth, "**This is an invalid configuration**\n");
  406. }
  407. xdprintf(Depth, "Index: 0x%x\n", (ULONG) EntryFld(Config, "IndexForThisConfiguration"));
  408. if ((NumberOfIoPortRanges = (ULONG) EntryFld(Config, "NumberOfIoPortRanges")) > 0) {
  409. for (i = 0; i < NumberOfIoPortRanges; i++) {
  410. ULONG IoPortBase;
  411. if (CheckControlC()) {
  412. break;
  413. }
  414. sprintf(buffer,"IoPortBase[%d]",i);
  415. sprintf(buffer2,"IoPortLength[%d]",i);
  416. sprintf(buffer3,"IoPortAlignment[%d]",i);
  417. if ((IoPortBase = (ULONG) EntryFld(Config, buffer)) == 0) {
  418. xdprintf(Depth,"I/O Any range of ");
  419. } else {
  420. xdprintf(Depth,"I/O Base 0x%x, ", IoPortBase);
  421. }
  422. dprintf("length 0x%x, alignment 0x%x, ",
  423. (ULONG) EntryFld(Config, buffer2)+1,
  424. (ULONG) EntryFld(Config, buffer3));
  425. if (EntryFld(Config, "Io16BitAccess") && EntryFld(Config, "Io8BitAccess")) {
  426. dprintf("16/8-bit access");
  427. } else if (EntryFld(Config, "Io16BitAccess")) {
  428. dprintf("16-bit access");
  429. } else if (EntryFld(Config, "Io8BitAccess")) {
  430. dprintf("8-bit access");
  431. }
  432. dprintf("\n");
  433. }
  434. }
  435. if ((NumberOfMemoryRanges = (ULONG) EntryFld(Config, "NumberOfMemoryRanges")) > 0) {
  436. for (i = 0; i < NumberOfMemoryRanges; i++) {
  437. if (CheckControlC()) {
  438. break;
  439. }
  440. sprintf(buffer,"MemoryHostBase[%d]",i);
  441. sprintf(buffer2,"MemoryCardBase[%d]",i);
  442. sprintf(buffer3,"MemoryLength[%d]",i);
  443. xdprintf(Depth,"MEM Host base 0x%x, card base 0x%x, len 0x%x\n",
  444. (ULONG) EntryFld(Config, buffer),
  445. (ULONG) EntryFld(Config, buffer2),
  446. (ULONG) EntryFld(Config, buffer3));
  447. }
  448. }
  449. if ((IrqMask = (ULONG) EntryFld(Config, "IrqMask")) != 0) {
  450. xdprintf(Depth,"IRQ - one of: ", IrqMask);
  451. DumpIrqMask(IrqMask);
  452. }
  453. //
  454. // Have to dump level/share disposition information some time..
  455. //
  456. }
  457. VOID
  458. DumpPcCardType(UCHAR Type,
  459. ULONG Depth)
  460. /*++
  461. Routine Description
  462. Prints the device type of the pc-card
  463. Arguments
  464. Type - Device type value
  465. Depth - Indentation
  466. Return value
  467. None
  468. --*/
  469. {
  470. PUCHAR s;
  471. xdprintf(Depth,"Device type: ");
  472. //
  473. // Type should be <= number of DeviceTypeTable entries - 1
  474. //
  475. if ((ULONG) Type >= sizeof(DeviceTypeTable)) {
  476. dprintf("Unknown\n");
  477. } else {
  478. dprintf("%s\n", DeviceTypeTable[(ULONG) Type]);
  479. }
  480. }
  481. VOID
  482. DumpConfigEntryChain(ULONG64 ConfigEntryChain,
  483. ULONG Depth)
  484. /*++
  485. Routine Description
  486. Dumps the chain of config entries
  487. Arguments
  488. ConfigEntryChain - pointer to head of config entry list
  489. Depth - indentation
  490. --*/
  491. {
  492. ULONG64 ce;
  493. ce = ConfigEntryChain;
  494. while (ce != 0) {
  495. if (CheckControlC()) {
  496. break;
  497. }
  498. xdprintf(Depth, ""); dprintf("ConfigEntry: 0x%p\n", ce);
  499. if (!GetFieldValue(ce, "pcmcia!CONFIG_ENTRY", "NextEntry", ConfigEntryChain)) {
  500. DumpConfigEntry(ce, Depth+1);
  501. ce = ConfigEntryChain;
  502. } else {
  503. ce = 0;
  504. }
  505. }
  506. }
  507. ULONG64
  508. SocDataFld (ULONG64 Addr, PUCHAR Field) {
  509. ULONG64 Temp;
  510. GetFieldValue(Addr, "pcmcia!SOCKET_DATA", Field, Temp);
  511. return Temp;
  512. }
  513. VOID
  514. DumpSocketData(ULONG64 SocketData, ULONG Depth)
  515. /*++
  516. Routine Description
  517. Dumps the socket data structure hanging off the device extension
  518. for a pc-card pdo, which describes in entirety the pc-card, it's
  519. resource/power requirements etc.
  520. Arguments
  521. SocketData - Pointer to the socket data structure
  522. Depth - Indentation at which to print
  523. Return Value
  524. None
  525. --*/
  526. {
  527. ULONG d;
  528. CHAR Mfg[80]={0}, Ident[80]={0};
  529. ULONG64 DefaultConfiguration;
  530. xdprintf(Depth, "");
  531. dprintf("NextSocketData 0x%p PrevSocketData 0x%p\n",
  532. SocDataFld(SocketData, "Next"), SocDataFld(SocketData, "Prev"));
  533. xdprintf(Depth, ""); dprintf("PdoExtension 0x%p\n", SocDataFld(SocketData, "PdoExtension"));
  534. GetFieldValue(SocketData, "pcmcia!SOCKET_DATA", "Mfg", Mfg);
  535. GetFieldValue(SocketData, "pcmcia!SOCKET_DATA", "Ident", Ident);
  536. xdprintf(Depth, "Manufacturer: %s Identifier: %s\n", Mfg, Ident);
  537. DumpPcCardType((UCHAR) SocDataFld(SocketData, "DeviceType"), Depth);
  538. xdprintf(Depth,"CisCrc: 0x%X LastEntryInCardConfig: 0x%x\n",
  539. (ULONG) SocDataFld(SocketData, "CisCrc"), (ULONG) SocDataFld(SocketData, "LastEntryInCardConfig"));
  540. xdprintf(Depth, "Manufacturer Code: 0x%x Info: 0x%x\n",
  541. (ULONG) SocDataFld(SocketData, "ManufacturerCode"),
  542. (ULONG) SocDataFld(SocketData, "ManufacturerInfo"));
  543. xdprintf(Depth, "Config Register Base: 0x%I64x\n", SocDataFld(SocketData, "ConfigRegisterBase"));
  544. //
  545. // Dump all the config entries hanging off this socket's pc-card
  546. //
  547. DumpConfigEntryChain(SocDataFld(SocketData, "ConfigEntryChain"), Depth);
  548. xdprintf(Depth, ""); dprintf("Default Configuration: 0x%p\n",
  549. (DefaultConfiguration = SocDataFld(SocketData, "DefaultConfiguration")));
  550. if (DefaultConfiguration != 0) {
  551. DumpConfigEntry(DefaultConfiguration, Depth+1);
  552. }
  553. xdprintf(Depth,"Vcc: 0x%x Vpp1: 0x%x Vpp2 0x%x\n",
  554. (ULONG) SocDataFld(SocketData, "Vcc"),
  555. (ULONG) SocDataFld(SocketData, "Vpp1"),
  556. (ULONG) SocDataFld(SocketData, "Vpp2"));
  557. xdprintf(Depth,"Audio: 0x%x RegistersPresentMask 0x%x\n",
  558. (ULONG) SocDataFld(SocketData, "Audio"),
  559. (ULONG) SocDataFld(SocketData, "RegistersPresentMask"));
  560. xdprintf(Depth, "ConfigIndex used for current card configuration: 0x%x\n",
  561. (ULONG) SocDataFld(SocketData, "ConfigIndexUsed"));
  562. xdprintf(Depth, "Function number (in a multifunc. card): 0x%x\n",
  563. (ULONG) SocDataFld(SocketData, "Function"));
  564. xdprintf(Depth, "Instance number: 0x%x\n", (ULONG) SocDataFld(SocketData, "Instance"));
  565. xdprintf(Depth, "Mf ResourceMap: irq index %x.%x, i/o index %x.%x, mem index %x.%x\n",
  566. (ULONG) SocDataFld(SocketData, "MfIrqResourceMapIndex"),
  567. (ULONG) SocDataFld(SocketData, "MfNeedsIrq"),
  568. (ULONG) SocDataFld(SocketData, "MfIoPortResourceMapIndex"),
  569. (ULONG) SocDataFld(SocketData, "MfIoPortCount"),
  570. (ULONG) SocDataFld(SocketData, "MfMemoryResourceMapIndex"),
  571. (ULONG) SocDataFld(SocketData, "MfMemoryCount"));
  572. }
  573. ULONG64
  574. PDOxFld (ULONG64 Addr, PUCHAR Field) {
  575. ULONG64 Temp;
  576. GetFieldValue(Addr, "pcmcia!PDO_EXTENSION", Field, Temp);
  577. return Temp;
  578. }
  579. ULONG64
  580. FDOxFld (ULONG64 Addr, PUCHAR Field) {
  581. ULONG64 Temp;
  582. GetFieldValue(Addr, "pcmcia!FDO_EXTENSION", Field, Temp);
  583. return Temp;
  584. }
  585. VOID
  586. DevExtPcmcia(
  587. ULONG64 Extension
  588. )
  589. /*++
  590. Routine Description:
  591. Dump a PCMCIA Device extension.
  592. Arguments:
  593. Extension Address of the extension to be dumped.
  594. Return Value:
  595. None.
  596. --*/
  597. {
  598. ULONG64 DeviceObject=0;
  599. ULONG64 socketDataPtr;
  600. ULONG Flags, depth;
  601. if (!ReadPointer(Extension, &DeviceObject)) {
  602. dprintf(
  603. "Failed to read PCMCIA extension at %08p, giving up.\n",
  604. Extension
  605. );
  606. return;
  607. }
  608. if (GetFieldValue(DeviceObject, "nt!_DEVICE_OBJECT", "Flags", Flags)) {
  609. return;
  610. }
  611. if (Flags & DO_BUS_ENUMERATED_DEVICE) {
  612. //
  613. // This is the extension for a PC-Card PDO
  614. //
  615. ULONG64 socketPtr, Capabilities;
  616. ULONG64 DeviceId;
  617. UCHAR deviceId[PCMCIA_MAXIMUM_DEVICE_ID_LENGTH];
  618. if (GetFieldValue(Extension, "pcmcia!PDO_EXTENSION", "DeviceId", DeviceId)) {
  619. return;
  620. }
  621. dprintf("PDO Extension, Device Object 0x%p\n",PDOxFld(Extension, "DeviceObject"));
  622. DumpFlags(0, " Device Flags", (ULONG) PDOxFld(Extension, "Flags"), PcmciaDeviceFlags);
  623. dprintf(" NextPdo 0x%p LowerDevice 0x%p PciPdo 0x%p\n",
  624. PDOxFld(Extension, "NextPdoInFdoChain"),
  625. PDOxFld(Extension, "LowerDevice"),
  626. PDOxFld(Extension, "PciPdo"));
  627. dprintf(" DeviceId 0x%p: ", DeviceId);
  628. if (DeviceId != 0) {
  629. ULONG status;
  630. ReadMemory(DeviceId, deviceId, PCMCIA_MAXIMUM_DEVICE_ID_LENGTH, &status);
  631. dprintf("%s", deviceId);
  632. }
  633. dprintf("\n");
  634. dprintf(" Socket: 0x%x\n", PDOxFld(Extension, "Socket"));
  635. socketDataPtr = PDOxFld(Extension, "SocketData");
  636. while (socketDataPtr != 0) {
  637. //
  638. // Dump socket data structure
  639. //
  640. dprintf(" SocketData 0x%x\n", socketDataPtr);
  641. DumpSocketData(socketDataPtr, 2);
  642. socketDataPtr = SocDataFld(socketDataPtr, "Next");
  643. }
  644. DumpDevicePowerState((ULONG) PDOxFld(Extension, "DevicePowerState"));
  645. DumpSystemPowerState((ULONG) PDOxFld(Extension, "SystemPowerState"));
  646. dprintf(" WaitWakeIrp 0x%p\n", PDOxFld(Extension, "WaitWakeIrp"));
  647. dprintf(" PendingPowerIrp 0x%p\n", PDOxFld(Extension, "PendingPowerIrp"));
  648. dprintf(" DeviceCapabilities (at 0x%p): \n", (Capabilities = PDOxFld(Extension, "Capabilities")));
  649. if (Capabilities != 0) {
  650. DumpDeviceCapabilities(Capabilities);
  651. }
  652. dprintf(" ConfigurationPhase: %d\n", (ULONG) PDOxFld(Extension, "ConfigurationPhase"));
  653. dprintf(" PowerWorker State: ");
  654. DumpEnum((ULONG) PDOxFld(Extension, "PowerWorkerState"), PcmciaPdoPowerWorkerStates);
  655. dprintf("\n");
  656. if ((ULONG) PDOxFld(Extension, "PowerWorkerState") != PPW_Stopped) {
  657. dprintf(" Worker Phase %d\n", (ULONG) PDOxFld(Extension, "PowerWorkerPhase"));
  658. dprintf(" Worker Sequence 0x%x\n", (ULONG) PDOxFld(Extension, "PowerWorkerSequence"));
  659. }
  660. } else {
  661. //
  662. // This is the extension for the pcmcia controller FDO
  663. //
  664. ULONG64 addr, PdoList, NextFdo, Capabilities;
  665. ULONG depth;
  666. ULONG model, revision;
  667. ULONG ControllerType, off;
  668. if (GetFieldValue(Extension, "pcmcia!FDO_EXTENSION", "PdoList", PdoList)) {
  669. return;
  670. }
  671. dprintf("FDO Extension, Device Object 0x%p\n", FDOxFld(Extension, "DeviceObject"));
  672. dprintf(" DriverObject 0x%p, RegistryPath 0x%p\n",
  673. FDOxFld(Extension, "DriverObject"), FDOxFld(Extension, "RegistryPath"));
  674. DumpFlags(0, " Device Flags", (ULONG) FDOxFld(Extension, "Flags"), PcmciaDeviceFlags);
  675. dprintf(" ControllerType (%x): ", (ControllerType = (ULONG) FDOxFld(Extension, "ControllerType")));
  676. DumpEnum(PcmciaClassFromControllerType(ControllerType), PcmciaControllerTypeEnum);
  677. if (model = PcmciaModelFromControllerType(ControllerType)) {
  678. dprintf("%d", model);
  679. }
  680. if (revision = PcmciaRevisionFromControllerType(ControllerType)) {
  681. dprintf(", rev(%d)", revision);
  682. }
  683. dprintf("\n");
  684. dprintf(" Child PdoList head 0x%p ", PdoList);
  685. GetFieldOffset("nt!_DEVICE_OBJECT","DeviceExtension", &off);
  686. if ((PdoList != 0) &&
  687. ReadPointer( PdoList + off ,
  688. &addr)) {
  689. dprintf("device extension 0x%p\n", addr);
  690. } else {
  691. dprintf("\n");
  692. }
  693. dprintf(" LivePdoCount 0x%x\n", (ULONG) FDOxFld(Extension, "LivePdoCount"));
  694. dprintf(" NextFdo 0x%p ", (NextFdo = FDOxFld(Extension, "NextFdo")));
  695. if ((NextFdo != 0) &&
  696. ReadPointer(NextFdo + off,
  697. &addr)) {
  698. dprintf("device extension 0x%p\n", addr);
  699. } else {
  700. dprintf("\n");
  701. }
  702. dprintf(" Pdo (for this fdo) 0x%p\n", FDOxFld(Extension, "Pdo"));
  703. dprintf(" LowerDevice 0x%p\n", FDOxFld(Extension, "LowerDevice"));
  704. dprintf(" SocketList 0x%p\n", FDOxFld(Extension, "SocketList"));
  705. dprintf(" IRQ mask 0x%x allows IRQs: ", (ULONG) FDOxFld(Extension, "AllocatedIrqMask"));
  706. DumpIrqMask((ULONG) FDOxFld(Extension, "AllocatedIrqMask"));
  707. dprintf(" Memory window physical address 0x%p\n", FDOxFld(Extension, "PhysicalBase"));
  708. dprintf(" Memory window virtual address 0x%p\n", FDOxFld(Extension, "AttributeMemoryBase"));
  709. dprintf(" Memory window size 0x%x\n", (ULONG) FDOxFld(Extension, "AttributeMemorySize"));
  710. dprintf(" DeviceDispatchIndex %x\n", (ULONG) FDOxFld(Extension, "DeviceDispatchIndex"));
  711. dprintf(" PCCard Ready Delay Iterations 0x%x (%d)\n",
  712. (ULONG) FDOxFld(Extension, "ReadyDelayIter"), (ULONG) FDOxFld(Extension, "ReadyDelayIter"));
  713. dprintf(" PCCard Ready Stall in usecs 0x%x (%d)\n",
  714. (ULONG) FDOxFld(Extension, "ReadyStall"), (ULONG) FDOxFld(Extension, "ReadyStall"));
  715. dprintf(" Number of sockets powered up %d\n",
  716. (ULONG) FDOxFld(Extension, "NumberOfSocketsPoweredUp"));
  717. DumpDevicePowerState((ULONG) FDOxFld(Extension, "DevicePowerState"));
  718. DumpSystemPowerState((ULONG) FDOxFld(Extension, "SystemPowerState"));
  719. //
  720. // Pending wait wake irp
  721. //
  722. dprintf(" WaitWakeIrp: %p\n", FDOxFld(Extension, "WaitWakeIrp"));
  723. //
  724. // Dump saved register context
  725. //
  726. dprintf(" PCI Context range, buffer: %p(%d), %p\n",
  727. FDOxFld(Extension, "PciContext.Range"), (ULONG) FDOxFld(Extension, "PciContext.RangeCount"),
  728. FDOxFld(Extension, "PciContextBuffer"));
  729. dprintf(" Cardbus Context range: %p(%d)\n",
  730. FDOxFld(Extension, "CardbusContext.Range"), (ULONG) FDOxFld(Extension, "CardbusContext.RangeCount"));
  731. dprintf(" Exca Context range: %p(%d)\n",
  732. FDOxFld(Extension, "ExcaContext.Range"), (ULONG) FDOxFld(Extension, "ExcaContext.RangeCount"));
  733. //
  734. // Dump capabilities
  735. //
  736. dprintf(" DeviceCapabilities (at 0x%p): \n", (Capabilities = FDOxFld(Extension, "Capabilities")));
  737. if (Capabilities != 0) {
  738. DumpDeviceCapabilities(Capabilities);
  739. }
  740. }
  741. }
  742. DECLARE_API( socket )
  743. /*++
  744. Routine Description:
  745. Dump a socket
  746. Arguments:
  747. args - the location of the socket to dump
  748. Return Value:
  749. None
  750. --*/
  751. {
  752. ULONG64 socketAddr=0;
  753. ULONG depth, status;
  754. socketAddr = GetExpression(args);
  755. if (ReadMemory(socketAddr, &depth, sizeof(depth), &status)) {
  756. dprintf("Socket at %p:\n", socketAddr);
  757. DumpSocket(socketAddr, 0);
  758. } else {
  759. dprintf("Could not read socket at %p\n", socketAddr);
  760. }
  761. return S_OK;
  762. }
  763. VOID
  764. DumpFlagsBrief(ULONG Flags)
  765. {
  766. if (Flags & PCMCIA_DEVICE_STARTED) {
  767. dprintf(" ST");
  768. } else {
  769. dprintf(" NS");
  770. }
  771. if (Flags & PCMCIA_DEVICE_LOGICALLY_REMOVED) {
  772. dprintf(" RM");
  773. }
  774. if (Flags & PCMCIA_DEVICE_PHYSICALLY_REMOVED) {
  775. dprintf(" EJ");
  776. }
  777. if (Flags & PCMCIA_DEVICE_DELETED) {
  778. dprintf(" DL");
  779. }
  780. if (Flags & PCMCIA_DEVICE_MULTIFUNCTION) {
  781. dprintf(" MF");
  782. }
  783. if (Flags & PCMCIA_DEVICE_WAKE_PENDING) {
  784. dprintf(" WP");
  785. }
  786. if (Flags & PCMCIA_DEVICE_LEGACY_DETECTED) {
  787. dprintf(" LD");
  788. }
  789. if (Flags & PCMCIA_DEVICE_CARDBUS) {
  790. dprintf(" CB");
  791. }
  792. }
  793. DECLARE_API( pcmcia )
  794. /*++
  795. Routine Description:
  796. Dumps overview of pcmcia driver state
  797. Arguments:
  798. args - the location of the socket to dump
  799. Return Value:
  800. None
  801. --*/
  802. {
  803. ULONG64 addr;
  804. ULONG64 fdoDevObj, pdoDevObj, pSocket;
  805. ULONG64 Extension;
  806. ULONG Count = 0, off;
  807. UCHAR deviceId[PCMCIA_MAXIMUM_DEVICE_ID_LENGTH];
  808. if (args[0] != '\0') {
  809. dprintf("!pcmcia - dumps general pcmcia driver state\n\n");
  810. dprintf("flag descriptions:\n");
  811. dprintf(" ST - Started\n");
  812. dprintf(" NS - Not Started\n");
  813. dprintf(" RM - Logically Removed\n");
  814. dprintf(" EJ - Physically Ejected\n");
  815. dprintf(" DL - Deleted\n");
  816. dprintf(" MF - MultiFunction\n");
  817. dprintf(" WP - Wake Pending\n");
  818. dprintf(" LD - Legacy Detected\n");
  819. dprintf(" CB - CardBus\n");
  820. }
  821. addr = GetExpression( "pcmcia!fdolist" );
  822. if (addr == 0) {
  823. dprintf("Error retrieving address of pcmcia!fdolist\n");
  824. return E_INVALIDARG;
  825. }
  826. if (!ReadPointer(addr, &fdoDevObj)) {
  827. dprintf("Failed to read fdolist at %08p, giving up.\n", addr);
  828. return E_INVALIDARG;
  829. }
  830. GetFieldOffset("nt!_DEVICE_OBJECT", "DeviceExtension", &off);
  831. while(fdoDevObj) {
  832. ULONG64 NextFdo;
  833. ULONG64 CbReg;
  834. if (CheckControlC()) {
  835. break;
  836. }
  837. if (!ReadPointer(fdoDevObj+off,&Extension)) {
  838. dprintf("Failed to read fdo extension address at %08p, giving up.\n", fdoDevObj+off);
  839. return E_INVALIDARG;
  840. }
  841. if (GetFieldValue(Extension, "pcmcia!FDO_EXTENSION", "NextFdo", NextFdo)) {
  842. dprintf("GetFieldValue failed for fdo extension at %08p, giving up.\n", Extension);
  843. return E_INVALIDARG;
  844. }
  845. dprintf("\nFDO %.8p ext %.8p\n", fdoDevObj, Extension);
  846. if (GetFieldValue(Extension, "pcmcia!FDO_EXTENSION", "CardBusSocketRegisterBase", CbReg)) {
  847. dprintf("GetFieldValue failed for fdo extension at %08p, giving up.\n", Extension);
  848. return E_INVALIDARG;
  849. }
  850. if (CbReg) {
  851. dprintf(" CbReg %.8p\n\n", CbReg);
  852. } else {
  853. dprintf("\n");
  854. }
  855. //
  856. // Print list of PDOs enumerated by this FDO
  857. //
  858. pdoDevObj = FDOxFld(Extension, "PdoList");
  859. pSocket = FDOxFld(Extension, "SocketList");
  860. if (!pdoDevObj) {
  861. xdprintf(2, "*no PDO's enumerated*\n");
  862. } else {
  863. xdprintf(2, "pdolist:");
  864. }
  865. while(pdoDevObj) {
  866. if (CheckControlC()) {
  867. break;
  868. }
  869. if (!ReadPointer(pdoDevObj+off,&Extension)) {
  870. return E_INVALIDARG;
  871. }
  872. dprintf(" %.8p", pdoDevObj);
  873. pdoDevObj = PDOxFld(Extension, "NextPdoInFdoChain");
  874. }
  875. dprintf("\n");
  876. //
  877. // Print list of sockets
  878. //
  879. if (!pSocket) {
  880. xdprintf(2, "*no sockets!*\n");
  881. }
  882. while(pSocket) {
  883. ULONG64 NextSocket;
  884. ULONG SocketNumber;
  885. if (CheckControlC()) {
  886. break;
  887. }
  888. if (GetFieldValue(pSocket, "pcmcia!SOCKET", "NextSocket", NextSocket)) {
  889. return E_INVALIDARG;
  890. }
  891. dprintf(" Socket %.8p\n", pSocket);
  892. dprintf(" base %.8p", SocFld(pSocket, "AddressPort"));
  893. if (SocketNumber = (ULONG) SocFld(pSocket, "SocketNumber")) {
  894. dprintf(".%d", SocketNumber);
  895. }
  896. dprintf("\n");
  897. //
  898. // Dump pdo's in socket list
  899. //
  900. pdoDevObj = SocFld(pSocket, "PdoList");
  901. if (!pdoDevObj) {
  902. xdprintf(3, "*empty*\n");
  903. }
  904. while(pdoDevObj) {
  905. ULONG64 DeviceId;
  906. ULONG status;
  907. if (CheckControlC()) {
  908. break;
  909. }
  910. if (!ReadPointer(pdoDevObj + off,&Extension)) {
  911. return E_INVALIDARG;
  912. }
  913. if (GetFieldValue(Extension, "pcmcia!PDO_EXTENSION", "DeviceId", DeviceId)) {
  914. return E_INVALIDARG;
  915. }
  916. dprintf(" PDO %.8p ext %.8p", pdoDevObj, Extension);
  917. DumpFlagsBrief((ULONG) PDOxFld(Extension, "Flags"));
  918. dprintf("\n");
  919. if (DeviceId != 0) {
  920. ReadMemory(DeviceId, deviceId, PCMCIA_MAXIMUM_DEVICE_ID_LENGTH, &status);
  921. dprintf(" %s\n", deviceId);
  922. }
  923. pdoDevObj = PDOxFld(Extension, "NextPdoInSocket");
  924. }
  925. pSocket = NextSocket;
  926. }
  927. fdoDevObj = NextFdo;
  928. }
  929. return S_OK;
  930. }