usbhost.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  1. /*++
  2. Copyright (c) 2013 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. usbhost.h
  5. Abstract:
  6. This header contains USB Core library support for host controllers.
  7. Author:
  8. Evan Green 15-Jan-2013
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. #include <minoca/usb/usb.h>
  14. //
  15. // ---------------------------------------------------------------- Definitions
  16. //
  17. //
  18. // Define the current version of the USB host controller interface.
  19. //
  20. #define USB_HOST_CONTROLLER_INTERFACE_VERSION 1
  21. //
  22. // Define the current version of the USB endpoint creation request structure.
  23. //
  24. #define USB_HOST_ENDPOINT_CREATION_REQUEST_VERSION 1
  25. //
  26. // Define the standard USB PID values.
  27. //
  28. #define USB_PID_OUT 0xE1
  29. #define USB_PID_IN 0x69
  30. #define USB_PID_SOF 0xA5
  31. #define USB_PID_SETUP 0x2D
  32. #define USB_PID_DATA0 0xC3
  33. #define USB_PID_DATA1 0x4B
  34. #define USB_PID_DATA2 0x87
  35. #define USB_PID_MDATA 0x0F
  36. #define USB_PID_ACK 0xD2
  37. #define USB_PID_NAK 0x5A
  38. #define USB_PID_STALL 0x1E
  39. #define USB_PID_NYET 0x96
  40. #define USB_PID_PRE 0x3C
  41. #define USB_PID_ERR 0x3C
  42. #define USB_PID_SPLIT 0x78
  43. #define USB_PID_PING 0xB4
  44. //
  45. // Define USB port status bits. These do not correspond directly to any defined
  46. // bits in the USB hub specification.
  47. //
  48. #define USB_PORT_STATUS_CONNECTED 0x0001
  49. #define USB_PORT_STATUS_ENABLED 0x0002
  50. #define USB_PORT_STATUS_SUSPENDED 0x0004
  51. #define USB_PORT_STATUS_OVER_CURRENT 0x0008
  52. #define USB_PORT_STATUS_RESET 0x0010
  53. //
  54. // Define USB port status change bits. These do not correspond directly to any
  55. // defined bits in the USB hub specification. They correspond 1-to-1 with their
  56. // respective status bits.
  57. //
  58. #define USB_PORT_STATUS_CHANGE_CONNECTED USB_PORT_STATUS_CONNECTED
  59. #define USB_PORT_STATUS_CHANGE_ENABLED USB_PORT_STATUS_ENABLED
  60. #define USB_PORT_STATUS_CHANGE_SUSPENDED USB_PORT_STATUS_SUSPENDED
  61. #define USB_PORT_STATUS_CHANGE_OVER_CURRENT USB_PORT_STATUS_OVER_CURRENT
  62. #define USB_PORT_STATUS_CHANGE_RESET USB_PORT_STATUS_RESET
  63. //
  64. // ------------------------------------------------------ Data Type Definitions
  65. //
  66. typedef struct _USB_HUB USB_HUB, *PUSB_HUB;
  67. /*++
  68. Structure Description:
  69. This structure stores port status information.
  70. Members:
  71. Status - Stores a bitmaks of the current port status. See USB_PORT_STATUS_*
  72. definitions.
  73. Change - Stores a bitmaks of the port status bits that have changed and are
  74. yet to be handled. See USB_PORT_STATUS_CHANGE_* definitions.
  75. --*/
  76. typedef struct _USB_PORT_STATUS {
  77. USHORT Status;
  78. USHORT Change;
  79. } USB_PORT_STATUS, *PUSB_PORT_STATUS;
  80. /*++
  81. Structure Description:
  82. This structure stores status information for each of the ports in a USB
  83. hub.
  84. Members:
  85. PortStatus - Stores an array of port status structures. One for each port.
  86. PortDeviceSpeed - Stores an array containing the speed of the device
  87. connected at each port. This value is ignored if no device is connected
  88. to the port.
  89. --*/
  90. typedef struct _USB_HUB_STATUS {
  91. PUSB_PORT_STATUS PortStatus;
  92. PUSB_DEVICE_SPEED PortDeviceSpeed;
  93. } USB_HUB_STATUS, *PUSB_HUB_STATUS;
  94. /*++
  95. Structure Description:
  96. This structure stores information passed to a USB host controller when an
  97. endpoint is being created.
  98. Members:
  99. Version - Stores the version of this structure.
  100. Type - Stores the type of endpoint being created.
  101. Direction - Stores the direction of the endpoint being created.
  102. Speed - Stores the speed of the device the endpoint is being created for.
  103. MaxPacketSize - Stores the maximum number of payload bytes that can be
  104. moved per transfer.
  105. PollRate - Stores the poll rate, in (micro)frames.
  106. EndpointNumber - Stores the endpoint number of the endpoint, as defined by
  107. the USB device.
  108. HubAddress - Stores the address of the device's parent hub, required for
  109. full or low speed devices on a high speed bus. This field will contain
  110. 0 for root hub enumerated devices.
  111. HubPortNumber - Stores the port number this devices is connected to on the
  112. parent hub. This field will be zero for root hub enumerated devices.
  113. --*/
  114. typedef struct _USB_HOST_ENDPOINT_CREATION_REQUEST {
  115. ULONG Version;
  116. USB_TRANSFER_TYPE Type;
  117. USB_TRANSFER_DIRECTION Direction;
  118. USB_DEVICE_SPEED Speed;
  119. ULONG MaxPacketSize;
  120. USHORT PollRate;
  121. UCHAR EndpointNumber;
  122. UCHAR HubAddress;
  123. UCHAR HubPortNumber;
  124. } USB_HOST_ENDPOINT_CREATION_REQUEST, *PUSB_HOST_ENDPOINT_CREATION_REQUEST;
  125. /*++
  126. Structure Description:
  127. This structure stores information about a USB transfer.
  128. Members:
  129. Public - Stores the public portion of the transfer, which is available to
  130. all users of the USB core.
  131. DeviceAddress - Stores the device address where the transfer is pointed.
  132. EndpointNumber - Stores the endpoint number of the endpoint this transfer
  133. is aimed at.
  134. Type - Stores the type of USB request that this transfer is.
  135. --*/
  136. typedef struct _USB_TRANSFER_INTERNAL {
  137. USB_TRANSFER Public;
  138. UCHAR DeviceAddress;
  139. UCHAR EndpointNumber;
  140. USB_TRANSFER_TYPE Type;
  141. } USB_TRANSFER_INTERNAL, *PUSB_TRANSFER_INTERNAL;
  142. //
  143. // Host controller functions.
  144. //
  145. typedef
  146. KSTATUS
  147. (*PUSB_HOST_CREATE_ENDPOINT) (
  148. PVOID HostControllerContext,
  149. PUSB_HOST_ENDPOINT_CREATION_REQUEST Endpoint,
  150. PVOID *EndpointContext
  151. );
  152. /*++
  153. Routine Description:
  154. This routine is called by the USB core when a new endpoint is being opened.
  155. It allows the host controller to create and store any context needed to
  156. support a new endpoint (such as a queue head).
  157. Arguments:
  158. HostControllerContext - Supplies the context pointer passed to the USB core
  159. when the controller was created. This is used to identify the USB host
  160. controller to the host controller driver.
  161. Endpoint - Supplies a pointer containing information about the endpoint
  162. being created. The host controller cannot count on this buffer sticking
  163. around after the function returns. If it needs this information it
  164. should make a copy of it.
  165. EndpointContext - Supplies a pointer where the host controller can store a
  166. context pointer identifying the endpoint created.
  167. Return Value:
  168. STATUS_SUCCESS if the endpoint can be successfully accommodated.
  169. Failing status code if the endpoint cannot be opened.
  170. --*/
  171. typedef
  172. VOID
  173. (*PUSB_HOST_RESET_ENDPOINT) (
  174. PVOID HostControllerContext,
  175. PVOID EndpointContext,
  176. ULONG MaxPacketSize
  177. );
  178. /*++
  179. Routine Description:
  180. This routine is called by the USB core when an endpoint needs to be reset.
  181. Arguments:
  182. HostControllerContext - Supplies the context pointer passed to the USB core
  183. when the controller was created. This is used to identify the USB host
  184. controller to the host controller driver.
  185. EndpointContext - Supplies a pointer to the context returned by the host
  186. controller when the endpoint was created.
  187. MaxPacketSize - Supplies the maximum packet size of the endpoint, which
  188. may have changed in the case of endpoint zero.
  189. Return Value:
  190. None.
  191. --*/
  192. typedef
  193. KSTATUS
  194. (*PUSB_HOST_FLUSH_ENDPOINT) (
  195. PVOID HostControllerContext,
  196. PVOID EndpointContext,
  197. PULONG TransferCount
  198. );
  199. /*++
  200. Routine Description:
  201. This routine flushes all the active transfers from an endpoint. It does so
  202. by polling for completion status and does not return until all transfers
  203. are completed. This must be called at high run level.
  204. Arguments:
  205. HostControllerContext - Supplies the context pointer passed to the USB core
  206. when the controller was created. This is used to identify the USB host
  207. controller to the host controller driver.
  208. EndpointContext - Supplies a pointer to the context returned by the host
  209. controller when the endpoint was created.
  210. TransferCount - Supplies a pointer to a boolean that receives the number
  211. of transfers that were flushed.
  212. Return Value:
  213. Status code.
  214. --*/
  215. typedef
  216. VOID
  217. (*PUSB_HOST_DESTROY_ENDPOINT) (
  218. PVOID HostControllerContext,
  219. PVOID EndpointContext
  220. );
  221. /*++
  222. Routine Description:
  223. This routine tears down and destroys an endpoint created with the endpoint
  224. creation routine.
  225. Arguments:
  226. HostControllerContext - Supplies the context pointer passed to the USB core
  227. when the controller was created. This is used to identify the USB host
  228. controller to the host controller driver.
  229. EndpointContext - Supplies a pointer to the context returned by the host
  230. controller when the endpoint was created.
  231. Return Value:
  232. None.
  233. --*/
  234. typedef
  235. KSTATUS
  236. (*PUSB_HOST_CREATE_TRANSFER) (
  237. PVOID HostControllerContext,
  238. PVOID EndpointContext,
  239. ULONG MaxBufferSize,
  240. ULONG Flags,
  241. PVOID *TransferContext
  242. );
  243. /*++
  244. Routine Description:
  245. This routine allocates structures needed for the USB host controller to
  246. support a transfer.
  247. Arguments:
  248. HostControllerContext - Supplies the context pointer passed to the USB core
  249. when the controller was created. This is used to identify the USB host
  250. controller to the host controller driver.
  251. EndpointContext - Supplies a pointer to the host controller's context of
  252. the endpoint that this transfer will eventually be submitted to.
  253. MaxBufferSize - Supplies the maximum buffer length, in bytes, of the
  254. transfer when it is submitted. It is assumed that the host controller
  255. will set up as many transfer descriptors as are needed to support a
  256. transfer of this size.
  257. Flags - Supplies a bitfield of flags regarding the transaction. See
  258. USB_TRANSFER_FLAG_* definitions.
  259. TransferContext - Supplies a pointer where the host controller can store a
  260. context pointer containing any needed structures for the transfer.
  261. Return Value:
  262. None.
  263. --*/
  264. typedef
  265. VOID
  266. (*PUSB_HOST_DESTROY_TRANSFER) (
  267. PVOID HostControllerContext,
  268. PVOID EndpointContext,
  269. PVOID TransferContext
  270. );
  271. /*++
  272. Routine Description:
  273. This routine destroys host controller structures associated with a USB
  274. transfer.
  275. Arguments:
  276. HostControllerContext - Supplies the context pointer passed to the USB core
  277. when the controller was created. This is used to identify the USB host
  278. controller to the host controller driver.
  279. EndpointContext - Supplies a pointer to the host controller context for the
  280. endpoint this transfer belonged to.
  281. TransferContext - Supplies the pointer provided to the USB core by the host
  282. controller when the transfer was created.
  283. Return Value:
  284. None.
  285. --*/
  286. typedef
  287. KSTATUS
  288. (*PUSB_HOST_SUBMIT_TRANSFER) (
  289. PVOID HostControllerContext,
  290. PVOID EndpointContext,
  291. PUSB_TRANSFER_INTERNAL Transfer,
  292. PVOID TransferContext
  293. );
  294. /*++
  295. Routine Description:
  296. This routine submits a transfer to the USB host controller for execution.
  297. Arguments:
  298. HostControllerContext - Supplies the context pointer passed to the USB core
  299. when the controller was created. This is used to identify the USB host
  300. controller to the host controller driver.
  301. EndpointContext - Supplies the context pointer provided to the USB core by
  302. the host controller when the endpoint was created.
  303. Transfer - Supplies a pointer to the USB transfer to execute.
  304. TransferContext - Supplies the pointer provided to the USB core by the host
  305. controller when the transfer was created.
  306. Return Value:
  307. STATUS_SUCCESS if the transfer was successfully added to the hardware queue.
  308. Failure codes if the transfer could not be added.
  309. --*/
  310. typedef
  311. KSTATUS
  312. (*PUSB_HOST_CANCEL_TRANSFER) (
  313. PVOID HostControllerContext,
  314. PVOID EndpointContext,
  315. PUSB_TRANSFER_INTERNAL Transfer,
  316. PVOID TransferContext
  317. );
  318. /*++
  319. Routine Description:
  320. This routine submits attempts to cancel a transfer that was previously
  321. submitted for execution.
  322. Arguments:
  323. HostControllerContext - Supplies the context pointer passed to the USB core
  324. when the controller was created. This is used to identify the USB host
  325. controller to the host controller driver.
  326. EndpointContext - Supplies the context pointer provided to the USB core by
  327. the host controller when the endpoint was created.
  328. Transfer - Supplies a pointer to the USB transfer to execute.
  329. TransferContext - Supplies the pointer provided to the USB core by the host
  330. controller when the transfer was created.
  331. Return Value:
  332. STATUS_SUCCESS if the transfer was successfully removed from the hardware
  333. queue.
  334. STATUS_TOO_LATE if the transfer had already completed.
  335. Other failure codes if the transfer could not be cancelled but has not yet
  336. completed.
  337. --*/
  338. typedef
  339. KSTATUS
  340. (*PUSB_HOST_GET_ROOT_HUB_STATUS) (
  341. PVOID HostControllerContext,
  342. PUSB_HUB_STATUS HubStatus
  343. );
  344. /*++
  345. Routine Description:
  346. This routine queries the host controller for the status of the root hub.
  347. Arguments:
  348. HostControllerContext - Supplies the context pointer passed to the USB core
  349. when the controller was created. This is used to identify the USB host
  350. controller to the host controller driver.
  351. HubStatus - Supplies a pointer where the host controller should fill out
  352. the root hub status.
  353. Return Value:
  354. STATUS_SUCCESS if the hub status was successfully queried.
  355. Failure codes if the status could not be queried.
  356. --*/
  357. typedef
  358. KSTATUS
  359. (*PUSB_HOST_SET_ROOT_HUB_STATUS) (
  360. PVOID HostControllerContext,
  361. PUSB_HUB_STATUS HubStatus
  362. );
  363. /*++
  364. Routine Description:
  365. This routine sets the state of the root hub in the USB host controller. It
  366. looks at the status change bits for each port in order to determine what
  367. needs to be set.
  368. Arguments:
  369. HostControllerContext - Supplies the context pointer passed to the USB core
  370. when the controller was created. This is used to identify the USB host
  371. controller to the host controller driver.
  372. HubStatus - Supplies a pointer to the status that should be set in the root
  373. hub.
  374. Return Value:
  375. STATUS_SUCCESS if the hub state was successfully programmed into the device.
  376. Failure codes if the status could not be set.
  377. --*/
  378. /*++
  379. Structure Description:
  380. This structure stores an interface of functions that the USB core will use
  381. to call into a specific host controller driver instance.
  382. Members:
  383. Version - Stores the USB controller interface version number.
  384. DriverObject - Stores a pointer to the host controller's driver object,
  385. which is used to create child devices on its behalf.
  386. DeviceObject - Stores a pointer to the host controller's device object,
  387. which is used to create child devices on its behalf.
  388. HostControllerContext - Stores a pointer's worth of context for the USB
  389. host controller. The USB core library will pass this context pointer
  390. to the host controller when calling its interface functions.
  391. Identifier - Stores a unique identifier used to match against the KD debug
  392. handoff data. Often this is the base physical address of the controller.
  393. DebugPortSubType - Stores the host controller type as defined by the Debug
  394. Port Table 2. Set to -1 if the controller isn't defined in the Debug
  395. Port Table 2.
  396. Speed - Stores the maximum supporte speed of the controller.
  397. RootHubPortCount - Stores the number of ports on the root hub of this
  398. controller.
  399. CreateEndpoint - Stores a pointer to a function that the USB core library
  400. calls when an endpoint is being prepared for use.
  401. ResetEndpoint - Stores a pointer to a function that the USB core library
  402. calls to reset an endpoint.
  403. FlushEndpoint - Stores a pointer to a function that the USB core library
  404. calls to flush transfers from an endpoint. This routine is required if
  405. polled I/O is supported.
  406. DestroyEndpoint - Stores a pointer to a function that the USB core library
  407. calls to destroy an endpoint.
  408. CreateTransfer - Stores a pointer to a function that the USB core library
  409. calls to create a new transfer.
  410. DestroyTransfer - Stores a pointer to a function that the USB core library
  411. calls to destroy a USB transfer.
  412. SubmitTransfer - Stores a pointer to a function that the USB core library
  413. calls to submit a USB transfer for execution.
  414. SubmitPolledTransfer - Stores a pointer to a function that the USB core
  415. library calls to submit a USB transfer for polled I/O execution.
  416. CancelTransfer - Stores a pointer to a function that the USB core library
  417. calls to cancel a submitted transfer.
  418. GetRootHubStatus - Stores a pointer to a function that the USB core library
  419. calls to get the current state of the root hub.
  420. SetRootHubStatus - Stores a pointer to a function that the USB core library
  421. calls to set the current state of the root hub.
  422. --*/
  423. typedef struct _USB_HOST_CONTROLLER_INTERFACE {
  424. ULONG Version;
  425. PDRIVER DriverObject;
  426. PDEVICE DeviceObject;
  427. PVOID HostControllerContext;
  428. ULONGLONG Identifier;
  429. USHORT DebugPortSubType;
  430. USB_DEVICE_SPEED Speed;
  431. ULONG RootHubPortCount;
  432. PUSB_HOST_CREATE_ENDPOINT CreateEndpoint;
  433. PUSB_HOST_RESET_ENDPOINT ResetEndpoint;
  434. PUSB_HOST_FLUSH_ENDPOINT FlushEndpoint;
  435. PUSB_HOST_DESTROY_ENDPOINT DestroyEndpoint;
  436. PUSB_HOST_CREATE_TRANSFER CreateTransfer;
  437. PUSB_HOST_DESTROY_TRANSFER DestroyTransfer;
  438. PUSB_HOST_SUBMIT_TRANSFER SubmitTransfer;
  439. PUSB_HOST_SUBMIT_TRANSFER SubmitPolledTransfer;
  440. PUSB_HOST_CANCEL_TRANSFER CancelTransfer;
  441. PUSB_HOST_GET_ROOT_HUB_STATUS GetRootHubStatus;
  442. PUSB_HOST_SET_ROOT_HUB_STATUS SetRootHubStatus;
  443. } USB_HOST_CONTROLLER_INTERFACE, *PUSB_HOST_CONTROLLER_INTERFACE;
  444. //
  445. // -------------------------------------------------------------------- Globals
  446. //
  447. //
  448. // -------------------------------------------------------- Function Prototypes
  449. //
  450. USB_API
  451. KSTATUS
  452. UsbHostRegisterController (
  453. PUSB_HOST_CONTROLLER_INTERFACE ControllerInterface,
  454. PHANDLE ControllerHandle
  455. );
  456. /*++
  457. Routine Description:
  458. This routine registers a new host controller instance with the USB core.
  459. This routine must be called at low level.
  460. Arguments:
  461. ControllerInterface - Supplies a pointer to the interface that the USB
  462. core will use to call back into the host controller. This contents of
  463. this memory will be copied during this call, so the caller can pass
  464. a pointer to a stack-allocated buffer here.
  465. ControllerHandle - Supplies a pointer where a handle will be returned
  466. representing this controller instance. When calls are made to the USB
  467. core regarding a specific controller, pass this handle.
  468. Return Value:
  469. STATUS_SUCCESS on success. A handle will also be returned on success.
  470. STATUS_NOT_SUPPORTED if an unsupported version was supplied with the
  471. controller interface.
  472. Other error codes on other failures.
  473. --*/
  474. USB_API
  475. VOID
  476. UsbHostDestroyControllerState (
  477. HANDLE ControllerHandle
  478. );
  479. /*++
  480. Routine Description:
  481. This routine destroys the state of a USB host controller that was created
  482. during registration.
  483. Arguments:
  484. ControllerHandle - Supplies a handle to a controller instance.
  485. Return Value:
  486. None.
  487. --*/
  488. USB_API
  489. VOID
  490. UsbHostProcessCompletedTransfer (
  491. PUSB_TRANSFER_INTERNAL Transfer
  492. );
  493. /*++
  494. Routine Description:
  495. This routine is called by the USB host controller when the host controller
  496. is done with a transfer. This routine must be called if the transfer is
  497. completed successfully, failed, or was cancelled.
  498. This routine must be called at dispatch level or less.
  499. Arguments:
  500. Transfer - Supplies a pointer to the transfer that has completed.
  501. Return Value:
  502. None.
  503. --*/
  504. USB_API
  505. VOID
  506. UsbHostNotifyPortChange (
  507. HANDLE ControllerHandle
  508. );
  509. /*++
  510. Routine Description:
  511. This routine notifies the USB core that the USB host controller detected a
  512. port change.
  513. Arguments:
  514. ControllerHandle - Supplies a handle to the USB core instance that needs to
  515. be notified that a host port changed status.
  516. Return Value:
  517. None.
  518. --*/
  519. USB_API
  520. KSTATUS
  521. UsbHostQueryChildren (
  522. PIRP Irp,
  523. HANDLE UsbDeviceHandle
  524. );
  525. /*++
  526. Routine Description:
  527. This routine responds to the Query Children IRP for a USB Host controller.
  528. Arguments:
  529. Irp - Supplies a pointer to the Query Children IRP.
  530. UsbDeviceHandle - Supplies a pointer to the USB Host controller handle.
  531. Return Value:
  532. Status code.
  533. --*/
  534. USB_API
  535. KSTATUS
  536. UsbCreateHub (
  537. HANDLE DeviceHandle,
  538. PUSB_HUB *Hub
  539. );
  540. /*++
  541. Routine Description:
  542. This routine creates a new USB hub device. This routine must be called at
  543. low level.
  544. Arguments:
  545. DeviceHandle - Supplies the open device handle to the hub.
  546. Hub - Supplies a pointer where a pointer to the hub context will be
  547. returned.
  548. Return Value:
  549. Status code.
  550. --*/
  551. USB_API
  552. VOID
  553. UsbDestroyHub (
  554. PUSB_HUB Hub
  555. );
  556. /*++
  557. Routine Description:
  558. This routine destroys a USB hub context. This should only be called once
  559. all of the hub's transfers have completed.
  560. Arguments:
  561. Hub - Supplies a pointer to the hub to tear down.
  562. Return Value:
  563. None.
  564. --*/
  565. USB_API
  566. KSTATUS
  567. UsbStartHub (
  568. PUSB_HUB Hub
  569. );
  570. /*++
  571. Routine Description:
  572. This routine starts a USB hub.
  573. Arguments:
  574. Hub - Supplies a pointer to the hub to start.
  575. Return Value:
  576. None.
  577. --*/
  578. USB_API
  579. KSTATUS
  580. UsbHubQueryChildren (
  581. PIRP Irp,
  582. PUSB_HUB Hub
  583. );
  584. /*++
  585. Routine Description:
  586. This routine responds to the Query Children IRP for a USB Hub. This routine
  587. must be called at low level.
  588. Arguments:
  589. Irp - Supplies a pointer to the Query Children IRP.
  590. Hub - Supplies a pointer to the hub to query.
  591. Return Value:
  592. Status code.
  593. --*/