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.

713 lines
16 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include <nturtl.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <windows.h>
  7. #include "hbaapi.h"
  8. #define MAX_ADAPTERS 64
  9. void CallMiscFunctions()
  10. {
  11. HBA_STATUS Status;
  12. HBA_UINT32 Version;
  13. Status = HBA_RegisterLibrary(NULL);
  14. if (Status != HBA_STATUS_ERROR_NOT_SUPPORTED)
  15. {
  16. printf("HBA_RegisterLibrary -> %d\n", Status);
  17. }
  18. Version = HBA_GetVersion();
  19. if (Version != HBA_VERSION)
  20. {
  21. printf("HBA_GetVersion -> %d\n", Version);
  22. }
  23. Status = HBA_LoadLibrary();
  24. if (Status != HBA_STATUS_OK)
  25. {
  26. printf("HBA_LoadLibrary -> %d\n", Status);
  27. }
  28. Status = HBA_FreeLibrary();
  29. if (Status != HBA_STATUS_OK)
  30. {
  31. printf("HBA_FreeLibrary -> %d\n", Status);
  32. }
  33. // TODO: These functions
  34. #if 0
  35. HBA_API HBA_STATUS HBA_SendScsiInquiry (
  36. HBA_HANDLE handle,
  37. HBA_WWN PortWWN,
  38. HBA_UINT64 fcLUN,
  39. HBA_UINT8 EVPD,
  40. HBA_UINT32 PageCode,
  41. void * pRspBuffer,
  42. HBA_UINT32 RspBufferSize,
  43. void * pSenseBuffer,
  44. HBA_UINT32 SenseBufferSize);
  45. HBA_API HBA_STATUS HBA_SendReportLUNs (
  46. HBA_HANDLE handle,
  47. HBA_WWN portWWN,
  48. void * pRspBuffer,
  49. HBA_UINT32 RspBufferSize,
  50. void * pSenseBuffer,
  51. HBA_UINT32 SenseBufferSize
  52. );
  53. HBA_API HBA_STATUS HBA_SendReadCapacity (
  54. HBA_HANDLE handle,
  55. HBA_WWN portWWN,
  56. HBA_UINT64 fcLUN,
  57. void * pRspBuffer,
  58. HBA_UINT32 RspBufferSize,
  59. void * pSenseBuffer,
  60. HBA_UINT32 SenseBufferSize
  61. );
  62. #endif
  63. }
  64. HBA_STATUS BuildAdapterList(
  65. PULONG AdapterCount,
  66. TCHAR **Adapters
  67. )
  68. {
  69. HBA_UINT32 Count, i;
  70. PTCHAR Name;
  71. HBA_STATUS Status;
  72. Count = HBA_GetNumberOfAdapters();
  73. if (Count > MAX_ADAPTERS)
  74. {
  75. printf("%d is above limit of %d adapters\n", Count, MAX_ADAPTERS);
  76. Count = MAX_ADAPTERS;
  77. }
  78. *AdapterCount = Count;
  79. Status = HBA_STATUS_OK;
  80. for (i = 0; i < Count; i++)
  81. {
  82. Name = malloc(256 * sizeof(TCHAR));
  83. Status = HBA_GetAdapterName(i, Name);
  84. if (Status == HBA_STATUS_OK)
  85. {
  86. Adapters[i] = Name;
  87. } else {
  88. printf("HBA_GetAdapterName(%d) -> %d\n", i, Status);
  89. break;
  90. }
  91. }
  92. return(Status);
  93. }
  94. void PrintHBA_WWN(
  95. PCHAR s,
  96. HBA_WWN wwn
  97. )
  98. {
  99. printf(s);
  100. printf(" %02x %02x %02x %02x %02x %02x %02x %02x \n",
  101. wwn.wwn[0], wwn.wwn[1], wwn.wwn[2], wwn.wwn[3],
  102. wwn.wwn[4], wwn.wwn[5], wwn.wwn[6], wwn.wwn[7]);
  103. }
  104. void PrintHBA_UINT32(
  105. PCHAR s,
  106. HBA_UINT32 u
  107. )
  108. {
  109. printf(s);
  110. printf(": 0x%x\n", u);
  111. }
  112. #ifdef UNICODE
  113. void Printchar(
  114. PCHAR s,
  115. PWCHAR w
  116. )
  117. {
  118. printf(s);
  119. printf(": %ws\n", w);
  120. }
  121. #else
  122. void Printchar(
  123. PCHAR s,
  124. PCHAR w
  125. )
  126. {
  127. printf(s);
  128. printf(": %s\n", w);
  129. }
  130. #endif
  131. HBA_STATUS GetAdapterAttributes(
  132. HBA_HANDLE Handle,
  133. HBA_UINT32 *PortCount
  134. )
  135. {
  136. HBA_STATUS Status;
  137. HBA_ADAPTERATTRIBUTES Attributes;
  138. Status = HBA_GetAdapterAttributes(Handle,
  139. &Attributes);
  140. if (Status == HBA_STATUS_OK)
  141. {
  142. printf("\nAdapter Attributes:\n");
  143. PrintHBA_WWN("NodeWWN", Attributes.NodeWWN);
  144. PrintHBA_UINT32("VendorSpecificID", Attributes.VendorSpecificID);
  145. PrintHBA_UINT32("NumberOfPorts", Attributes.NumberOfPorts);
  146. *PortCount = Attributes.NumberOfPorts;
  147. Printchar("Manufacturer", Attributes.Manufacturer);
  148. Printchar("SerialNumber", Attributes.SerialNumber);
  149. Printchar("Model", Attributes.Model);
  150. Printchar("ModelDescription", Attributes.ModelDescription);
  151. Printchar("NodeSymbolicName", Attributes.NodeSymbolicName);
  152. Printchar("HardwareVersion", Attributes.HardwareVersion);
  153. Printchar("DriverVersion", Attributes.DriverVersion);
  154. Printchar("OptionROMVersion", Attributes.OptionROMVersion);
  155. Printchar("FirmwareVersion", Attributes.FirmwareVersion);
  156. Printchar("DriverName", Attributes.DriverName);
  157. } else {
  158. printf("HBA_GetAdapterAttributes -> %d\n", Status);
  159. }
  160. return(Status);
  161. }
  162. void PrintHBA_PORTTYPE(
  163. PCHAR s,
  164. HBA_PORTTYPE u
  165. )
  166. {
  167. // TODO: symbolic constants
  168. printf(s);
  169. printf(": 0x%x\n", u);
  170. }
  171. void PrintHBA_PORTSPEED(
  172. PCHAR s,
  173. HBA_PORTSPEED u
  174. )
  175. {
  176. // TODO: symbolic constants
  177. printf(s);
  178. printf(": 0x%x\n", u);
  179. }
  180. void PrintHBA_PORTSTATE(
  181. PCHAR s,
  182. HBA_PORTSTATE u
  183. )
  184. {
  185. // TODO: symbolic constants
  186. printf(s);
  187. printf(": 0x%x\n", u);
  188. }
  189. void PrintHBA_COS(
  190. PCHAR s,
  191. HBA_COS u
  192. )
  193. {
  194. // TODO: symbolic constants
  195. printf(s);
  196. printf(": 0x%x\n", u);
  197. }
  198. void PrintHBA_FC4TYPES(
  199. PCHAR s,
  200. HBA_FC4TYPES Fc4
  201. )
  202. {
  203. ULONG i;
  204. // TODO: symbolic constants
  205. printf(s);
  206. printf(":");
  207. for (i = 0; i < 32; i++)
  208. {
  209. printf(" %02x", Fc4.bits[i]);
  210. }
  211. printf("\n");
  212. }
  213. void PrintHBA_UINT64(
  214. PCHAR s,
  215. HBA_UINT64 u
  216. )
  217. {
  218. printf(s);
  219. printf(": 0x%x\n", u);
  220. }
  221. void PrintHBA_INT64(
  222. PCHAR s,
  223. HBA_INT64 u
  224. )
  225. {
  226. printf(s);
  227. printf(": 0x%x\n", u);
  228. }
  229. void PrintHBA_UINT16(
  230. PCHAR s,
  231. HBA_UINT16 u
  232. )
  233. {
  234. printf(s);
  235. printf(": 0x%x\n", u);
  236. }
  237. void PrintHBA_UINT8A(
  238. PCHAR s,
  239. HBA_UINT8 *u,
  240. ULONG Len
  241. )
  242. {
  243. ULONG i;
  244. printf(s);
  245. printf(":");
  246. for (i = 0; i < Len; i++)
  247. {
  248. printf(" 0x%x\n", u[i]);
  249. }
  250. printf("\n");
  251. }
  252. void PrintHBA_PORTATTRIBUTES(
  253. PHBA_PORTATTRIBUTES Attributes
  254. )
  255. {
  256. PrintHBA_WWN("NodeWWN", Attributes->NodeWWN);
  257. PrintHBA_WWN("PortWWN", Attributes->PortWWN);
  258. PrintHBA_UINT32("PortFcId", Attributes->PortFcId);
  259. PrintHBA_PORTTYPE("PortType", Attributes->PortType);
  260. PrintHBA_PORTSTATE("PortState", Attributes->PortState);
  261. PrintHBA_COS("PortSupportedClassofService", Attributes->PortSupportedClassofService);
  262. PrintHBA_FC4TYPES("PortSupportedFc4Types", Attributes->PortSupportedFc4Types);
  263. PrintHBA_FC4TYPES("PortActiveFc4Types", Attributes->PortActiveFc4Types);
  264. Printchar("PortSymbolicName", Attributes->PortSymbolicName);
  265. Printchar("OSDeviceName", Attributes->OSDeviceName);
  266. PrintHBA_PORTSPEED("PortSupportedSpeed", Attributes->PortSupportedSpeed);
  267. PrintHBA_PORTSPEED("PortSpeed", Attributes->PortSpeed);
  268. PrintHBA_UINT32("PortMaxFrameSize", Attributes->PortMaxFrameSize);
  269. PrintHBA_WWN("FabricName", Attributes->FabricName);
  270. PrintHBA_UINT32("NumberofDiscoveredPorts", Attributes->NumberofDiscoveredPorts);
  271. }
  272. HBA_STATUS GetPortInformation(
  273. HBA_HANDLE Handle,
  274. HBA_UINT32 PortIndex
  275. )
  276. {
  277. HBA_STATUS Status;
  278. HBA_PORTATTRIBUTES Attributes;
  279. HBA_PORTSTATISTICS Statistics;
  280. UINT i;
  281. HBA_ResetStatistics(Handle, PortIndex);
  282. Status = HBA_GetAdapterPortAttributes(Handle,
  283. PortIndex,
  284. &Attributes);
  285. if (Status == HBA_STATUS_OK)
  286. {
  287. PrintHBA_PORTATTRIBUTES(&Attributes);
  288. Status = HBA_GetPortStatistics(Handle,
  289. PortIndex,
  290. &Statistics);
  291. if (Status == HBA_STATUS_OK)
  292. {
  293. PrintHBA_INT64("SecondsSinceLastReset", Statistics.SecondsSinceLastReset);
  294. PrintHBA_INT64("TxFrames", Statistics.TxFrames);
  295. PrintHBA_INT64("TxWords", Statistics.TxWords);
  296. PrintHBA_INT64("RxFrames", Statistics.RxFrames);
  297. PrintHBA_INT64("RxWords", Statistics.RxWords);
  298. PrintHBA_INT64("LIPCount", Statistics.LIPCount);
  299. PrintHBA_INT64("NOSCount", Statistics.NOSCount);
  300. PrintHBA_INT64("ErrorFrames", Statistics.ErrorFrames);
  301. PrintHBA_INT64("DumpedFrames", Statistics.DumpedFrames);
  302. PrintHBA_INT64("LinkFailureCount", Statistics.LinkFailureCount);
  303. PrintHBA_INT64("LossOfSyncCount", Statistics.LossOfSyncCount);
  304. PrintHBA_INT64("LossOfSignalCount", Statistics.LossOfSignalCount);
  305. PrintHBA_INT64("PrimitiveSeqProtocolErrCount", Statistics.PrimitiveSeqProtocolErrCount);
  306. PrintHBA_INT64("InvalidTxWordCount", Statistics.InvalidTxWordCount);
  307. PrintHBA_INT64("InvalidCRCCount", Statistics.InvalidCRCCount);
  308. for (i = 0; i < 4; i++)
  309. {
  310. printf("\nDiscovered port %d\n", i);
  311. Status = HBA_GetDiscoveredPortAttributes(Handle,
  312. PortIndex,
  313. i,
  314. &Attributes);
  315. if (Status == HBA_STATUS_OK)
  316. {
  317. HBA_WWN wwn = {0}; // TODO: make wwn meaningful
  318. PrintHBA_PORTATTRIBUTES(&Attributes);
  319. Status = HBA_GetPortAttributesByWWN(Handle,
  320. wwn,
  321. &Attributes);
  322. if (Status == HBA_STATUS_OK)
  323. {
  324. PrintHBA_PORTATTRIBUTES(&Attributes);
  325. } else {
  326. printf("HBA_GetPortAttributesByWWN -> %d\n", Status);
  327. }
  328. } else {
  329. printf("HBA_GetDiscoveredPortAttributes -> %d\n", Status);
  330. }
  331. }
  332. } else {
  333. printf("HBA_GetPortStatistics -> %d\n", Status);
  334. }
  335. } else {
  336. printf("HBA_GetPortAttributes -> %d\n", Status);
  337. }
  338. return(Status);
  339. }
  340. HBA_STATUS GetSetMgmtInfo(
  341. HBA_HANDLE Handle
  342. )
  343. {
  344. HBA_MGMTINFO MgmtInfo;
  345. HBA_STATUS Status;
  346. Status = HBA_GetRNIDMgmtInfo(Handle,
  347. &MgmtInfo);
  348. if (Status == HBA_STATUS_OK)
  349. {
  350. PrintHBA_WWN("wwn", MgmtInfo.wwn);
  351. PrintHBA_UINT32("unittype", MgmtInfo.unittype);
  352. PrintHBA_UINT32("PortId", MgmtInfo.PortId);
  353. PrintHBA_UINT32("NumberOfAttachedNodes", MgmtInfo.NumberOfAttachedNodes);
  354. PrintHBA_UINT16("IPVersion", MgmtInfo.IPVersion);
  355. PrintHBA_UINT16("UDPPort", MgmtInfo.UDPPort);
  356. PrintHBA_UINT8A("IPAddress", MgmtInfo.IPAddress, 16);
  357. PrintHBA_UINT16("reserved", MgmtInfo.reserved);
  358. PrintHBA_UINT16("TopologyDiscoveryFlags", MgmtInfo.TopologyDiscoveryFlags);
  359. Status = HBA_SetRNIDMgmtInfo(Handle,
  360. &MgmtInfo);
  361. if (Status != HBA_STATUS_OK)
  362. {
  363. printf("HBA_SetRNIDMgmtInfo -> %d\n", Status);
  364. }
  365. } else {
  366. printf("HBA_GetRNIDMgmtInfo -> %d\n", Status);
  367. }
  368. return(Status);
  369. }
  370. UCHAR RspBuffer[0x1000];
  371. UCHAR ReqBuffer[0x800];
  372. HBA_STATUS SendPassThroughs(
  373. HBA_HANDLE Handle
  374. )
  375. {
  376. HBA_STATUS Status;
  377. HBA_UINT32 RspBufferSize;
  378. HBA_WWN wwn = {0};
  379. HBA_WWNTYPE wwnType = 0;
  380. memset(ReqBuffer, 0x80, sizeof(ReqBuffer));
  381. Status = HBA_SendCTPassThru(Handle,
  382. ReqBuffer,
  383. sizeof(ReqBuffer),
  384. RspBuffer,
  385. sizeof(RspBuffer)/2);
  386. if (Status != HBA_STATUS_OK)
  387. {
  388. printf("HBA_SendCTPassThru too small -> %d\n", Status);
  389. }
  390. memset(ReqBuffer, 0x81, sizeof(ReqBuffer));
  391. Status = HBA_SendCTPassThru(Handle,
  392. ReqBuffer,
  393. sizeof(ReqBuffer),
  394. RspBuffer,
  395. sizeof(RspBuffer));
  396. if (Status != HBA_STATUS_OK)
  397. {
  398. printf("HBA_SendCTPassThru -> %d\n", Status);
  399. }
  400. //
  401. // Now do RNID
  402. //
  403. RspBufferSize = 0;
  404. memset(ReqBuffer, 0x80, sizeof(ReqBuffer));
  405. Status = HBA_SendRNID(Handle,
  406. wwn,
  407. wwnType,
  408. RspBuffer,
  409. &RspBufferSize);
  410. if (Status != HBA_STATUS_OK)
  411. {
  412. printf("HBA_SendRNID too small -> %d\n", Status);
  413. } else {
  414. printf("HBA_SENDRNID too small RspBufferSize = %d\n", RspBufferSize);
  415. }
  416. memset(ReqBuffer, 0x81, sizeof(ReqBuffer));
  417. RspBufferSize = 100;
  418. Status = HBA_SendRNID(Handle,
  419. wwn,
  420. wwnType,
  421. RspBuffer,
  422. &RspBufferSize);
  423. if (Status != HBA_STATUS_OK)
  424. {
  425. printf("HBA_SendRNID -> %d\n", Status);
  426. } else {
  427. printf("HBA_SENDRNID RspBufferSize = %d\n", RspBufferSize);
  428. }
  429. return(Status);
  430. }
  431. void PrintHBA_SCSIID(
  432. PHBA_SCSIID ScsiId
  433. )
  434. {
  435. Printchar("OSDeviceName", ScsiId->OSDeviceName);
  436. PrintHBA_UINT32("ScsiBusNumber", ScsiId->ScsiBusNumber);
  437. PrintHBA_UINT32("ScsiTargetNumber", ScsiId->ScsiTargetNumber);
  438. PrintHBA_UINT32("ScsiOSLun", ScsiId->ScsiOSLun);
  439. }
  440. void PrintHBA_FCPID(
  441. PHBA_FCPID FcpId
  442. )
  443. {
  444. PrintHBA_UINT32("FcId", FcpId->FcId);
  445. PrintHBA_WWN("NodeWWN", FcpId->NodeWWN);
  446. PrintHBA_WWN("PortWWN", FcpId->PortWWN);
  447. PrintHBA_UINT64("FcpLun", FcpId->FcpLun);
  448. }
  449. void PrintHBA_FCPSCSIENTRY(
  450. PHBA_FCPSCSIENTRY entry
  451. )
  452. {
  453. PrintHBA_SCSIID(&entry->ScsiId);
  454. PrintHBA_FCPID(&entry->FcpId);
  455. }
  456. void PrintHBA_FCPBINDINGTYPE(
  457. PCHAR s,
  458. HBA_FCPBINDINGTYPE type
  459. )
  460. {
  461. printf(s);
  462. if (type == TO_D_ID)
  463. {
  464. printf(": TO_D_ID\n");
  465. } else if (type == TO_WWN) {
  466. printf(": TO_WWN\n");
  467. } else {
  468. printf(": ?? UNKNOWN ??\n");
  469. }
  470. }
  471. void PrintHBA_FCPBINDINGENTRY(
  472. PHBA_FCPBINDINGENTRY entry
  473. )
  474. {
  475. PrintHBA_FCPBINDINGTYPE("type", entry->type);
  476. PrintHBA_SCSIID(&entry->ScsiId);
  477. PrintHBA_FCPID(&entry->FcpId);
  478. }
  479. HBA_STATUS GetMappings(
  480. HBA_HANDLE Handle
  481. )
  482. {
  483. HBA_FCPTARGETMAPPING FcpMappingStatic;
  484. PHBA_FCPTARGETMAPPING FcpMapping;
  485. HBA_FCPBINDING FcpBindingStatic;
  486. PHBA_FCPBINDING FcpBinding;
  487. ULONG i, SizeNeeded;
  488. HBA_STATUS Status;
  489. printf("FcpTargetMapping\n");
  490. FcpMappingStatic.NumberOfEntries = 0;
  491. Status = HBA_GetFcpTargetMapping(Handle,
  492. &FcpMappingStatic);
  493. if (Status == HBA_STATUS_ERROR_MORE_DATA)
  494. {
  495. SizeNeeded = (sizeof(HBA_FCPTARGETMAPPING) +
  496. (FcpMappingStatic.NumberOfEntries * sizeof(HBA_FCPSCSIENTRY)));
  497. FcpMapping = (PHBA_FCPTARGETMAPPING)malloc(SizeNeeded);
  498. if (FcpMapping != NULL)
  499. {
  500. FcpMapping->NumberOfEntries = FcpMappingStatic.NumberOfEntries;
  501. Status = HBA_GetFcpTargetMapping(Handle,
  502. FcpMapping);
  503. if (Status == HBA_STATUS_OK)
  504. {
  505. printf("Entries = %d\n", FcpMapping->NumberOfEntries);
  506. for (i = 0; i < FcpMapping->NumberOfEntries; i++)
  507. {
  508. PrintHBA_FCPSCSIENTRY(&FcpMapping->entry[i]);
  509. }
  510. } else {
  511. printf("HBA_GetFcpTargetMapping full -> %d\n", Status);
  512. }
  513. } else {
  514. printf("Alloc for %d FCPMapping failed\n", SizeNeeded);
  515. }
  516. } else {
  517. printf("HBA_GetFcpTargetMapping -> %d\n", Status);
  518. }
  519. printf("FcpBinding\n");
  520. FcpBindingStatic.NumberOfEntries = 0;
  521. Status = HBA_GetFcpPersistentBinding(Handle,
  522. &FcpBindingStatic);
  523. if (Status == HBA_STATUS_ERROR_MORE_DATA)
  524. {
  525. SizeNeeded = (sizeof(HBA_FCPBINDING) +
  526. (FcpBindingStatic.NumberOfEntries * sizeof(HBA_FCPBINDINGENTRY)));
  527. FcpBinding = (PHBA_FCPBINDING)malloc(SizeNeeded);
  528. if (FcpBinding != NULL)
  529. {
  530. FcpBinding->NumberOfEntries = FcpBindingStatic.NumberOfEntries;
  531. Status = HBA_GetFcpPersistentBinding(Handle,
  532. FcpBinding);
  533. if (Status == HBA_STATUS_OK)
  534. {
  535. printf("NumberOfEntries = %d\n", FcpBinding->NumberOfEntries);
  536. for (i = 0; i < FcpBinding->NumberOfEntries; i++)
  537. {
  538. PrintHBA_FCPBINDINGENTRY(&FcpBinding->entry[i]);
  539. }
  540. } else {
  541. printf("HBA_GetPersistentBinding full -> %d\n", Status);
  542. }
  543. } else {
  544. printf("Alloc for %d FcpBinding failed\n", SizeNeeded);
  545. }
  546. } else {
  547. printf("HBA_GetFcpPersistenBinding -> %d\n", Status);
  548. }
  549. return(Status);
  550. }
  551. HBA_STATUS GetAdapterInformation(
  552. PTCHAR AdapterName
  553. )
  554. {
  555. HBA_STATUS Status;
  556. HBA_HANDLE Handle;
  557. HBA_UINT32 i, PortCount;
  558. Handle = HBA_OpenAdapter(AdapterName);
  559. if (Handle != 0)
  560. {
  561. HBA_RefreshInformation(Handle);
  562. Status = GetAdapterAttributes(Handle, &PortCount);
  563. if (Status == HBA_STATUS_OK)
  564. {
  565. for (i = 0; i < PortCount; i++)
  566. {
  567. printf("Port %d\n", i);
  568. Status = GetPortInformation(Handle, i);
  569. if (Status != HBA_STATUS_OK)
  570. {
  571. printf("GetPortAttributes(%d) -> %d\n", i, Status);
  572. }
  573. }
  574. Status = GetSetMgmtInfo(Handle);
  575. if (Status != HBA_STATUS_OK)
  576. {
  577. printf("GetSetMgmtInfo -> %d\n", Status);
  578. }
  579. Status = SendPassThroughs(Handle);
  580. if (Status != HBA_STATUS_OK)
  581. {
  582. printf("DoPassthroughs -> %d\n", Status);
  583. }
  584. Status = GetMappings(Handle);
  585. if (Status != HBA_STATUS_OK)
  586. {
  587. printf("GetMappings -> %d\n", Status);
  588. }
  589. }
  590. HBA_CloseAdapter(Handle);
  591. } else {
  592. #ifdef UNICODE
  593. printf("HBA_OpenAdapter(%ws) Error\n", AdapterName);
  594. #else
  595. printf("HBA_OpenAdapter(%s) Error\n", AdapterName);
  596. #endif
  597. }
  598. return(Status);
  599. }
  600. int _cdecl main(int argc, char *argv[])
  601. {
  602. TCHAR *Adapters[MAX_ADAPTERS];
  603. ULONG AdapterCount;
  604. HBA_STATUS Status;
  605. ULONG i;
  606. CallMiscFunctions();
  607. Status = BuildAdapterList(&AdapterCount, Adapters);
  608. if (Status == HBA_STATUS_OK)
  609. {
  610. printf("%d adapters discovered\n", AdapterCount);
  611. for (i = 0; i < AdapterCount; i++)
  612. {
  613. #ifdef UNICODE
  614. printf("Adapter: %ws\n", Adapters[i]);
  615. #else
  616. printf("Adapter: %s\n", Adapters[i]);
  617. #endif
  618. Status = GetAdapterInformation(Adapters[i]);
  619. if (Status != HBA_STATUS_OK)
  620. {
  621. #ifdef UNICODE
  622. printf("GetAdapterInformation(%ws) -> %d\n",
  623. Adapters[i], Status);
  624. #else
  625. printf("GetAdapterInformation(%s) -> %d\n",
  626. Adapters[i], Status);
  627. #endif
  628. }
  629. }
  630. }
  631. return(0);
  632. }