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.

1706 lines
45 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. mts.c
  5. Abstract:
  6. MikeTs's little KD extension.
  7. Author:
  8. Michael Tsang (mikets) 18-November-1997
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #include "pcskthw.h"
  15. #include "pci.h"
  16. #pragma hdrstop
  17. BOOL
  18. ReadPci (
  19. IN PPCI_TYPE1_CFG_BITS PciCfg1,
  20. OUT PUCHAR Buffer,
  21. IN ULONG Offset,
  22. IN ULONG Length
  23. );
  24. BOOLEAN
  25. WritePci (
  26. IN PPCI_TYPE1_CFG_BITS PciCfg1,
  27. IN PUCHAR Buffer,
  28. IN ULONG Offset,
  29. IN ULONG Length
  30. );
  31. typedef struct _PCI_BRIDBG_CTRL_REG {
  32. USHORT PERRREnable:1;
  33. USHORT SERREnable:1;
  34. USHORT ISAEnable:1;
  35. USHORT VGAEnable:1;
  36. USHORT Reserved:1;
  37. USHORT MasterAbort:1;
  38. USHORT CBRst:1;
  39. USHORT IRQRoutingEnable:1;
  40. USHORT Mem0Prefetch:1;
  41. USHORT Mem1Prefetch:1;
  42. USHORT WritePostEnable:1;
  43. USHORT Reserved1:5;
  44. } PCI_BRIDBG_CTRL_REG;
  45. VOID PrintClassInfo(PBYTE pb, DWORD dwReg);
  46. void PrintPciStatusReg(
  47. USHORT Status
  48. )
  49. {
  50. if (Status & PCI_STATUS_CAPABILITIES_LIST) {
  51. dprintf("CapList ");
  52. }
  53. if (Status & PCI_STATUS_66MHZ_CAPABLE) {
  54. dprintf("66MHzCapable ");
  55. }
  56. if (Status & PCI_STATUS_UDF_SUPPORTED) {
  57. dprintf("UDFSupported ");
  58. }
  59. if (Status & PCI_STATUS_FAST_BACK_TO_BACK) {
  60. dprintf("FB2BCapable ");
  61. }
  62. if (Status & PCI_STATUS_DATA_PARITY_DETECTED) {
  63. dprintf("DataPERR ");
  64. }
  65. if (Status & PCI_STATUS_SIGNALED_TARGET_ABORT) {
  66. dprintf("TargetDevAbort ");
  67. }
  68. if (Status & PCI_STATUS_RECEIVED_TARGET_ABORT) {
  69. dprintf("TargetAbort ");
  70. }
  71. if (Status & PCI_STATUS_RECEIVED_MASTER_ABORT) {
  72. dprintf("InitiatorAbort ");
  73. }
  74. if (Status & PCI_STATUS_SIGNALED_SYSTEM_ERROR) {
  75. dprintf("SERR ");
  76. }
  77. if (Status & PCI_STATUS_DETECTED_PARITY_ERROR) {
  78. dprintf("PERR ");
  79. }
  80. if (Status & PCI_STATUS_DEVSEL) {
  81. dprintf("DEVSELTiming:%lx",(Status & PCI_STATUS_DEVSEL) >> 9);
  82. }
  83. dprintf("\n");
  84. }
  85. void PrintPciBridgeCtrlReg(
  86. USHORT Bridge
  87. )
  88. {
  89. PCI_BRIDBG_CTRL_REG bReg = *((PCI_BRIDBG_CTRL_REG *) &Bridge);
  90. if (bReg.PERRREnable) {
  91. dprintf("PERRREnable ");
  92. }
  93. if (bReg.SERREnable) {
  94. dprintf("SERREnable ");
  95. }
  96. if (bReg.ISAEnable) {
  97. dprintf("ISAEnable ");
  98. }
  99. if (bReg.MasterAbort) {
  100. dprintf("MasterAbort ");
  101. }
  102. if (bReg.CBRst) {
  103. dprintf("CBRst ");
  104. }
  105. if (bReg.IRQRoutingEnable) {
  106. dprintf("IRQRoutingEnable ");
  107. }
  108. if (bReg.Mem0Prefetch) {
  109. dprintf("Mem0Prefetch ");
  110. }
  111. if (bReg.Mem1Prefetch) {
  112. dprintf("Mem1Prefetch ");
  113. }
  114. if (bReg.WritePostEnable) {
  115. dprintf("WritePostEnable ");
  116. }
  117. dprintf("\n");
  118. }
  119. BOOL
  120. PrintCommonConfigSpace(
  121. PCI_COMMON_CONFIG *pCmnCfg,
  122. PCHAR Pad
  123. )
  124. {
  125. if (!Pad) {
  126. Pad = "";
  127. }
  128. dprintf("%sVendorID %04lx\n", Pad, pCmnCfg->VendorID);
  129. dprintf("%sDeviceID %04lx\n", Pad, pCmnCfg->DeviceID);
  130. dprintf("%sCommand ", Pad);
  131. if (pCmnCfg->Command & PCI_ENABLE_IO_SPACE) {
  132. dprintf("IOSpaceEnable ");
  133. }
  134. if (pCmnCfg->Command & PCI_ENABLE_MEMORY_SPACE) {
  135. dprintf("MemSpaceEnable ");
  136. }
  137. if (pCmnCfg->Command & PCI_ENABLE_BUS_MASTER) {
  138. dprintf("BusInitiate ");
  139. }
  140. if (pCmnCfg->Command & PCI_ENABLE_SPECIAL_CYCLES) {
  141. dprintf("SpecialCycle ");
  142. }
  143. if (pCmnCfg->Command & PCI_ENABLE_WRITE_AND_INVALIDATE) {
  144. dprintf("MemWriteEnable ");
  145. }
  146. if (pCmnCfg->Command & PCI_ENABLE_VGA_COMPATIBLE_PALETTE) {
  147. dprintf("VGASnoop ");
  148. }
  149. if (pCmnCfg->Command & PCI_ENABLE_PARITY) {
  150. dprintf("PERREnable ");
  151. }
  152. if (pCmnCfg->Command & PCI_ENABLE_WAIT_CYCLE) {
  153. dprintf("WaitCycle ");
  154. }
  155. if (pCmnCfg->Command & PCI_ENABLE_SERR) {
  156. dprintf("SERREnable ");
  157. }
  158. if (pCmnCfg->Command & PCI_ENABLE_FAST_BACK_TO_BACK) {
  159. dprintf("FB2BEnable ");
  160. }
  161. dprintf("\n");
  162. dprintf("%sStatus ", Pad);
  163. PrintPciStatusReg(pCmnCfg->Status);
  164. dprintf("%sRevisionID %02lx\n%sProgIF %02lx",
  165. Pad,
  166. pCmnCfg->RevisionID,
  167. Pad,
  168. pCmnCfg->ProgIf);
  169. PrintClassInfo((PBYTE) pCmnCfg, FIELD_OFFSET(PCI_COMMON_CONFIG, ProgIf));
  170. dprintf("%sSubClass %02lx", Pad,
  171. pCmnCfg->SubClass);
  172. PrintClassInfo((PBYTE) pCmnCfg, FIELD_OFFSET(PCI_COMMON_CONFIG, SubClass));
  173. dprintf("%sBaseClass %02lx", Pad,
  174. pCmnCfg->BaseClass);
  175. PrintClassInfo((PBYTE) pCmnCfg, FIELD_OFFSET(PCI_COMMON_CONFIG, BaseClass));
  176. dprintf("%sCacheLineSize %04lx", Pad, pCmnCfg->CacheLineSize);
  177. if (pCmnCfg->CacheLineSize & 0xf0) {
  178. dprintf("BurstDisabled ");
  179. }
  180. if (pCmnCfg->CacheLineSize & 0xf) {
  181. dprintf("Burst4DW");
  182. }
  183. dprintf("\n");
  184. dprintf("%sLatencyTimer %02lx\n", Pad, pCmnCfg->LatencyTimer);
  185. dprintf("%sHeaderType %02lx\n", Pad, pCmnCfg->HeaderType);
  186. dprintf("%sBIST %02lx\n", Pad, pCmnCfg->BIST);
  187. return TRUE;
  188. }
  189. BOOL
  190. PrintCfgSpaceType0(
  191. PCI_COMMON_CONFIG *pCmnCfg,
  192. PCHAR Pad
  193. )
  194. {
  195. int i;
  196. if (!Pad) {
  197. Pad = "";
  198. }
  199. for (i=0; i<PCI_TYPE0_ADDRESSES; ++i) {
  200. dprintf("%sBAR%x %08lx\n", Pad, i, pCmnCfg->u.type0.BaseAddresses[i]);
  201. }
  202. dprintf("%sCBCISPtr %08lx\n", Pad, pCmnCfg->u.type0.CIS);
  203. dprintf("%sSubSysVenID %04lx\n", Pad, pCmnCfg->u.type0.SubVendorID);
  204. dprintf("%sSubSysID %04lx\n", Pad, pCmnCfg->u.type0.SubSystemID);
  205. dprintf("%sROMBAR %08lx\n", Pad, pCmnCfg->u.type0.ROMBaseAddress);
  206. dprintf("%sCapPtr %02lx\n", Pad, pCmnCfg->u.type0.CapabilitiesPtr);
  207. dprintf("%sIntLine %02lx\n", Pad, pCmnCfg->u.type0.InterruptLine);
  208. dprintf("%sIntPin %02lx\n", Pad, pCmnCfg->u.type0.InterruptPin);
  209. dprintf("%sMinGnt %02lx\n", Pad, pCmnCfg->u.type0.MinimumGrant);
  210. dprintf("%sMaxLat %02lx\n", Pad, pCmnCfg->u.type0.MaximumLatency);
  211. return TRUE;
  212. }
  213. BOOL
  214. PrintCfgSpaceType1(
  215. PCI_COMMON_CONFIG *pCmnCfg,
  216. PCHAR Pad
  217. )
  218. {
  219. int i;
  220. if (!Pad) {
  221. Pad = "";
  222. }
  223. for (i=0; i<PCI_TYPE1_ADDRESSES; ++i) {
  224. dprintf("%sBAR%x %08lx\n", Pad, i, pCmnCfg->u.type1.BaseAddresses[i]);
  225. }
  226. dprintf("%sPriBusNum %02lx\n", Pad, pCmnCfg->u.type1.PrimaryBus);
  227. dprintf("%sSecBusNum %02lx\n", Pad, pCmnCfg->u.type1.SecondaryBus);
  228. dprintf("%sSubBusNum %02lx\n", Pad, pCmnCfg->u.type1.SubordinateBus);
  229. dprintf("%sSecLatencyTmr %02lx\n", Pad, pCmnCfg->u.type1.SecondaryLatency);
  230. dprintf("%sIOBase %02lx\n", Pad, pCmnCfg->u.type1.IOBase);
  231. dprintf("%sIOLimit %02lx\n", Pad, pCmnCfg->u.type1.IOLimit);
  232. dprintf("%sSecStatus ",Pad);
  233. PrintPciStatusReg(pCmnCfg->u.type1.SecondaryStatus);
  234. dprintf("%sMemBase %04lx\n", Pad, pCmnCfg->u.type1.MemoryBase);
  235. dprintf("%sMemLimit %04lx\n", Pad, pCmnCfg->u.type1.MemoryLimit);
  236. dprintf("%sPrefMemBase %04lx\n", Pad, pCmnCfg->u.type1.PrefetchBase);
  237. dprintf("%sPrefMemLimit %04lx\n", Pad, pCmnCfg->u.type1.PrefetchLimit);
  238. dprintf("%sPrefBaseHi %08lx\n", Pad, pCmnCfg->u.type1.PrefetchBaseUpper32);
  239. dprintf("%sPrefLimitHi %08lx\n", Pad, pCmnCfg->u.type1.PrefetchLimitUpper32);
  240. dprintf("%sIOBaseHi %04lx\n", Pad, pCmnCfg->u.type1.IOBaseUpper16);
  241. dprintf("%sIOLimitHi %04lx\n", Pad, pCmnCfg->u.type1.IOLimitUpper16);
  242. dprintf("%sCapPtr %02lx\n", Pad, pCmnCfg->u.type1.CapabilitiesPtr);
  243. dprintf("%sROMBAR %08lx\n", Pad, pCmnCfg->u.type1.ROMBaseAddress);
  244. dprintf("%sIntLine %02lx\n", Pad, pCmnCfg->u.type1.InterruptLine);
  245. dprintf("%sIntPin %02lx\n", Pad, pCmnCfg->u.type1.InterruptPin);
  246. dprintf("%sBridgeCtrl %04lx\n", Pad, pCmnCfg->u.type1.BridgeControl);
  247. return TRUE;
  248. }
  249. BOOL
  250. PrintCfgSpaceType2(
  251. PCI_COMMON_CONFIG *pCmnCfg,
  252. PCHAR Pad
  253. )
  254. {
  255. int i;
  256. if (!Pad) {
  257. Pad = "";
  258. }
  259. dprintf("%sRegBaseAddr %08lx\n", Pad, pCmnCfg->u.type2.SocketRegistersBaseAddress);
  260. dprintf("%sCapPtr %02lx\n", Pad, pCmnCfg->u.type2.CapabilitiesPtr);
  261. dprintf("%sSecStatus ", Pad);
  262. PrintPciStatusReg(pCmnCfg->u.type2.SecondaryStatus);
  263. dprintf("%sPCIBusNum %02lx\n", Pad, pCmnCfg->u.type2.PrimaryBus);
  264. dprintf("%sCBBusNum %02lx\n", Pad, pCmnCfg->u.type2.SecondaryBus);
  265. dprintf("%sSubBusNum %02lx\n", Pad, pCmnCfg->u.type2.SubordinateBus);
  266. dprintf("%sCBLatencyTimer %02lx\n", Pad, pCmnCfg->u.type2.SecondaryLatency);
  267. for (i=0; i< PCI_TYPE2_ADDRESSES; ++i) {
  268. dprintf("%sRange[%lx].Base %08lx\n", Pad, i, pCmnCfg->u.type2.Range[i].Base);
  269. dprintf("%sRange[%lx].Limit %08lx\n", Pad, i, pCmnCfg->u.type2.Range[i].Limit);
  270. }
  271. dprintf("%sIntLine %02lx\n", Pad, pCmnCfg->u.type2.InterruptLine);
  272. dprintf("%sIntPin %02lx\n", Pad, pCmnCfg->u.type2.InterruptPin);
  273. dprintf("%sBridgeCtrl %02lx\n", Pad);
  274. PrintPciBridgeCtrlReg(pCmnCfg->u.type2.BridgeControl);
  275. #if 0
  276. // Not part of type2 typedef, but were present in old !dcs
  277. {"SubSysVenID=", (PFMTHDR)&fmtHexWord, NULL},
  278. {"SubSysID=", (PFMTHDR)&fmtHexWord, NULL},
  279. {"LegacyBaseAddr=",(PFMTHDR)&fmtHexDWord, NULL},
  280. #endif
  281. return TRUE;
  282. }
  283. void
  284. PrintDataRange(
  285. PCHAR pData,
  286. ULONG nDwords,
  287. ULONG base,
  288. PCHAR Pad
  289. )
  290. {
  291. unsigned int i;
  292. unsigned int j;
  293. PULONG pRange;
  294. pRange = (PULONG) pData;
  295. if (!Pad) {
  296. Pad = "";
  297. }
  298. for (i=0; i<((nDwords+3)/4); i++) {
  299. dprintf("%s%02lx:", Pad, base + i*16);
  300. for (j=0; (j < 4) && (i*4+j < nDwords); j++) {
  301. dprintf(" %08lx", pRange[i*4+j]);
  302. }
  303. dprintf("\n");
  304. }
  305. }
  306. BOOL
  307. PrintPciCapHeader(
  308. PCI_CAPABILITIES_HEADER *pCapHdr,
  309. PCHAR Pad
  310. )
  311. {
  312. if (!Pad) Pad = "";
  313. dprintf("%sCapID ", Pad);
  314. if (pCapHdr->CapabilityID & PCI_CAPABILITY_ID_POWER_MANAGEMENT) {
  315. dprintf("PwrMgmt ");
  316. }
  317. if (pCapHdr->CapabilityID & PCI_CAPABILITY_ID_AGP) {
  318. dprintf("AGP ");
  319. }
  320. if (pCapHdr->CapabilityID & PCI_CAPABILITY_ID_MSI) {
  321. dprintf("MSI ");
  322. }
  323. dprintf("\n");
  324. dprintf("%sNextPtr %02lx\n", Pad, pCapHdr->Next);
  325. return TRUE;
  326. }
  327. void
  328. PrintPciPwrMgmtCaps(
  329. USHORT Capabilities
  330. )
  331. {
  332. PCI_PMC pmc;
  333. pmc = *((PCI_PMC *) &Capabilities);
  334. if (pmc.PMEClock) {
  335. dprintf("PMECLK ");
  336. }
  337. if (pmc.Rsvd1) {
  338. dprintf("AUXPWR ");
  339. }
  340. if (pmc.DeviceSpecificInitialization) {
  341. dprintf("DSI ");
  342. }
  343. if (pmc.Support.D1) {
  344. dprintf("D1Support ");
  345. }
  346. if (pmc.Support.D2) {
  347. dprintf("D2Support ");
  348. }
  349. if (pmc.Support.PMED0) {
  350. dprintf("PMED0 ");
  351. }
  352. if (pmc.Support.PMED1) {
  353. dprintf("PMED1 ");
  354. }
  355. if (pmc.Support.PMED2) {
  356. dprintf("PMED2 ");
  357. }
  358. if (pmc.Support.PMED3Hot) {
  359. dprintf("PMED3Hot ");
  360. }
  361. if (pmc.Support.PMED3Cold) {
  362. dprintf("PMED3Cold ");
  363. }
  364. dprintf("Version=%lx\n", pmc.Version);
  365. }
  366. BOOL
  367. PrintPciPowerManagement(
  368. PCHAR pData,
  369. PCHAR Pad
  370. )
  371. {
  372. PPCI_PM_CAPABILITY pPmC;
  373. int i;
  374. pPmC = (PPCI_PM_CAPABILITY) pData;
  375. if (!Pad) {
  376. Pad = "";
  377. }
  378. dprintf("%sPwrMgmtCap ", Pad);
  379. PrintPciPwrMgmtCaps(pPmC->PMC.AsUSHORT);
  380. dprintf("%sPwrMgmtCtrl ", Pad);
  381. PCI_PMCSR CtrlStatus = pPmC->PMCSR.ControlStatus;
  382. if (CtrlStatus.PMEEnable) {
  383. dprintf("PMEEnable ");
  384. }
  385. if (CtrlStatus.PMEStatus) {
  386. dprintf("PMESTAT ");
  387. }
  388. dprintf("DataScale:%lx ", CtrlStatus.DataScale);
  389. dprintf("DataSel:%lx ", CtrlStatus.DataSelect);
  390. dprintf("D%lx%s", CtrlStatus.PowerState, (CtrlStatus.PowerState == 3) ? "Hot " : " ");
  391. dprintf("\n");
  392. dprintf("%sPwrMgmtBridge ", Pad);
  393. if (pPmC->PMCSR_BSE.BridgeSupport.D3HotSupportsStopClock) {
  394. dprintf("D3HotStopClock ");
  395. }
  396. if (pPmC->PMCSR_BSE.BridgeSupport.BusPowerClockControlEnabled) {
  397. dprintf("BPCCEnable ");
  398. }
  399. dprintf("\n");
  400. return TRUE;
  401. }
  402. BOOL
  403. PrintPciAGP(
  404. PCHAR pData,
  405. PCHAR Pad
  406. )
  407. {
  408. PPCI_AGP_CAPABILITY pAGP;
  409. int i;
  410. pAGP = (PPCI_AGP_CAPABILITY) pData;
  411. if (!Pad) {
  412. Pad = "";
  413. }
  414. dprintf("%sVersion Major %lx, Minor %lx\n",
  415. Pad,
  416. pAGP->Major,
  417. pAGP->Minor);
  418. dprintf("%sStatus MaxRQDepth:%lx",
  419. Pad,
  420. pAGP->AGPStatus.RequestQueueDepthMaximum);
  421. if (pAGP->AGPStatus.SideBandAddressing) {
  422. dprintf(" SBA");
  423. }
  424. dprintf(" Rate:%lx\n", pAGP->AGPStatus.Rate);
  425. dprintf("%sCommand ", Pad);
  426. if (pAGP->AGPCommand.SBAEnable) {
  427. dprintf("SBAEnable ");
  428. }
  429. if (pAGP->AGPCommand.AGPEnable) {
  430. dprintf("AGPEnable ");
  431. }
  432. dprintf("RQDepth:%lx ", pAGP->AGPCommand.RequestQueueDepth);
  433. dprintf("Rate:%lx ", pAGP->AGPCommand.Rate);
  434. dprintf("\n");
  435. return TRUE;
  436. }
  437. BOOL
  438. PrintPciMSICaps(
  439. PCHAR pData,
  440. PCHAR Pad
  441. )
  442. {
  443. PPCI_PCI_CAPABILITY pMsiCap;
  444. pMsiCap = (PPCI_PCI_CAPABILITY) pData;
  445. if (!Pad) {
  446. Pad = "";
  447. }
  448. dprintf("%sMsgCtrl ", Pad);
  449. if (pMsiCap->MessageControl.CapableOf64Bits) {
  450. dprintf("64BitCapable ");
  451. }
  452. if (pMsiCap->MessageControl.MSIEnable) {
  453. dprintf("MSIEnable ");
  454. }
  455. dprintf("MultipleMsgEnable:%lx ", pMsiCap->MessageControl.MultipleMessageEnable);
  456. dprintf("MultipleMsgCapable:%lx ", pMsiCap->MessageControl.MultipleMessageCapable);
  457. dprintf("%sMsgAddr %lx\n", Pad, pMsiCap->MessageAddress.Raw);
  458. if (pMsiCap->MessageControl.CapableOf64Bits) {
  459. dprintf("%sMsgAddrHi %lx\n", pMsiCap->Data.Bit64.MessageUpperAddress);
  460. dprintf("%sMsData %lx\n", pMsiCap->Data.Bit64.MessageData);
  461. } else {
  462. dprintf("%sMsData %lx\n", pMsiCap->Data.Bit32.MessageData);
  463. }
  464. return TRUE;
  465. }
  466. /*** CardBus Registers
  467. */
  468. void
  469. PrintCBSktEventReg(
  470. UCHAR Register
  471. )
  472. {
  473. dprintf("%lx ", Register);
  474. if (Register & SKTEVENT_CSTSCHG) {
  475. dprintf("CSTSCHG ");
  476. }
  477. if (Register & SKTEVENT_CCD1) {
  478. dprintf("/CCD1 ");
  479. }
  480. if (Register & SKTEVENT_CCD2) {
  481. dprintf("/CCD2 ");
  482. }
  483. if (Register & SKTEVENT_POWERCYCLE) {
  484. dprintf("PowerCycle ");
  485. }
  486. }
  487. //Socket Mask Register
  488. void
  489. PrintCBSktMaskReg(
  490. UCHAR Register
  491. )
  492. {
  493. dprintf("%lx ", Register);
  494. if (Register & SKTMSK_POWERCYCLE) {
  495. dprintf("PowerCycle ");
  496. }
  497. if (Register & SKTMSK_CSTSCHG) {
  498. dprintf("CSTSCHG ");
  499. }
  500. if ((Register & SKTMSK_CCD) == 0) {
  501. dprintf("CSCDisabled ");
  502. } else if ((Register & SKTMSK_CCD) == SKTMSK_CCD) {
  503. dprintf("CSCEnabled ");
  504. } else {
  505. dprintf("Undefined ");
  506. }
  507. }
  508. //Socket Present State Register
  509. void
  510. PrintCBSktStateReg(
  511. ULONG Register
  512. )
  513. {
  514. dprintf("%08lx ", Register);
  515. if (Register & SKTSTATE_CSTSCHG) {
  516. dprintf("CSTSCHG ");
  517. }
  518. if (Register & SKTSTATE_POWERCYCLE) {
  519. dprintf("PowerCycle ");
  520. }
  521. if (Register & SKTSTATE_CARDTYPE_MASK) {
  522. dprintf("");
  523. }
  524. if (Register & SKTSTATE_R2CARD) {
  525. dprintf("R2Card ");
  526. }
  527. if (Register & SKTSTATE_CBCARD) {
  528. dprintf("CBCard ");
  529. }
  530. if (Register & SKTSTATE_OPTI_DOCK) {
  531. dprintf("OptiDock ");
  532. }
  533. if (Register & SKTSTATE_CARDINT) {
  534. dprintf("CardInt ");
  535. }
  536. if (Register & SKTSTATE_NOTACARD) {
  537. dprintf("NotACard ");
  538. }
  539. if (Register & SKTSTATE_DATALOST) {
  540. dprintf("DataLoss ");
  541. }
  542. if (Register & SKTSTATE_BADVCCREQ) {
  543. dprintf("BadVccReq ");
  544. }
  545. if (Register & SKTSTATE_5VCARD) {
  546. dprintf("5VCard ");
  547. }
  548. if (Register & SKTSTATE_3VCARD) {
  549. dprintf("3VCard ");
  550. }
  551. if (Register & SKTSTATE_XVCARD) {
  552. dprintf("XVCard ");
  553. }
  554. if (Register & SKTSTATE_YVCARD) {
  555. dprintf("YVCard ");
  556. }
  557. if (Register & SKTSTATE_5VSOCKET) {
  558. dprintf("5VSkt ");
  559. }
  560. if (Register & SKTSTATE_3VSOCKET) {
  561. dprintf("3VSkt ");
  562. }
  563. if (Register & SKTSTATE_XVSOCKET) {
  564. dprintf("XVSkt ");
  565. }
  566. if (Register & SKTSTATE_YVSOCKET) {
  567. dprintf("YVSkt ");
  568. }
  569. if ((Register & SKTSTATE_CCD_MASK) == 0) {
  570. dprintf("CardPresent ");
  571. } else if ((Register & SKTSTATE_CCD_MASK) == SKTSTATE_CCD_MASK) {
  572. dprintf("NoCard ");
  573. } else {
  574. dprintf("CardMayPresent ");
  575. }
  576. }
  577. //Socket Control Register
  578. void PrintCBSktCtrlReg(
  579. ULONG Register
  580. )
  581. {
  582. ULONG Ctrl;
  583. dprintf("%08lx ", Register);
  584. Ctrl = Register & SKTPOWER_VPP_CONTROL;
  585. dprintf("Vpp:");
  586. switch (Ctrl) {
  587. case SKTPOWER_VPP_OFF:
  588. dprintf("Off");
  589. break;
  590. case SKTPOWER_VPP_120V:
  591. dprintf("12V");
  592. break;
  593. case SKTPOWER_VPP_050V:
  594. dprintf("5V");
  595. break;
  596. case SKTPOWER_VPP_033V:
  597. dprintf("3.3V");
  598. break;
  599. case SKTPOWER_VPP_0XXV:
  600. dprintf("X.XV");
  601. break;
  602. case SKTPOWER_VPP_0YYV:
  603. dprintf("Y.YV");
  604. break;
  605. }
  606. dprintf(" Vcc:");
  607. switch (Register & SKTPOWER_VCC_CONTROL) {
  608. case SKTPOWER_VCC_OFF:
  609. dprintf("Off");
  610. break;
  611. case SKTPOWER_VCC_050V:
  612. dprintf("5V");
  613. break;
  614. case SKTPOWER_VCC_033V:
  615. dprintf("3.3V");
  616. break;
  617. case SKTPOWER_VCC_0XXV:
  618. dprintf("X.XV");
  619. break;
  620. case SKTPOWER_VCC_0YYV:
  621. dprintf("Y.YV");
  622. break;
  623. }
  624. if (Register & SKTPOWER_STOPCLOCK) {
  625. dprintf(" ClockStopEnabled ");
  626. }
  627. }
  628. BOOL
  629. PrintCBRegs(
  630. PCHAR pData,
  631. PCHAR Pad
  632. )
  633. {
  634. ULONG Off=0;
  635. dprintf("%s%02lx: SktEvent ", Pad, Off);
  636. PrintCBSktEventReg(*pData);
  637. dprintf("\n");
  638. pData+=4; Off+=4;
  639. dprintf("%s%02lx: SktMask ", Pad, Off);
  640. PrintCBSktMaskReg(*pData);
  641. dprintf("\n");
  642. pData+=4; Off+=4;
  643. dprintf("%s%02lx: SktState ", Pad, Off);
  644. PrintCBSktStateReg(*((PULONG)pData));
  645. dprintf("\n");
  646. pData+=4; Off+=4;
  647. dprintf("%s%02lx: SktForce %08lx\n", Pad, Off, *((PULONG)pData));
  648. pData+=4; Off+=4;
  649. dprintf("%s%02lx: SktCtrl ", Pad, Off);
  650. PrintCBSktEventReg(*(pData));
  651. dprintf("\n");
  652. return FALSE;
  653. }
  654. /*** ExCA Registers
  655. */
  656. void
  657. PrintExCARegs(
  658. PEXCAREGS pExCARegs
  659. )
  660. {
  661. struct _MEMWIN_EXCA {
  662. USHORT Start;
  663. USHORT Stop;
  664. USHORT Offset;
  665. USHORT Reserved;
  666. } MemWin, *pMemWin;
  667. dprintf("%02lx: IDRev %02lx", FIELD_OFFSET(EXCAREGS, bIDRev),pExCARegs->bIDRev);
  668. if ((pExCARegs->bIDRev & IDREV_IFID_MASK) == IDREV_IFID_IO) {
  669. dprintf(" IOOnly");
  670. }
  671. else if ((pExCARegs->bIDRev & IDREV_IFID_MASK) == IDREV_IFID_MEM) {
  672. dprintf(" MemOnly");
  673. } else if ((pExCARegs->bIDRev & IDREV_IFID_MASK) == IDREV_IFID_IOMEM) {
  674. dprintf(" IO&Mem");
  675. }
  676. dprintf(" Rev: %02lx\n", pExCARegs->bIDRev & IDREV_REV_MASK);
  677. dprintf("%02lx: IFStatus %02lx",
  678. FIELD_OFFSET(EXCAREGS, bInterfaceStatus),
  679. pExCARegs->bInterfaceStatus);
  680. if (pExCARegs->bInterfaceStatus & IFS_BVD1) {
  681. dprintf(" BVD1");
  682. }
  683. if (pExCARegs->bInterfaceStatus & IFS_BVD2) {
  684. dprintf(" BVD2");
  685. }
  686. if (pExCARegs->bInterfaceStatus & IFS_CD1) {
  687. dprintf(" CD1");
  688. }
  689. if (pExCARegs->bInterfaceStatus & IFS_CD2) {
  690. dprintf(" CD2");
  691. }
  692. if (pExCARegs->bInterfaceStatus & IFS_WP) {
  693. dprintf(" WP");
  694. }
  695. if (pExCARegs->bInterfaceStatus & IFS_RDYBSY) {
  696. dprintf(" Ready");
  697. }
  698. if (pExCARegs->bInterfaceStatus & IFS_CARDPWR_ACTIVE) {
  699. dprintf(" PowerActive");
  700. }
  701. if (pExCARegs->bInterfaceStatus & IFS_VPP_VALID) {
  702. dprintf(" VppValid");
  703. }
  704. dprintf("\n");
  705. dprintf("%02lx: PwrCtrl %02lx", FIELD_OFFSET(EXCAREGS, bPowerControl), pExCARegs->bPowerControl);
  706. dprintf(" Vpp1=");
  707. switch (pExCARegs->bPowerControl & PC_VPP1_MASK) {
  708. case PC_VPP_NO_CONNECT:
  709. dprintf("Off");
  710. break;
  711. case PC_VPP_SETTO_VCC:
  712. dprintf("Vcc");
  713. break;
  714. case PC_VPP_SETTO_VPP:
  715. dprintf("Vpp");
  716. break;
  717. }
  718. dprintf(" Vpp2=");
  719. switch ((pExCARegs->bPowerControl & PC_VPP2_MASK) >> 4) {
  720. case PC_VPP_NO_CONNECT:
  721. dprintf("Off");
  722. break;
  723. case PC_VPP_SETTO_VCC:
  724. dprintf("Vcc");
  725. break;
  726. case PC_VPP_SETTO_VPP:
  727. dprintf("Vpp");
  728. break;
  729. }
  730. if (pExCARegs->bPowerControl & PC_CARDPWR_ENABLE) {
  731. dprintf(" PwrEnable");
  732. }
  733. if (pExCARegs->bPowerControl & PC_AUTOPWR_ENABLE) {
  734. dprintf(" AutoPwrEnabled");
  735. }
  736. if (pExCARegs->bPowerControl & PC_RESETDRV_DISABLE) {
  737. dprintf(" RESETDRVDisabled");
  738. }
  739. if (pExCARegs->bPowerControl & PC_OUTPUT_ENABLE) {
  740. dprintf(" OutputEnable");
  741. }
  742. dprintf("\n");
  743. dprintf("%02lx: IntGenCtrl %02lx",
  744. FIELD_OFFSET(EXCAREGS, bIntGenControl),
  745. pExCARegs->bIntGenControl);
  746. switch (pExCARegs->bIntGenControl & ~IGC_IRQ_MASK) {
  747. case IGC_INTR_ENABLE:
  748. dprintf(" INTREnable");
  749. break;
  750. case IGC_PCCARD_IO:
  751. dprintf(" IOCard");
  752. break;
  753. case IGC_PCCARD_RESETLO:
  754. dprintf(" ResetOff");
  755. break;
  756. case IGC_RINGIND_ENABLE:
  757. dprintf(" RingIndEnable");
  758. break;
  759. }
  760. dprintf(" CardIRQ:%lx\n", pExCARegs->bIntGenControl & IGC_IRQ_MASK);
  761. dprintf("%02lx: CardStatChange %02lx", FIELD_OFFSET(EXCAREGS, bCardStatusChange), pExCARegs->bCardStatusChange);
  762. if (pExCARegs->bCardStatusChange & CSC_BATT_DEAD) {
  763. dprintf(" BATTDEAD");
  764. }
  765. if (pExCARegs->bCardStatusChange & CSC_BATT_WARNING) {
  766. dprintf(" BATTWARN");
  767. }
  768. if (pExCARegs->bCardStatusChange & CSC_READY_CHANGE) {
  769. dprintf(" RDYC");
  770. }
  771. if (pExCARegs->bCardStatusChange & CSC_CD_CHANGE) {
  772. dprintf(" CDC");
  773. }
  774. dprintf("\n");
  775. dprintf("%02lx: IntConfig %02lx",
  776. FIELD_OFFSET(EXCAREGS, bCardStatusIntConfig),
  777. pExCARegs->bCardStatusIntConfig);
  778. if (pExCARegs->bCardStatusIntConfig & CSCFG_BATT_DEAD) {
  779. dprintf(" BattDeadEnable");
  780. }
  781. if (pExCARegs->bCardStatusIntConfig & CSCFG_BATT_WARNING) {
  782. dprintf(" BattWarnEnable");
  783. }
  784. if (pExCARegs->bCardStatusIntConfig & CSCFG_READY_ENABLE) {
  785. dprintf(" RDYEnable");
  786. }
  787. if (pExCARegs->bCardStatusIntConfig & CSCFG_CD_ENABLE) {
  788. dprintf(" CDEnable");
  789. }
  790. dprintf(" CSCIRQ:%lx\n",(pExCARegs->bCardStatusIntConfig & CSCFG_IRQ_MASK));
  791. dprintf("%02lx: WinEnable %02lx",
  792. FIELD_OFFSET(EXCAREGS, bWindowEnable),
  793. pExCARegs->bWindowEnable);
  794. if (pExCARegs->bWindowEnable & WE_MEM0_ENABLE) {
  795. dprintf(" Mem0Enable");
  796. }
  797. if (pExCARegs->bWindowEnable & WE_MEM1_ENABLE) {
  798. dprintf(" Mem1Enable");
  799. }
  800. if (pExCARegs->bWindowEnable & WE_MEM2_ENABLE) {
  801. dprintf(" Mem2Enable");
  802. }
  803. if (pExCARegs->bWindowEnable & WE_MEM3_ENABLE) {
  804. dprintf(" Mem3Enable");
  805. }
  806. if (pExCARegs->bWindowEnable & WE_MEM4_ENABLE) {
  807. dprintf(" Mem4Enable");
  808. }
  809. if (pExCARegs->bWindowEnable & WE_MEMCS16_DECODE) {
  810. dprintf(" DecodeA23-A12");
  811. }
  812. if (pExCARegs->bWindowEnable & WE_IO0_ENABLE) {
  813. dprintf(" IO0Enable");
  814. }
  815. if (pExCARegs->bWindowEnable & WE_IO1_ENABLE) {
  816. dprintf(" IO1Enable");
  817. }
  818. dprintf("\n");
  819. dprintf("%02lx: IOWinCtrl %02lx",
  820. FIELD_OFFSET(EXCAREGS, bIOControl),
  821. pExCARegs->bIOControl);
  822. if (pExCARegs->bIOControl & IOC_IO0_DATASIZE) {
  823. dprintf(" IO0CardIOCS");
  824. }
  825. if (pExCARegs->bIOControl & IOC_IO0_IOCS16) {
  826. dprintf(" IO016Bit");
  827. }
  828. if (pExCARegs->bIOControl & IOC_IO0_ZEROWS) {
  829. dprintf(" IO0ZeroWS");
  830. }
  831. if (pExCARegs->bIOControl & IOC_IO0_WAITSTATE) {
  832. dprintf(" IO0WS");
  833. }
  834. if (pExCARegs->bIOControl & IOC_IO1_DATASIZE) {
  835. dprintf(" IO1CardIOCS");
  836. }
  837. if (pExCARegs->bIOControl & IOC_IO1_IOCS16) {
  838. dprintf(" IO116Bit");
  839. }
  840. if (pExCARegs->bIOControl & IOC_IO1_ZEROWS) {
  841. dprintf(" IO1ZeroWS");
  842. }
  843. if (pExCARegs->bIOControl & IOC_IO1_WAITSTATE) {
  844. dprintf(" IO1WS");
  845. }
  846. dprintf("\n");
  847. dprintf("%02lx: IOWin0Start %02lx %02lx\n",
  848. FIELD_OFFSET(EXCAREGS, bIO0StartLo),
  849. pExCARegs->bIO0StartHi, pExCARegs->bIO0StartLo);
  850. dprintf("%02lx: IOWin0Stop %02lx %02lx\n",
  851. FIELD_OFFSET(EXCAREGS, bIO0StopLo),
  852. pExCARegs->bIO0StopHi, pExCARegs->bIO0StopLo);
  853. dprintf("%02lx: IOWin1Start %02lx %02lx\n",
  854. FIELD_OFFSET(EXCAREGS, bIO1StartLo),
  855. pExCARegs->bIO1StartHi, pExCARegs->bIO1StartLo);
  856. dprintf("%02lx: IOWin1Stop %02lx %02lx\n",
  857. FIELD_OFFSET(EXCAREGS, bIO1StopLo),
  858. pExCARegs->bIO1StopHi, pExCARegs->bIO1StopLo);
  859. pMemWin = (struct _MEMWIN_EXCA*) &pExCARegs->bMem0StartLo;
  860. for (int i=0;
  861. i<5;
  862. i++, pMemWin++) {
  863. dprintf("%02lx: MemWin%lxStart %04lx",
  864. FIELD_OFFSET(EXCAREGS, bMem0StartLo) + i*sizeof(_MEMWIN_EXCA),
  865. i, pMemWin->Start & MEMBASE_ADDR_MASK);
  866. if (pMemWin->Start & MEMBASE_ZEROWS) {
  867. dprintf(" ZeroWs");
  868. } else if (pMemWin->Start & MEMBASE_16BIT) {
  869. dprintf(" 16Bit");
  870. }
  871. dprintf("\n");
  872. dprintf("%02lx: MemWin%lxStop %04lx, WaitState:%lx\n",
  873. FIELD_OFFSET(EXCAREGS, bMem0StopLo) + i*sizeof(_MEMWIN_EXCA),
  874. i,
  875. (pMemWin->Stop & MEMEND_ADDR_MASK),
  876. (pMemWin->Stop & MEMEND_WS_MASK));
  877. dprintf("%02lx: MemWin%lxOffset %04lx %s%s\n",
  878. FIELD_OFFSET(EXCAREGS, bMem0OffsetLo) + i*sizeof(_MEMWIN_EXCA),
  879. i,
  880. (pMemWin->Offset & MEMOFF_ADDR_MASK),
  881. ((pMemWin->Offset & MEMOFF_REG_ACTIVE) ? " RegActive" : ""),
  882. ((pMemWin->Offset & MEMOFF_WP) ? " WP" : "")
  883. );
  884. }
  885. }
  886. void
  887. PrintExCAHiRegs(
  888. PUCHAR pExCaReg,
  889. PCHAR Pad
  890. )
  891. {
  892. ULONG Off = sizeof(EXCAREGS);
  893. dprintf("%s%02lx: MemWin0High %02lx\n", Pad, Off++, *(pExCaReg++));
  894. dprintf("%s%02lx: MemWin1High %02lx\n", Pad, Off++, *(pExCaReg++));
  895. dprintf("%s%02lx: MemWin2High %02lx\n", Pad, Off++, *(pExCaReg++));
  896. dprintf("%s%02lx: MemWin3High %02lx\n", Pad, Off++, *(pExCaReg++));
  897. dprintf("%s%02lx: MemWin4High %02lx\n", Pad, Off++, *(pExCaReg++));
  898. dprintf("%s%02lx: CLIOWin0High %02lx\n", Pad, Off++, *(pExCaReg++));
  899. dprintf("%s%02lx: CLIOWin1High %02lx\n", Pad, Off++, *(pExCaReg++));
  900. }
  901. /***LP ReadExCAByte - Read ExCA byte register
  902. *
  903. * ENTRY
  904. * dwBaseAddr - Base port address
  905. * dwReg - register offset
  906. *
  907. * EXIT
  908. * returns data read
  909. */
  910. BYTE ReadExCAByte(ULONG64 dwBaseAddr, DWORD dwReg)
  911. {
  912. BYTE bData=0;
  913. ULONG ulSize;
  914. ulSize = sizeof(BYTE);
  915. WriteIoSpace64(dwBaseAddr, dwReg, &ulSize);
  916. ulSize = sizeof(BYTE);
  917. ReadIoSpace64(dwBaseAddr + 1, (PULONG)&bData, &ulSize);
  918. return bData;
  919. } //ReadExCAByte
  920. /***LP GetClassDesc - Get class description string
  921. *
  922. * ENTRY
  923. * bBaseClass - Base Class code
  924. * bSubClass - Sub Class code
  925. * bProgIF - Program Interface code
  926. *
  927. * EXIT-SUCCESS
  928. * returns pointer to description string
  929. * EXIT-FAILURE
  930. * returns NULL
  931. */
  932. PSZ GetClassDesc(BYTE bBaseClass, BYTE bSubClass, BYTE bProgIF)
  933. {
  934. char *psz = NULL;
  935. int i;
  936. static struct classtab_s
  937. {
  938. BYTE bBaseClass;
  939. BYTE bSubClass;
  940. BYTE bProgIF;
  941. PSZ pszDesc;
  942. } ClassTable[] =
  943. {
  944. {0x00, 0xff, 0xff, "Legacy controller"},
  945. {0x00, 0x00, 0x00, "All legacy controller except VGA"},
  946. {0x00, 0x01, 0x00, "All legacy VGA device"},
  947. {0x01, 0xff, 0xff, "Mass storage controller"},
  948. {0x01, 0x00, 0x00, "SCSI bus controller"},
  949. {0x01, 0x01, 0xff, "IDE controller"},
  950. {0x01, 0x02, 0x00, "Floppy disk controller"},
  951. {0x01, 0x03, 0x00, "IPI bus controller"},
  952. {0x01, 0x04, 0x00, "RAID controller"},
  953. {0x01, 0x80, 0x00, "Other mass storage controller"},
  954. {0x02, 0xff, 0xff, "Network controller"},
  955. {0x02, 0x00, 0x00, "Ethernet controller"},
  956. {0x02, 0x01, 0x00, "Token ring controller"},
  957. {0x02, 0x02, 0x00, "FDDI controller"},
  958. {0x02, 0x03, 0x00, "ATM controller"},
  959. {0x02, 0x80, 0x00, "Other network controller"},
  960. {0x03, 0xff, 0xff, "Display controller"},
  961. {0x03, 0x00, 0x00, "VGA compatible controller"},
  962. {0x03, 0x00, 0x01, "8514 compatible controller"},
  963. {0x03, 0x01, 0x00, "XGA controller"},
  964. {0x03, 0x80, 0x00, "Other display controller"},
  965. {0x04, 0xff, 0xff, "Multimedia device"},
  966. {0x04, 0x00, 0x00, "Video device"},
  967. {0x04, 0x01, 0x00, "Audio device"},
  968. {0x04, 0x80, 0x00, "Other multimedia device"},
  969. {0x05, 0xff, 0xff, "Memory controller"},
  970. {0x05, 0x00, 0x00, "RAM controller"},
  971. {0x05, 0x01, 0x00, "Flash controller"},
  972. {0x05, 0x80, 0x00, "Other memory controller"},
  973. {0x06, 0xff, 0xff, "Bridge device"},
  974. {0x06, 0x00, 0x00, "Host bridge"},
  975. {0x06, 0x01, 0x00, "ISA bridge"},
  976. {0x06, 0x02, 0x00, "EISA bridge"},
  977. {0x06, 0x03, 0x00, "MCA bridge"},
  978. {0x06, 0x04, 0x00, "PCI-PCI bridge"},
  979. {0x06, 0x05, 0x00, "PCMCIA bridge"},
  980. {0x06, 0x06, 0x00, "NuBus bridge"},
  981. {0x06, 0x07, 0x00, "CardBus bridge"},
  982. {0x06, 0x80, 0x00, "Other bridge device"},
  983. {0x07, 0xff, 0xff, "Simple com device"},
  984. {0x07, 0x00, 0x00, "Generic XT compatible serial controller"},
  985. {0x07, 0x00, 0x01, "16450 compatible serial controller"},
  986. {0x07, 0x00, 0x02, "16550 compatible serial controller"},
  987. {0x07, 0x01, 0x00, "Parallel port"},
  988. {0x07, 0x01, 0x01, "Bidirectional parallel port"},
  989. {0x07, 0x01, 0x02, "ECP 1.X compliant parallel port"},
  990. {0x07, 0x80, 0x00, "Other communication device"},
  991. {0x08, 0xff, 0xff, "Base system peripherals"},
  992. {0x08, 0x00, 0x00, "Generic 8259 PIC"},
  993. {0x08, 0x00, 0x01, "ISA PIC"},
  994. {0x08, 0x00, 0x02, "EISA PIC"},
  995. {0x08, 0x01, 0x00, "Generic 8237 DMA controller"},
  996. {0x08, 0x01, 0x01, "ISA DMA controller"},
  997. {0x08, 0x01, 0x02, "EISA DMA controller"},
  998. {0x08, 0x02, 0x00, "Generic 8254 system timer"},
  999. {0x08, 0x02, 0x01, "ISA system timer"},
  1000. {0x08, 0x02, 0x02, "EISA system timer"},
  1001. {0x08, 0x03, 0x00, "Generic RTC controller"},
  1002. {0x08, 0x03, 0x01, "ISA RTC controller"},
  1003. {0x08, 0x80, 0x00, "Other system peripheral"},
  1004. {0x09, 0xff, 0xff, "Input device"},
  1005. {0x09, 0x00, 0x00, "Keyboard controller"},
  1006. {0x09, 0x01, 0x00, "Digitizer (pen)"},
  1007. {0x09, 0x02, 0x00, "Mouse controller"},
  1008. {0x09, 0x80, 0x00, "Other input controller"},
  1009. {0x0a, 0xff, 0xff, "Docking station"},
  1010. {0x0a, 0x00, 0x00, "Generic docking station"},
  1011. {0x0a, 0x80, 0x00, "Other type of docking station"},
  1012. {0x0b, 0xff, 0xff, "Processor"},
  1013. {0x0b, 0x00, 0x00, "386"},
  1014. {0x0b, 0x01, 0x00, "486"},
  1015. {0x0b, 0x02, 0x00, "Pentium"},
  1016. {0x0b, 0x10, 0x00, "Alpha"},
  1017. {0x0b, 0x20, 0x00, "PowerPC"},
  1018. {0x0b, 0x40, 0x00, "Co-processor"},
  1019. {0x0c, 0xff, 0xff, "Serial bus controller"},
  1020. {0x0c, 0x00, 0x00, "FireWire (IEEE 1394)"},
  1021. {0x0c, 0x01, 0x00, "ACCESS bus"},
  1022. {0x0c, 0x02, 0x00, "SSA"},
  1023. {0x0c, 0x03, 0x00, "Universal Serial Bus (USB)"},
  1024. {0x0c, 0x04, 0x00, "Fibre Channel"},
  1025. {0xff, 0xff, 0xff, "Unknown"},
  1026. {0x00, 0x00, 0x00, NULL}
  1027. };
  1028. for (i = 0; ClassTable[i].pszDesc != NULL; ++i)
  1029. {
  1030. if ((ClassTable[i].bBaseClass == bBaseClass) &&
  1031. (ClassTable[i].bSubClass == bSubClass) &&
  1032. (ClassTable[i].bProgIF == bProgIF))
  1033. {
  1034. psz = ClassTable[i].pszDesc;
  1035. }
  1036. }
  1037. return psz;
  1038. } //GetClassDesc
  1039. /***LP PrintClassInfo - Print device class info.
  1040. *
  1041. * ENTRY
  1042. * pb -> ConfigSpace
  1043. * dwReg - ConfigSpace register
  1044. *
  1045. * EXIT
  1046. * None
  1047. */
  1048. VOID PrintClassInfo(PBYTE pb, DWORD dwReg)
  1049. {
  1050. PPCI_COMMON_CONFIG pcc = (PPCI_COMMON_CONFIG) pb;
  1051. BYTE bBaseClass, bSubClass, bProgIF;
  1052. PSZ psz;
  1053. if (dwReg == FIELD_OFFSET(PCI_COMMON_CONFIG ,BaseClass))
  1054. {
  1055. bBaseClass = pcc->BaseClass;
  1056. bSubClass = 0xff;
  1057. bProgIF = 0xff;
  1058. }
  1059. else if (dwReg == FIELD_OFFSET(PCI_COMMON_CONFIG ,SubClass))
  1060. {
  1061. bBaseClass = pcc->BaseClass;
  1062. bSubClass = pcc->SubClass;
  1063. bProgIF = 0xff;
  1064. }
  1065. else //must be CFGSPACE_CLASSCODE_PI
  1066. {
  1067. bBaseClass = pcc->BaseClass;
  1068. bSubClass = pcc->SubClass;
  1069. bProgIF = pcc->ProgIf;
  1070. }
  1071. if ((psz = GetClassDesc(bBaseClass, bSubClass, bProgIF)) != NULL)
  1072. dprintf(" (%s)", psz);
  1073. else if ((bBaseClass == 0x01) && (bSubClass == 0x01) && (bProgIF != 0xff) &&
  1074. (bProgIF != 0x00))
  1075. {
  1076. dprintf(" (");
  1077. if (bProgIF & 0x80)
  1078. dprintf("MasterIDE ");
  1079. if (bProgIF & 0x02)
  1080. dprintf("PriNativeCapable ");
  1081. if (bProgIF & 0x01)
  1082. dprintf("PriNativeMode ");
  1083. if (bProgIF & 0x08)
  1084. dprintf("SecNativeCapable ");
  1085. if (bProgIF & 0x04)
  1086. dprintf("SecNativeMode");
  1087. dprintf(")");
  1088. }
  1089. dprintf("\n");
  1090. } //PrintClassInfo
  1091. VOID
  1092. DumpCfgSpace (
  1093. IN PPCI_COMMON_CONFIG pcs
  1094. )
  1095. {
  1096. BYTE bHeaderType = pcs->HeaderType & ~PCI_MULTIFUNCTION;
  1097. DWORD dwOffset;
  1098. PSZ pszDataFmt = "%02x: ";
  1099. dwOffset = 0;
  1100. if (PrintCommonConfigSpace(pcs, " ")) {
  1101. switch (bHeaderType)
  1102. {
  1103. case PCI_DEVICE_TYPE:
  1104. dprintf(" DeviceType (@%02lx):\n", FIELD_OFFSET(PCI_COMMON_CONFIG,u));
  1105. PrintCfgSpaceType0(pcs, " ");
  1106. break;
  1107. case PCI_BRIDGE_TYPE:
  1108. dprintf(" BridgeType (@%02lx):\n", FIELD_OFFSET(PCI_COMMON_CONFIG,u));
  1109. PrintCfgSpaceType1(pcs, " ");
  1110. break;
  1111. case PCI_CARDBUS_BRIDGE_TYPE:
  1112. dprintf(" CardBusBridgeType (@%02lx):\n", FIELD_OFFSET(PCI_COMMON_CONFIG,u));
  1113. PrintCfgSpaceType2(pcs, " ");
  1114. break;
  1115. default:
  1116. dprintf(" TypeUnknown:\n");
  1117. PrintDataRange((PCHAR) &pcs->u, 12, FIELD_OFFSET(PCI_COMMON_CONFIG, u), " ");
  1118. }
  1119. if ((pcs->Status & PCI_STATUS_CAPABILITIES_LIST)) {
  1120. if (bHeaderType == PCI_DEVICE_TYPE) {
  1121. dwOffset = pcs->u.type0.CapabilitiesPtr;
  1122. }
  1123. else if (bHeaderType == PCI_BRIDGE_TYPE) {
  1124. dwOffset = pcs->u.type1.CapabilitiesPtr;
  1125. }
  1126. else if (bHeaderType == PCI_CARDBUS_BRIDGE_TYPE) {
  1127. dwOffset = pcs->u.type2.CapabilitiesPtr;
  1128. }
  1129. else {
  1130. dwOffset = 0;
  1131. }
  1132. dprintf(" Capabilities (@%02lx):\n", dwOffset);
  1133. while ((dwOffset != 0)) {
  1134. PPCI_CAPABILITIES_HEADER pCap;
  1135. pCap = (PPCI_CAPABILITIES_HEADER)&((PBYTE)pcs)[dwOffset];
  1136. if (PrintPciCapHeader(pCap, " ")) {
  1137. switch (pCap->CapabilityID) {
  1138. case PCI_CAPABILITY_ID_POWER_MANAGEMENT:
  1139. PrintPciPowerManagement(((PCHAR)pCap), " ");
  1140. break;
  1141. case PCI_CAPABILITY_ID_AGP:
  1142. PrintPciAGP(((PCHAR)pCap), " ");
  1143. break;
  1144. case PCI_CAPABILITY_ID_MSI:
  1145. PrintPciMSICaps(((PCHAR)pCap), " ");
  1146. break;
  1147. }
  1148. dwOffset = pCap->Next;
  1149. } else {
  1150. break;
  1151. }
  1152. }
  1153. }
  1154. }
  1155. PrintDataRange((PCHAR) pcs, sizeof(PCI_COMMON_CONFIG)/4, 0, " ");
  1156. }
  1157. /***LP DumpCBRegs - Dump CardBus registers
  1158. *
  1159. * ENTRY
  1160. * pbBuff -> register base
  1161. *
  1162. * EXIT
  1163. * None
  1164. */
  1165. VOID DumpCBRegs(PBYTE pbBuff)
  1166. {
  1167. PrintCBRegs((PCHAR) pbBuff, "");
  1168. } //DumpCBRegs
  1169. /***LP DumpExCARegs - Dump ExCA registers
  1170. *
  1171. * ENTRY
  1172. * pbBuff -> buffer
  1173. * dwSize - size of buffer
  1174. *
  1175. * EXIT
  1176. * None
  1177. */
  1178. VOID DumpExCARegs(PBYTE pbBuff, DWORD dwSize)
  1179. {
  1180. DWORD dwOffset = 0;
  1181. char *pszDataFmt = "%02x: ";
  1182. PrintExCARegs((PEXCAREGS) pbBuff);
  1183. PrintExCAHiRegs(pbBuff + sizeof(EXCAREGS), "");
  1184. } //DumpExCARegs
  1185. DECLARE_API( dcs )
  1186. /*++
  1187. Routine Description:
  1188. Dumps PCI ConfigSpace
  1189. Arguments:
  1190. args - Supplies the Bus.Dev.Fn numbers
  1191. Return Value:
  1192. None
  1193. --*/
  1194. {
  1195. LONG lcArgs;
  1196. DWORD dwBus = 0;
  1197. DWORD dwDev = 0;
  1198. DWORD dwFn = 0;
  1199. lcArgs = sscanf(args, "%lx.%lx.%lx", &dwBus, &dwDev, &dwFn);
  1200. dprintf("!dcs now integrated into !pci 1xx (flag 100).\n"
  1201. "Use !pci 100 %lx %lx %lx to dump PCI config space.\n",
  1202. dwBus, dwDev, dwFn);
  1203. return E_INVALIDARG;
  1204. if (lcArgs != 3)
  1205. {
  1206. dprintf("invalid command syntax\n"
  1207. "Usage: dcs <Bus>.<Dev>.<Func>\n");
  1208. }
  1209. else
  1210. {
  1211. PCI_TYPE1_CFG_BITS PciCfg1;
  1212. PCI_COMMON_CONFIG cs;
  1213. PciCfg1.u.AsULONG = 0;
  1214. PciCfg1.u.bits.BusNumber = dwBus;
  1215. PciCfg1.u.bits.DeviceNumber = dwDev;
  1216. PciCfg1.u.bits.FunctionNumber = dwFn;
  1217. PciCfg1.u.bits.Enable = TRUE;
  1218. ReadPci(&PciCfg1, (PUCHAR)&cs, 0, sizeof(cs));
  1219. DumpCfgSpace(&cs);
  1220. }
  1221. return S_OK;
  1222. }
  1223. DECLARE_API( ecs )
  1224. /*++
  1225. Routine Description:
  1226. Edit PCI ConfigSpace
  1227. Arguments:
  1228. args - Bus.Dev.Fn
  1229. Dword Offset
  1230. Data
  1231. Return Value:
  1232. None
  1233. --*/
  1234. {
  1235. dprintf("Edit PCI ConfigSpace - must use one of the following:\n"
  1236. "!ecd - edit dword\n"
  1237. "!ecw - edit word\n"
  1238. "!ecb - edit byte\n");
  1239. return S_OK;
  1240. }
  1241. DECLARE_API( ecb )
  1242. /*++
  1243. Routine Description:
  1244. Edit PCI ConfigSpace BYTE
  1245. Arguments:
  1246. args - Bus.Dev.Fn Offset Data
  1247. Return Value:
  1248. None
  1249. --*/
  1250. {
  1251. LONG lcArgs;
  1252. DWORD bus = 0, dev = 0, fn = 0;
  1253. DWORD offset = 0, data = 0;
  1254. PCI_TYPE1_CFG_BITS pcicfg;
  1255. lcArgs = sscanf(args, "%lx.%lx.%lx %lx %lx", &bus, &dev, &fn, &offset, &data);
  1256. if (lcArgs != 5)
  1257. {
  1258. dprintf("invalid command syntax\n"
  1259. "Usage: ecb <Bus>.<Dev>.<Func> Offset Data\n");
  1260. }else{
  1261. //
  1262. // Init for PCI config.
  1263. //
  1264. pcicfg.u.AsULONG = 0;
  1265. pcicfg.u.bits.BusNumber = bus;
  1266. pcicfg.u.bits.DeviceNumber = dev;
  1267. pcicfg.u.bits.FunctionNumber = fn;
  1268. pcicfg.u.bits.Enable = TRUE;
  1269. if (!(WritePci (&pcicfg, (PUCHAR)&data, offset, sizeof(UCHAR)))){
  1270. dprintf("write operation failed!\n");
  1271. return S_FALSE;
  1272. }
  1273. }
  1274. return S_OK;
  1275. }
  1276. DECLARE_API( ecw )
  1277. /*++
  1278. Routine Description:
  1279. Edit PCI ConfigSpace WORD
  1280. Arguments:
  1281. args - Bus.Dev.Fn Offset Data
  1282. Return Value:
  1283. None
  1284. --*/
  1285. {
  1286. LONG lcArgs;
  1287. DWORD bus = 0, dev = 0, fn = 0;
  1288. DWORD offset = 0, data = 0;
  1289. PCI_TYPE1_CFG_BITS pcicfg;
  1290. lcArgs = sscanf(args, "%lx.%lx.%lx %lx %lx", &bus, &dev, &fn, &offset, &data);
  1291. if (lcArgs != 5)
  1292. {
  1293. dprintf("invalid command syntax\n"
  1294. "Usage: ecw <Bus>.<Dev>.<Func> Offset Data\n");
  1295. }else{
  1296. if ((offset & 0x1) || (offset > 0xfe)) {
  1297. //
  1298. // not word aligned.
  1299. //
  1300. dprintf("offset must be word aligned and no greater than 0xfe\n");
  1301. return S_OK;
  1302. }
  1303. //
  1304. // Init for PCI config.
  1305. //
  1306. pcicfg.u.AsULONG = 0;
  1307. pcicfg.u.bits.BusNumber = bus;
  1308. pcicfg.u.bits.DeviceNumber = dev;
  1309. pcicfg.u.bits.FunctionNumber = fn;
  1310. pcicfg.u.bits.Enable = TRUE;
  1311. if (!(WritePci (&pcicfg, (PUCHAR)&data, offset, sizeof(USHORT)))){
  1312. dprintf("write operation failed!\n");
  1313. return S_FALSE;
  1314. }
  1315. }
  1316. return S_OK;
  1317. }
  1318. DECLARE_API( ecd )
  1319. /*++
  1320. Routine Description:
  1321. Edit PCI ConfigSpace DWORD
  1322. Arguments:
  1323. args - Bus.Dev.Fn Offset Data
  1324. Return Value:
  1325. None
  1326. --*/
  1327. {
  1328. LONG lcArgs;
  1329. DWORD bus = 0, dev = 0, fn = 0;
  1330. DWORD offset = 0, data = 0;
  1331. PCI_TYPE1_CFG_BITS pcicfg;
  1332. lcArgs = sscanf(args, "%lx.%lx.%lx %lx %lx", &bus, &dev, &fn, &offset, &data);
  1333. if (lcArgs != 5)
  1334. {
  1335. dprintf("invalid command syntax\n"
  1336. "Usage: ecd <Bus>.<Dev>.<Func> Offset Data\n");
  1337. }else{
  1338. if ((offset & 0x3) || (offset > 0xfc)) {
  1339. //
  1340. // not dword aligned.
  1341. //
  1342. dprintf("offset must be dword aligned and no greater than 0xfc\n");
  1343. return S_OK;
  1344. }
  1345. //
  1346. // Init for PCI config.
  1347. //
  1348. pcicfg.u.AsULONG = 0;
  1349. pcicfg.u.bits.BusNumber = bus;
  1350. pcicfg.u.bits.DeviceNumber = dev;
  1351. pcicfg.u.bits.FunctionNumber = fn;
  1352. pcicfg.u.bits.Enable = TRUE;
  1353. if (!(WritePci (&pcicfg, (PUCHAR)&data, offset, sizeof(ULONG)))){
  1354. dprintf("write operation failed!\n");
  1355. return S_FALSE;
  1356. }
  1357. }
  1358. return S_OK;
  1359. }
  1360. DECLARE_API( cbreg )
  1361. /*++
  1362. Routine Description:
  1363. Dumps CardBus registers
  1364. Arguments:
  1365. args - Supplies the address in hex.
  1366. Return Value:
  1367. None
  1368. --*/
  1369. {
  1370. BOOL rc = TRUE;
  1371. LONG lcArgs;
  1372. BOOL fPhysical = FALSE;
  1373. DWORD dwAddr = 0;
  1374. if (args == NULL)
  1375. {
  1376. dprintf("invalid command syntax\n"
  1377. "Usage: cbreg <RegBaseAddr>\n");
  1378. rc = FALSE;
  1379. }
  1380. else if ((args[0] == '%') && (args[1] == '%'))
  1381. {
  1382. lcArgs = sscanf(&args[2], "%lx", &dwAddr);
  1383. fPhysical = TRUE;
  1384. }
  1385. else
  1386. {
  1387. lcArgs = sscanf(args, "%lx", &dwAddr);
  1388. }
  1389. if ((rc == TRUE) && (lcArgs == 1))
  1390. {
  1391. BYTE abCBRegs[0x14];
  1392. BYTE abExCARegs[0x47];
  1393. DWORD dwSize;
  1394. if (fPhysical)
  1395. {
  1396. ULONG64 phyaddr = 0;
  1397. phyaddr = dwAddr;
  1398. ReadPhysical(phyaddr, abCBRegs, sizeof(abCBRegs), &dwSize);
  1399. if (dwSize != sizeof(abCBRegs))
  1400. {
  1401. dprintf("failed to read physical CBRegs (SizeRead=%x)\n",
  1402. dwSize);
  1403. rc = FALSE;
  1404. }
  1405. else
  1406. {
  1407. phyaddr += 0x800;
  1408. ReadPhysical(phyaddr, abExCARegs, sizeof(abExCARegs), &dwSize);
  1409. if (dwSize != sizeof(abExCARegs))
  1410. {
  1411. dprintf("failed to read physical ExCARegs (SizeRead=%x)\n",
  1412. dwSize);
  1413. rc = FALSE;
  1414. }
  1415. }
  1416. }
  1417. else if (!ReadMemory(dwAddr, abCBRegs, sizeof(abCBRegs), &dwSize) ||
  1418. (dwSize != sizeof(abCBRegs)))
  1419. {
  1420. dprintf("failed to read CBRegs (SizeRead=%x)\n", dwSize);
  1421. rc = FALSE;
  1422. }
  1423. else if (!ReadMemory(dwAddr + 0x800, abExCARegs, sizeof(abExCARegs),
  1424. &dwSize) ||
  1425. (dwSize != sizeof(abExCARegs)))
  1426. {
  1427. dprintf("failed to read CBRegs (SizeRead=%x)\n", dwSize);
  1428. rc = FALSE;
  1429. }
  1430. if (rc == TRUE)
  1431. {
  1432. dprintf("\nCardBus Registers:\n");
  1433. DumpCBRegs(abCBRegs);
  1434. dprintf("\nExCA Registers:\n");
  1435. DumpExCARegs(abExCARegs, sizeof(abExCARegs));
  1436. }
  1437. }
  1438. return S_OK;
  1439. }
  1440. DECLARE_API( exca )
  1441. /*++
  1442. Routine Description:
  1443. Dumps CardBus ExCA registers
  1444. Arguments:
  1445. args - Supplies <BasePort>.<SktNum>
  1446. Return Value:
  1447. None
  1448. --*/
  1449. {
  1450. LONG lcArgs;
  1451. DWORD dwBasePort = 0;
  1452. DWORD dwSktNum = 0;
  1453. if (TargetMachine != IMAGE_FILE_MACHINE_I386) {
  1454. dprintf("X86 target only API.\n");
  1455. return E_INVALIDARG;
  1456. }
  1457. lcArgs = sscanf(args, "%lx.%lx", &dwBasePort, &dwSktNum);
  1458. if (lcArgs != 2)
  1459. {
  1460. dprintf("invalid command syntax\n"
  1461. "Usage: exca <BasePort>.<SocketNum>\n");
  1462. }
  1463. else
  1464. {
  1465. int i;
  1466. BYTE abExCARegs[0x40];
  1467. for (i = 0; i < sizeof(abExCARegs); ++i)
  1468. {
  1469. abExCARegs[i] = ReadExCAByte(dwBasePort,
  1470. (ULONG)(dwSktNum*0x40 + i));
  1471. }
  1472. DumpExCARegs(abExCARegs, sizeof(abExCARegs));
  1473. }
  1474. return S_OK;
  1475. }