Leaked source code of windows server 2003
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.

728 lines
17 KiB

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