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.

2408 lines
61 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. usb_hcdi.h
  5. Abstract:
  6. Environment:
  7. Kernel & user mode
  8. Revision History:
  9. 6-20-99 : created
  10. --*/
  11. #ifndef __USB_HCDI_H__
  12. #define __USB_HCDI_H__
  13. /*
  14. Power management rules for USB host controllers transitioning from
  15. USB suspend to USB working. This is what we expect for
  16. S3->S0
  17. S1->S0
  18. 1. The controller must not reset the USB bus or cause a disconnect or power
  19. loss on any of the root USB ports.
  20. 2. The system BIOS must not enable any type of legacy USB BIOS or otherwise
  21. enable the host controller to a run state.
  22. 3. If a PCI reset occurs in addition to rule 1 the BIOS must restore all
  23. host registers to their state prior to entering low power. Root ports
  24. should NOT indicate connect or enable status changes.
  25. 4. The controller hardware must be in a functional state -- capable of
  26. driving resume and entering the run state without requiring a global
  27. hardware reset that otherwise would result in a USB bus reset driven on
  28. the root ports.
  29. */
  30. #define USB_BAD_PTR ((PVOID) (-1))
  31. /* status code returned by core functions */
  32. typedef enum _USB_MINIPORT_STATUS {
  33. USBMP_STATUS_SUCCESS = 0,
  34. USBMP_STATUS_BUSY,
  35. USBMP_STATUS_NO_RESOURCES,
  36. USBMP_STATUS_NO_BANDWIDTH,
  37. USBMP_STATUS_INIT_FAILURE,
  38. USBMP_STATUS_FAILURE,
  39. USBMP_STATUS_NOT_SUPPORTED,
  40. USBMP_STATUS_HARDWARE_FAILURE,
  41. USBMP_STATUS_NTERRCODE_NOT_MAPPFED,
  42. } USB_MINIPORT_STATUS;
  43. /* define a test guids for the miniport pass-thru interface */
  44. /* {53D3650A-A4E7-4b0f-BC1D-B76DEB40FA1E}*/
  45. DEFINE_GUID(MINIPORT_PASSTHRU_TEST_GUID,
  46. 0x53d3650a, 0xa4e7, 0x4b0f, 0xbc, 0x1d, 0xb7, 0x6d, 0xeb, 0x40, 0xfa, 0x1e);
  47. /* {386289AA-02EC-486e-925E-838931877F4B}*/
  48. DEFINE_GUID(MINIPORT_PASSTHRU_TEST_BADGUID,
  49. 0x386289aa, 0x2ec, 0x486e, 0x92, 0x5e, 0x83, 0x89, 0x31, 0x87, 0x7f, 0x4b);
  50. // {386289AA-02EC-486e-925E-838931877F4B}
  51. #define TEST_FLAG(var, flag) (((var) & (flag)) ? TRUE : FALSE)
  52. #define CLEAR_FLAG(var, flag) ((var) &= ~(flag))
  53. #define SET_FLAG(var, flag) ((var) |= (flag))
  54. /*
  55. Definition for the 32 bit physical address
  56. that controller hardware understands.
  57. If a miniport HW structure only supports 32 bit
  58. physical addresses then this type is used to
  59. indicate it.
  60. */
  61. typedef ULONG HW_32BIT_PHYSICAL_ADDRESS;
  62. typedef HW_32BIT_PHYSICAL_ADDRESS *PHW_32BIT_PHYSICAL_ADDRESS;
  63. typedef PHYSICAL_ADDRESS HW_64BIT_PHYSICAL_ADDRESS;
  64. typedef struct _MP_HW_PHYSICAL_ADDRESS {
  65. union {
  66. HW_32BIT_PHYSICAL_ADDRESS Hw32;
  67. HW_64BIT_PHYSICAL_ADDRESS Hw64;
  68. };
  69. } MP_HW_PHYSICAL_ADDRESS, *PMP_HW_PHYSICAL_ADDRESS;
  70. C_ASSERT((sizeof(MP_HW_PHYSICAL_ADDRESS) == 8));
  71. /*
  72. This structure is used for pointers embedded in
  73. HW structures by the miniport. They is always sized
  74. for 64 bit to limit 32/64 bit porting problems.
  75. */
  76. typedef struct _MP_HW_POINTER {
  77. PVOID Pointer;
  78. #ifndef _WIN64
  79. ULONG PadTo8;
  80. #endif
  81. } MP_HW_POINTER, *PMP_HW_POINTER;
  82. C_ASSERT((sizeof(MP_HW_POINTER) == 8));
  83. typedef struct _MP_HW_LIST_ENTRY {
  84. LIST_ENTRY List;
  85. #ifndef _WIN64
  86. ULONG PadTo16[2];
  87. #endif
  88. } MP_HW_LIST_ENTRY, *PMP_HW_LIST_ENTRY;
  89. C_ASSERT((sizeof(MP_HW_LIST_ENTRY) == 16));
  90. #define PENDPOINT_DATA PVOID
  91. #define PDEVICE_DATA PVOID
  92. #define PTRANSFER_CONTEXT PVOID
  93. /*
  94. we redifine the USBDI HCD AREA for the miniport model
  95. */
  96. struct _USBPORT_DATA {
  97. PVOID HcdTransferContext;
  98. PVOID UrbSig;
  99. PVOID Reserved7[6];
  100. };
  101. #ifdef _WIN64
  102. #define URB_SIG ((PVOID) 0xDEADF00DDEADF00D)
  103. #else
  104. #define URB_SIG ((PVOID) 0xDEADF00D)
  105. #endif
  106. //C_ASSERT(sizeof(struct _URB_HCD_AREA) == sizeof(struct _USBPORT_DATA))
  107. #define IN_TRANSFER(tp) (((tp)->TransferFlags & \
  108. USBD_TRANSFER_DIRECTION_IN) ? TRUE : FALSE)
  109. #define SHORT_TRANSFER_OK(tp) (((tp)->TransferFlags & \
  110. USBD_SHORT_TRANSFER_OK) ? TRUE : FALSE)
  111. /*
  112. Common transfer request parameter definition, all transfer
  113. requests passed to the miniport will be mapped to this
  114. format. The miniport will/can use this structure to
  115. reference fields that are common to all transfers
  116. as well as fields specific to isochronous and
  117. control transfers.
  118. */
  119. #define MPTX_SPLIT_TRANSFER 0x00000001
  120. typedef struct _TRANSFER_PARAMETERS {
  121. /* identical to URB field */
  122. ULONG TransferFlags;
  123. /* identical to URB field */
  124. ULONG TransferBufferLength;
  125. /* uniquely identifies a transfer set */
  126. ULONG SequenceNumber;
  127. /* miniport special handling requirements */
  128. ULONG MiniportFlags;
  129. /* USB frame this transfer completed in */
  130. ULONG FrameCompleted;
  131. /* setup packet for control transfers */
  132. UCHAR SetupPacket[8];
  133. } TRANSFER_PARAMETERS, *PTRANSFER_PARAMETERS;
  134. typedef struct _MINIPORT_ISO_PACKET {
  135. /*
  136. length of this packet
  137. */
  138. ULONG Length;
  139. /*
  140. bytes transferred this packet
  141. */
  142. ULONG LengthTransferred;
  143. /*
  144. virtual frame to transmit this packet
  145. */
  146. ULONG FrameNumber;
  147. ULONG MicroFrameNumber;
  148. /*
  149. completion code for this packet
  150. */
  151. USBD_STATUS UsbdStatus;
  152. ULONG BufferPointerCount;
  153. /* support up to 2 sg entries per packet */
  154. /* max packet size for a USB 1.1 frame is ~1024 bytes*/
  155. ULONG BufferPointer0Length;
  156. MP_HW_PHYSICAL_ADDRESS BufferPointer0;
  157. ULONG BufferPointer1Length;
  158. MP_HW_PHYSICAL_ADDRESS BufferPointer1;
  159. } MINIPORT_ISO_PACKET, *PMINIPORT_ISO_PACKET;
  160. typedef struct _MINIPORT_ISO_TRANSFER {
  161. ULONG Sig;
  162. ULONG PacketCount;
  163. PUCHAR SystemAddress;
  164. MINIPORT_ISO_PACKET Packets[1];
  165. } MINIPORT_ISO_TRANSFER, *PMINIPORT_ISO_TRANSFER;
  166. /*
  167. These structures are used to pass IoMapped transfer
  168. buffers to the miniport
  169. */
  170. //
  171. // Page size and shift value used by the OHCI, EHCI and UHCI
  172. // controller usb controllers use a defined
  173. //
  174. // this must always be 4k -- it is defined by the controller HW
  175. #define USB_PAGE_SIZE 0x00001000
  176. #define USB_PAGE_SHIFT 12L
  177. typedef struct _TRANSFER_SG_ENTRY32 {
  178. MP_HW_PHYSICAL_ADDRESS LogicalAddress;
  179. PUCHAR SystemAddress;
  180. ULONG Length;
  181. ULONG StartOffset;
  182. } TRANSFER_SG_ENTRY32, *PTRANSFER_SG_ENTRY32;
  183. #define USBMP_SGFLAG_SINGLE_PHYSICAL_PAGE 0x00000001
  184. typedef struct _TRANSFER_SG_LIST {
  185. ULONG SgFlags;
  186. PUCHAR MdlVirtualAddress;
  187. PUCHAR MdlSystemAddress;
  188. ULONG SgCount;
  189. TRANSFER_SG_ENTRY32 SgEntry[1];
  190. } TRANSFER_SG_LIST, *PTRANSFER_SG_LIST;
  191. /**************************************************************
  192. **************************************************************
  193. USBPORT Interface Services
  194. NOTES:
  195. - these functions are callable at raised IRQL
  196. ***************************************************************
  197. ***************************************************************/
  198. #define USBPRTFN __stdcall
  199. /*
  200. VOID
  201. USBPORTSVC_InvalidateEndpoint(
  202. PDEVICE_DATA DeviceData,
  203. PENDPOINT_DATA EndpointData
  204. );
  205. */
  206. typedef VOID
  207. (USBPRTFN *PPORTFN_INVALIDATE_ENDPOINT) (
  208. PDEVICE_DATA,
  209. PENDPOINT_DATA
  210. );
  211. /*
  212. PUCHAR
  213. USBPORTSVC_MapHwPhysicalToVirtual(
  214. HW_32BIT_PHYSICAL_ADDRESS HwPhysicalAddress,
  215. PDEVICE_DATA DeviceData,
  216. PENDPOINT_DATA EndpointData
  217. )
  218. maps a physical address from the miniport to
  219. a virtual address
  220. */
  221. typedef PUCHAR
  222. (USBPRTFN *PPORTFN_PHYS_TO_VIRTUAL) (
  223. HW_32BIT_PHYSICAL_ADDRESS,
  224. PDEVICE_DATA,
  225. PENDPOINT_DATA
  226. );
  227. /*
  228. VOID
  229. USBPORTSVC_CompleteTransfer(
  230. PDEVICE_DATA DeviceData
  231. PDEVICE_DATA EndpointData,
  232. PTRANSFER_PARAMETERS TransferParameters,
  233. USBD_STATUS UsbdStatus,
  234. ULONG BytesTransferred
  235. );
  236. Called by miniport to complete an async transfer request
  237. */
  238. typedef VOID
  239. (USBPRTFN *PPORTFN_COMPLETE_TRANSFER) (
  240. PDEVICE_DATA,
  241. PENDPOINT_DATA,
  242. PTRANSFER_PARAMETERS,
  243. USBD_STATUS,
  244. ULONG
  245. );
  246. /*
  247. VOID
  248. USBPORTSVC_CompleteIsoTransfer(
  249. PDEVICE_DATA DeviceData
  250. PDEVICE_DATA EndpointData,
  251. PTRANSFER_PARAMETERS TransferParameters,
  252. PMINIPORT_ISO_TRANSFER IsoTransfer
  253. );
  254. Called by miniport to complete an iso transfer request
  255. */
  256. typedef VOID
  257. (USBPRTFN *PPORTFN_COMPLETE_ISO_TRANSFER) (
  258. PDEVICE_DATA,
  259. PENDPOINT_DATA,
  260. PTRANSFER_PARAMETERS,
  261. PMINIPORT_ISO_TRANSFER
  262. );
  263. /* ROOT HUB functions */
  264. /*
  265. VOID
  266. USBPORTSVC_InvalidateRootHub(
  267. PDEVICE_DATA DeviceData
  268. );
  269. Called by the miniport to indicate the root hub
  270. needs attention
  271. */
  272. typedef VOID
  273. (USBPRTFN *PPORTFN_INVALIDATE_ROOTHUB) (
  274. PDEVICE_DATA
  275. );
  276. /* Debug functions */
  277. /*
  278. VOID
  279. USBPORTSVC_DbgPrint(
  280. PDEVICE_DATA DeviceData,
  281. ULONG Level,
  282. PCH Format,
  283. PVOID Arg0,
  284. PVOID Arg1,
  285. PVOID Arg2,
  286. PVOID Arg3,
  287. PVOID Arg4,
  288. PVOID Arg5
  289. );
  290. Called by miniport to print a message to the debugger
  291. the message is printed if the var USBPORT_DEBUG_TRACE_LEVEL
  292. is >= level.
  293. */
  294. typedef VOID
  295. (USBPRTFN *PPORTFN_DBGPRINT) (
  296. PDEVICE_DATA,
  297. ULONG,
  298. PCH,
  299. int,
  300. int,
  301. int,
  302. int,
  303. int,
  304. int
  305. );
  306. /*
  307. VOID
  308. USBPORTSVC_TestDebugBreak(
  309. PDEVICE_DATA DeviceData
  310. );
  311. Triggers a break in the debugger in the registry key
  312. debugbreakOn is set. These breakpoins are useful for
  313. debugging hardware/client software problems
  314. */
  315. typedef VOID
  316. (USBPRTFN *PPORTFN_TEST_DEBUG_BREAK) (
  317. PDEVICE_DATA
  318. );
  319. /*
  320. VOID
  321. USBPORTSVC_AssertFailure(
  322. PDEVICE_DATA DeviceData
  323. PVOID FailedAssertion,
  324. PVOID FileName,
  325. ULONG LineNumber,
  326. PCHAR Message
  327. );
  328. */
  329. typedef VOID
  330. (USBPRTFN *PPORTFN_ASSERT_FAILURE) (
  331. PDEVICE_DATA,
  332. PVOID,
  333. PVOID,
  334. ULONG,
  335. PCHAR
  336. );
  337. /*
  338. VOID
  339. USBPORTSVC_LogEntry(
  340. PDEVICE_DATA DeviceData,
  341. );
  342. */
  343. /* Miniport LOG MASKS */
  344. #define G 0x10000001 /* always log */
  345. typedef VOID
  346. (USBPRTFN *PPORTFN_LOGENTRY) (
  347. PDEVICE_DATA,
  348. ULONG,
  349. ULONG,
  350. ULONG_PTR,
  351. ULONG_PTR,
  352. ULONG_PTR
  353. );
  354. /* other functions */
  355. /*
  356. USB_MINIPORT_STATUS
  357. USBPORTSVC_ReadWriteConfigSpace(
  358. PDEVICE_DATA DeviceData,
  359. BOOLEAN Read,
  360. PVOID Buffer,
  361. ULONG Offset,
  362. ULONG Length
  363. )
  364. reads a registry key value from the branch associated
  365. with the PDO for the host controller.
  366. this API reads from either the software or hardware
  367. branch
  368. this function cannot be called at raised IRQL
  369. */
  370. typedef USB_MINIPORT_STATUS
  371. (USBPRTFN *PPORTFN_READWRITE_CONFIG_SPACE) (
  372. PDEVICE_DATA,
  373. BOOLEAN,
  374. PVOID,
  375. ULONG,
  376. ULONG
  377. );
  378. /*
  379. VOID
  380. USBPORTSVC_Wait(
  381. PDEVICE_DATA DeviceData,
  382. ULONG MillisecondsToWait
  383. )
  384. Execute a syncronous wait for a specified number of
  385. milliseconds
  386. */
  387. typedef VOID
  388. (USBPRTFN *PPORTFN_WAIT) (
  389. PDEVICE_DATA,
  390. ULONG
  391. );
  392. /*
  393. VOID
  394. USBPORTSVC_BugCheck(
  395. PDEVICE_DATA DeviceData
  396. )
  397. */
  398. typedef VOID
  399. (USBPRTFN *PPORTFN_BUGCHECK) (
  400. PDEVICE_DATA
  401. );
  402. /*
  403. VOID
  404. USBPORTSVC_NotifyDoubleBuffer(
  405. PDEVICE_DATA DeviceData
  406. PTRANSFER_PARAMETERS TransferParameters,
  407. PVOID SystemAddress,
  408. ULONG Length
  409. )
  410. */
  411. typedef VOID
  412. (USBPRTFN *PPORTFN_NOTIFY_DOUBLE_BUFFER) (
  413. PDEVICE_DATA,
  414. PTRANSFER_PARAMETERS,
  415. PVOID,
  416. ULONG
  417. );
  418. /*
  419. USB_MINIPORT_STATUS
  420. USBPORTSVC_GetMiniportRegistryKeyValue(
  421. PDEVICE_DATA DeviceData,
  422. BOOLEAN SoftwareBranch,
  423. PWCHAR KeyNameString,
  424. ULONG KeyNameStringLength,
  425. PVOID Data,
  426. ULONG DataLength
  427. )
  428. reads a registry key value from the branch associated
  429. with the PDO for the host controller.
  430. this API reads from either the software or hardware
  431. branch
  432. this function cannot be called at raised IRQL
  433. */
  434. typedef USB_MINIPORT_STATUS
  435. (USBPRTFN *PPORTFN_GET_MINIPORT_REGESTRY_KEY_VALUE) (
  436. PDEVICE_DATA,
  437. BOOLEAN,
  438. PWCHAR,
  439. ULONG,
  440. PVOID,
  441. ULONG
  442. );
  443. /*
  444. VOID
  445. USBPORTSVC_RequestAsyncCallback(
  446. PDEVICE_DATA DeviceData,
  447. ULONG MilliSecondInterval,
  448. PVOID Context,
  449. ULONG ContextLength,
  450. PMPFN_MINIPORT_CALLBACK Callback
  451. )
  452. request an async callback when the millisecond interval
  453. has elapsed.
  454. The context field is copied ant the miniport is called back
  455. with the copy so it is safe for the miniport to use a stack
  456. variable as context.
  457. */
  458. /*++
  459. CallBack Definition for async notifiaction service
  460. --*/
  461. typedef VOID
  462. (__stdcall *PMINIPORT_CALLBACK) (
  463. PDEVICE_DATA,
  464. PVOID
  465. );
  466. typedef VOID
  467. (USBPRTFN *PPORTFN_REQUEST_ASYNC_CALLBACK) (
  468. PDEVICE_DATA,
  469. ULONG,
  470. PVOID,
  471. ULONG,
  472. PMINIPORT_CALLBACK
  473. );
  474. /*
  475. VOID
  476. USBPORTSVC_InvalidateController(
  477. PDEVICE_DATA DeviceData,
  478. USB_CONTROLLER_STATE ControllerState
  479. )
  480. */
  481. typedef enum _USB_CONTROLLER_STATE {
  482. UsbMpControllerPowerFault,
  483. UsbMpControllerNeedsHwReset,
  484. UsbMpControllerRemoved,
  485. UsbMpSimulateInterrupt
  486. } USB_CONTROLLER_STATE;
  487. typedef VOID
  488. (__stdcall *PPORTFN_INVALIDATE_CONTROLLER) (
  489. PDEVICE_DATA,
  490. USB_CONTROLLER_STATE
  491. );
  492. /**************************************************************
  493. **************************************************************
  494. USB MINIPORT interface functions
  495. prototypes for functions called by the USB port driver
  496. (usbport)
  497. ***************************************************************
  498. ***************************************************************/
  499. #define USBMPFN __stdcall
  500. /***************************************************************
  501. CORE Functions
  502. The following core functions are serialized as a group they
  503. are assocaited with processing data transfers on the bus
  504. MINIPORT_SubmitTransfer
  505. MINIPORT_SubmitIsoTransfer
  506. MINIPORT_AbortTransfer
  507. MINIPORT_OpenEndpoint
  508. MINIPORT_RebalanceEndpoint
  509. MINIPORT_QueryEndpointRequirements
  510. MINIPORT_CloseEndpoint
  511. MINIPORT_SetEndpointState
  512. MINIPORT_GetEndpointState
  513. MINIPORT_PokeEndpoint
  514. MINIPORT_PollEndpoint
  515. MINIPORT_Get32bitFrameNumber
  516. MINIPORT_InterruptNextSOF
  517. MINIPORT_PollController
  518. ****************************************************************/
  519. /*++
  520. MINIPORT_SubmitTransfer
  521. program a USB transfer, iso, bulk, interrupt or control to the hardware.
  522. if no resources are avaiable then return USBMP_STATUS_BUSY.
  523. if the transfer is successfully queued to the HW then return
  524. USBMP_STATUS_SUCCESS
  525. NOTES:
  526. -At the time this routine is called the transfer buffer has been
  527. mapped (ie no need to call IoMapTransfer).
  528. URB_FUNCTION_CONTROL_TRANSFER
  529. URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
  530. IRQL = DISPATCH_LEVEL
  531. USB_MINIPORT_STATUS
  532. MINIPORT_SubmitTransfer(
  533. PDEVICE_DATA DeviceData,
  534. PENDPOINT_DATA EndpointData,
  535. PTRANSFER_PARAMETERS TransferParameters,
  536. PTRANSFER_CONTEXT TransferContext,
  537. PTRANSFER_SG_LIST TransferSGList
  538. );
  539. --*/
  540. typedef USB_MINIPORT_STATUS
  541. (USBMPFN *PMPFN_SUBMIT_TRANSFER) (
  542. PDEVICE_DATA,
  543. PENDPOINT_DATA,
  544. PTRANSFER_PARAMETERS,
  545. PTRANSFER_CONTEXT,
  546. PTRANSFER_SG_LIST
  547. );
  548. /*++
  549. MINIPORT_SubmitTransfer
  550. program a USB transfer, iso, bulk, interrupt or control to the hardware.
  551. if no resources are avaiable then return USBMP_STATUS_BUSY.
  552. if the transfer is successfully queued to the HW then return
  553. USBMP_STATUS_SUCCESS
  554. NOTES:
  555. -At the time this routine is called the transfer buffer has been
  556. mapped (ie no need to call IoMapTransfer).
  557. IRQL = DISPATCH_LEVEL
  558. USB_MINIPORT_STATUS
  559. MINIPORT_SubmitIsoTransfer(
  560. PDEVICE_DATA DeviceData,
  561. PENDPOINT_DATA EndpointData,
  562. PTRANSFER_PARAMETERS TransferParameters,
  563. PTRANSFER_CONTEXT TransferContext,
  564. PMINIPORT_ISO_TRANSFER IsoTransfer
  565. );
  566. --*/
  567. typedef USB_MINIPORT_STATUS
  568. (USBMPFN *PMPFN_SUBMIT_ISO_TRANSFER) (
  569. PDEVICE_DATA,
  570. PENDPOINT_DATA,
  571. PTRANSFER_PARAMETERS,
  572. PTRANSFER_CONTEXT,
  573. PMINIPORT_ISO_TRANSFER
  574. );
  575. /*++
  576. MINIPORT_AbortTransfer
  577. abort a specfic transfer that has been started, this will only be
  578. called if the endpoint is in the ENDPOINT_PAUSED state.
  579. this call is NOT failable and the HW must have no reference to
  580. the transfer on return.
  581. The miniport does not indicate completion.
  582. IRQL = DISPATCH_LEVEL
  583. VOID
  584. MINIPORT_AbortTransfer(
  585. PDEVICE_DATA DeviceData,
  586. PENDPOINT_DATA EndpointData,
  587. PTRANSFER_CONTEXT TransferContext,
  588. PULONG BytesTransferred
  589. );
  590. --*/
  591. typedef VOID
  592. (USBMPFN *PMPFN_ABORT_TRANSFER) (
  593. PDEVICE_DATA,
  594. PENDPOINT_DATA,
  595. PTRANSFER_CONTEXT,
  596. PULONG
  597. );
  598. /*++
  599. MINIPORT_OpenEndpoint
  600. open an endpoint.
  601. PENDPOINT_DATA is the minport private endpoint
  602. context
  603. PENDPOINT_PARAMETERS describes the endpoint to open
  604. for the miniport -- this information is READ_ONLY
  605. on return the endpoint should be in the PAUSE state
  606. IRQL = DISPATCH_LEVEL
  607. USB_MINIPORT_STATUS
  608. MINIPORT_OpenEndpoint(
  609. PDEVICE_DATA DeviceData,
  610. PENDPOINT_PARAMETERS EndpointParameters,
  611. PENDPOINT_DATA EndpointData
  612. );
  613. --*/
  614. typedef enum _ENDPOINT_TRANSFER_TYPE {
  615. Isochronous = 0,
  616. Control,
  617. Bulk,
  618. Interrupt
  619. } ENDPOINT_TRANSFER_TYPE;
  620. typedef enum _ENDPOINT_TRANSFER_DIRECTION {
  621. In = 0,
  622. Out
  623. } ENDPOINT_TRANSFER_DIRECTION;
  624. typedef enum _DEVICE_SPEED {
  625. LowSpeed = 0,
  626. FullSpeed,
  627. HighSpeed
  628. } DEVICE_SPEED;
  629. /* these values are input by the port driver */
  630. /*
  631. Bandwidth Mamagement:
  632. All bandwidth allocation is managed by the port driver. The
  633. bandwidth consumed by an endpoint is passed to the miniport
  634. but this is purely informational.
  635. Load balancing for interrupt endpoints is handled by passing
  636. the miniport the appropriate schedule offset for an interrupt
  637. endpoint.
  638. interrupt endpoints may occupy different locations in the
  639. schedule dpeneding on the period. The consume bandwidth only
  640. for locations they occupy. This is the 'ScheduleOffset'.
  641. USBPORT will choose an appropriate schedule offset and pass this
  642. to the miniport for the open.
  643. period offsets
  644. 1 0
  645. 2 0,1
  646. 4 0,..3
  647. 8 0,..7
  648. 16 0,..15
  649. 32 0,..31
  650. */
  651. typedef struct _ENDPOINT_PARAMETERS {
  652. USHORT DeviceAddress;
  653. USHORT EndpointAddress;
  654. USHORT MaxPacketSize;
  655. // adjusted interrupt period
  656. // will be one of : 128, 64, 32, 16, 8, 4, 2, 1
  657. UCHAR Period;
  658. UCHAR MaxPeriod;
  659. // bandwidth required in bits/ms
  660. // ie the reserved bw that this endpont will
  661. // consume
  662. DEVICE_SPEED DeviceSpeed;
  663. ULONG Bandwidth;
  664. ULONG ScheduleOffset;
  665. ENDPOINT_TRANSFER_TYPE TransferType;
  666. ENDPOINT_TRANSFER_DIRECTION TransferDirection;
  667. PUCHAR CommonBufferVa;
  668. HW_32BIT_PHYSICAL_ADDRESS CommonBufferPhys;
  669. ULONG CommonBufferBytes;
  670. // endpoint parm flags
  671. ULONG EndpointFlags;
  672. ULONG MaxTransferSize;
  673. // usb 2.0 parameters
  674. // device address of the hub (TT) for this ep
  675. USHORT TtDeviceAddress;
  676. // port number (really TT number) of the TT for
  677. // this device
  678. USHORT TtPortNumber;
  679. UCHAR InterruptScheduleMask;
  680. UCHAR SplitCompletionMask;
  681. UCHAR TransactionsPerMicroframe;
  682. UCHAR Pad;
  683. USHORT MuxPacketSize;
  684. ULONG Ordinal;
  685. } ENDPOINT_PARAMETERS, *PENDPOINT_PARAMETERS;
  686. /* these are returned by the miniport */
  687. typedef struct _ENDPOINT_REQUIREMENTS {
  688. /* size of the common buffer the
  689. miniport will need to service
  690. this endpoint */
  691. ULONG MinCommonBufferBytes;
  692. /*
  693. the largest single transfer this endpoint
  694. can handle. If a client driver passes
  695. down a larger transfer usbport will break
  696. it in to multiple requests.
  697. MinCommonBufferBytes/sizeof(TD) should be
  698. enough TDs to statify at least one request
  699. of MaximumTransferSize.
  700. Ideally it should be able to handle two -- this
  701. will ensure that the bus does not go idle.
  702. */
  703. ULONG MaximumTransferSize;
  704. } ENDPOINT_REQUIREMENTS, *PENDPOINT_REQUIREMENTS;
  705. // **
  706. // EP_PARM_FLAG_
  707. // Enpoint Parameter flags, describe required endpoint
  708. // behaviors including possible optimaizations
  709. //#define EP_PARM_FLAG_ 0x00000002
  710. //
  711. // EP_PARM_FLAG_NOHALT - the endpoint should not halt on the
  712. // host side as a result of a bus error
  713. //
  714. #define EP_PARM_FLAG_NOHALT 0x00000004
  715. // optimization flags
  716. #define EP_PARM_ISO_BUFFERING 0x00000008
  717. //
  718. typedef USB_MINIPORT_STATUS
  719. (USBMPFN *PMPFN_OPEN_ENDPOINT) (
  720. PDEVICE_DATA,
  721. PENDPOINT_PARAMETERS,
  722. PENDPOINT_DATA
  723. );
  724. /*++
  725. MINIPORT_PokeEndpoint
  726. poke an endpoint.
  727. use to change the address of an endpoint without
  728. removing it from the schedule.
  729. **This API is used exclusively to change the endpoint
  730. address.
  731. PENDPOINT_DATA is the minport private endpoint
  732. context
  733. PENDPOINT_PARAMETERS describes the endpoint to open
  734. for the miniport -- this information is READ_ONLY
  735. IRQL = DISPATCH_LEVEL
  736. USB_MINIPORT_STATUS
  737. MINIPORT_PokeEndpoint(
  738. PDEVICE_DATA DeviceData,
  739. PENDPOINT_PARAMETERS EndpointParameters,
  740. PENDPOINT_DATA EndpointData
  741. );
  742. --*/
  743. typedef USB_MINIPORT_STATUS
  744. (USBMPFN *PMPFN_POKE_ENDPOINT) (
  745. PDEVICE_DATA,
  746. PENDPOINT_PARAMETERS,
  747. PENDPOINT_DATA
  748. );
  749. /*++
  750. MINIPORT_RebalanceEndpoint
  751. PENDPOINT_DATA is the minport private endpoint
  752. context
  753. PENDPOINT_PARAMETERS describes the endpoint to open
  754. for the miniport -- this information is READ_ONLY
  755. IRQL = DISPATCH_LEVEL
  756. VOID
  757. MINIPORT_RebalanceEndpoint(
  758. PDEVICE_DATA DeviceData,
  759. PENDPOINT_PARAMETERS EndpointParameters,
  760. PENDPOINT_DATA EndpointData
  761. );
  762. --*/
  763. typedef VOID
  764. (USBMPFN *PMPFN_REBALANCE_ENDPOINT) (
  765. PDEVICE_DATA,
  766. PENDPOINT_PARAMETERS,
  767. PENDPOINT_DATA
  768. );
  769. /*++
  770. MINIPORT_QueryEndpointRequirements
  771. PENDPOINT_DATA is the minport private endpoint
  772. context
  773. IRQL = DISPATCH_LEVEL
  774. VOID
  775. MINIPORT_QueryEndpointRequirements(
  776. PDEVICE_DATA DeviceData,
  777. PENDPOINT_PARAMETERS EndpointParameters,
  778. PENDPOINT_REQUIREMENTS EndpointRequirements
  779. );
  780. Notes on Maximum Transfer Sizes:
  781. Control:
  782. The miniport can assume that no Control transfer buffer passed to
  783. it will be larger than EndpointParameters.MAXTRANSFERSIZE. The miniport
  784. should request enough locked memory (common buffer) to support at least
  785. one control transfer.
  786. TBD - The miniport may optionally request that the controller transfer
  787. be limmited to a smaller value by setting
  788. EndpointRequirements.MAXTRANSFERSIZE. In this case the miniport must
  789. support fragmented control tranfsers.
  790. EndpointParameters.MAXTRANSFERSIZE can never be larger than 64k by spec.
  791. Interrupt:
  792. The miniport can indicate the max transfer size for each interrupt
  793. transfer it can handle in EndpointRequirements.MAXTRANSFERSIZE.
  794. Assume that no transfer buffer will be larger than the this size.
  795. EndpointParameters.MAXTRANSFERSIZE is the default value. The miniport
  796. should allocate resources to handle at least two transfers of this size.
  797. Bulk:
  798. The miniport can indicate the max transfer size for each bulk transfer
  799. it can handle in EndpointRequirements.MAXTRANSFERSIZE. No transfer will
  800. be passed in larger than this value. The miniport must request enough
  801. resources to program at least two transfers of this size into the hardware.
  802. MAXTRANSFERSIZE must be at least 4k.
  803. EndpointParameters.MAXTRANSFERSIZE is the default value.
  804. Basic Iso:
  805. Miniport may specify an EndpointRequirements.MAXTRANSFERSIZE size
  806. but it must also be able to always handle at least two transfers of
  807. MAX_ISO_PACKETS_PER_TRANSFER.
  808. --*/
  809. /*
  810. Historical Note:
  811. The orignal USBD driver shipped in Win98 thru Win2k limits iso requests
  812. to 255 packets so we are safe to set this limit at 256.
  813. This is 256ms for full speed and 32 ms for High speed on the hardware
  814. per request which is plenty.
  815. */
  816. #define MAX_ISO_PACKETS_PER_TRANSFER 256
  817. typedef VOID
  818. (USBMPFN *PMPFN_QENDPOINT_REQUIREMENTS) (
  819. PDEVICE_DATA,
  820. PENDPOINT_PARAMETERS,
  821. PENDPOINT_REQUIREMENTS
  822. );
  823. /*++
  824. MINIPORT_PollEndpoint
  825. Poll the endpoint for done transfers or other changes
  826. PENDPOINT_DATA is the minport private endpoint
  827. context
  828. IRQL = DISPATCH_LEVEL
  829. VOID
  830. MINIPORT_PollEndpoint(
  831. PDEVICE_DATA DeviceData,
  832. PENDPOINT_DATA EndpointData
  833. );
  834. --*/
  835. typedef VOID
  836. (USBMPFN *PMPFN_POLL_ENDPOINT) (
  837. PDEVICE_DATA,
  838. PENDPOINT_DATA
  839. );
  840. /*
  841. MINIPORT_CloseEndpoint
  842. close an endpoint, PENDPOINT_DATA is the minport private endpoint
  843. context
  844. free any resources allocated for the endpoint other than BW
  845. IRQL = DISPATCH_LEVEL
  846. VOID
  847. MINIPORT_CloseEndpoint(
  848. PDEVICE_DATA DeviceData,
  849. PENDPOINT_DATA EndpointData
  850. );
  851. */
  852. typedef VOID
  853. (USBMPFN *PMPFN_CLOSE_ENDPOINT) (
  854. PDEVICE_DATA,
  855. PENDPOINT_DATA
  856. );
  857. /*
  858. MINIPORT_SetEndpointState
  859. Set an endpoint to one of our defined transfer states, the endpoint
  860. need not be in the state when the miniport returns.
  861. There is an assumption here that the enpoint will reach the
  862. desired state on the next SOF, the port will keep track of
  863. this and assume that the state transition has occurred after
  864. one ms frame has passed.
  865. These are software state, changes can only be intiated by a
  866. request thru the MINIPORT_SetEndpointState function. endpoints
  867. cannot transition on their own.
  868. ENDPOINT_IDLE
  869. The endpoint has no active transfer, set this endpoint to a
  870. state that generates minimal activity on the contoller (ie
  871. remove it from the schedule,set skip bit etc)
  872. ENDPOINT_PAUSE
  873. temporarily stop any bus activity associated with the endpoint,
  874. this is a prelude to receiving an abortTransfer.
  875. ENDPOINT_ACTIVE
  876. enable processing of the enpoint -- ie it is in the schedule and
  877. ready for action
  878. ENDPOINT_REMOVE
  879. the endpoint has been removed from the HW schedule
  880. IRQL = DISPATCH_LEVEL
  881. VOID
  882. MINIPORT_SetEndpointState(
  883. PDEVICE_DATA DeviceData,
  884. PENDPOINT_DATA EndpointData
  885. MP_ENDPOINT_STATE
  886. );
  887. MP_ENDPOINT_STATE
  888. MINIPORT_GetEndpointState(
  889. PDEVICE_DATA DeviceData,
  890. PENDPOINT_DATA EndpointData
  891. );
  892. */
  893. typedef enum _MP_ENDPOINT_STATE {
  894. ENDPOINT_TRANSITION = 0,
  895. ENDPOINT_IDLE,
  896. ENDPOINT_PAUSE,
  897. ENDPOINT_ACTIVE,
  898. ENDPOINT_REMOVE,
  899. ENDPOINT_CLOSED
  900. } MP_ENDPOINT_STATE;
  901. typedef VOID
  902. (USBMPFN *PMPFN_SET_ENDPOINT_STATE) (
  903. PDEVICE_DATA,
  904. PENDPOINT_DATA,
  905. MP_ENDPOINT_STATE
  906. );
  907. typedef MP_ENDPOINT_STATE
  908. (USBMPFN *PMPFN_GET_ENDPOINT_STATE) (
  909. PDEVICE_DATA,
  910. PENDPOINT_DATA
  911. );
  912. /*++
  913. MINIPORT_SetEndpointDataToggle
  914. resets the data toggle for an endpoint
  915. IRQL = DISPATCH_LEVEL
  916. VOID
  917. MINIPORT_SetEndpointDataToggle(
  918. PDEVICE_DATA DeviceData,
  919. PENDPOINT_DATA EndointData,
  920. ULONG Toggle
  921. );
  922. --*/
  923. typedef VOID
  924. (USBMPFN *PMPFN_SET_ENDPOINT_DATA_TOGGLE) (
  925. PDEVICE_DATA,
  926. PENDPOINT_DATA,
  927. ULONG
  928. );
  929. /*++
  930. MINIPORT_GetEndpointStatus
  931. returns the status of an endpoint ie HALTED
  932. the status of the endpoint is controlled by the HW.
  933. IRQL = DISPATCH_LEVEL
  934. MP_ENDPOINT_STATUS
  935. MINIPORT_GetEndpointStatus(
  936. PDEVICE_DATA DeviceData,
  937. PENDPOINT_DATA EndointData
  938. );
  939. VOID
  940. MINIPORT_SetEndpointStatus(
  941. PDEVICE_DATA DeviceData,
  942. PENDPOINT_DATA EndointData,
  943. MP_ENDPOINT_STATUS EpStatus
  944. );
  945. --*/
  946. typedef enum _MP_ENDPOINT_STATUS {
  947. ENDPOINT_STATUS_RUN = 0,
  948. ENDPOINT_STATUS_HALT
  949. } MP_ENDPOINT_STATUS;
  950. typedef MP_ENDPOINT_STATUS
  951. (USBMPFN *PMPFN_GET_ENDPOINT_STATUS) (
  952. PDEVICE_DATA,
  953. PENDPOINT_DATA
  954. );
  955. typedef VOID
  956. (USBMPFN *PMPFN_SET_ENDPOINT_STATUS) (
  957. PDEVICE_DATA,
  958. PENDPOINT_DATA,
  959. MP_ENDPOINT_STATUS
  960. );
  961. /*++
  962. MINIPORT_Get32BitFrameNumber
  963. returns the 32 bit frame number maintained by the HCD
  964. IRQL = DISPATCH_LEVEL
  965. ULONG
  966. MINIPORT_Get32BitFrameNumber(
  967. PDEVICE_DATA DeviceData
  968. );
  969. --*/
  970. typedef ULONG
  971. (USBMPFN *PMPFN_GET_32BIT_FRAME_NUMBER) (
  972. PDEVICE_DATA
  973. );
  974. /*++
  975. MINIPORT_InterruptNextSOF
  976. requests an interrupt at the next SOF interval
  977. IRQL = DISPATCH_LEVEL
  978. VOID
  979. MINIPORT_InterruptNextSOF(
  980. PDEVICE_DATA DeviceData
  981. );
  982. --*/
  983. typedef VOID
  984. (USBMPFN *PMPFN_INTERRUPT_NEXT_SOF) (
  985. PDEVICE_DATA
  986. );
  987. /*
  988. MINIPORT_PollController
  989. Optional Poll routine for miniport this function will
  990. be called at the MiniportPollInterval specficeid in
  991. the registration packet.
  992. Specifying a vlue of zero disables polling of the
  993. controller.
  994. IRQL = ANY
  995. VOID
  996. MINIPORT_PollController (
  997. PDEVICE_DATA DeviceData
  998. );
  999. */
  1000. typedef VOID
  1001. (USBMPFN *PMPFN_POLL_CONTROLLER) (
  1002. PDEVICE_DATA
  1003. );
  1004. /***************************************************************
  1005. PNP/POWER Functions
  1006. The following core pnp functions are serialized as a group
  1007. ****************************************************************/
  1008. /*
  1009. MINIPORT_CheckController
  1010. Entry point called by usbport periodically to check the hardware
  1011. state, this function is not serialized. Typically this is used to
  1012. detect surprise removal of the hardware.
  1013. IRQL = ANY
  1014. VOID
  1015. MINIPORT_CheckController(
  1016. PDEVICE_DATA DeviceData
  1017. );
  1018. */
  1019. typedef VOID
  1020. (USBMPFN *PMPFN_CHECK_CONTROLLER) (
  1021. PDEVICE_DATA
  1022. );
  1023. /*
  1024. MINIPORT_StartController
  1025. Initialize Hardware, allocate memory etc.
  1026. on return (STATUS_SUCCESS) the device is considered started and
  1027. powered and must handle ALL CORE functions.
  1028. the miniport should disable any BIOS if present
  1029. the last thing the driver should do before returning is enable
  1030. interrupt generation by the controller
  1031. HcParameters are filled in by the miniport
  1032. IRQL = PASSIVE_LEVEL
  1033. USB_MINIPORT_STATUS
  1034. MINIPORT_StartController(
  1035. PDEVICE_DATA DeviceData,
  1036. PHC_RESOURCES HcResources
  1037. );
  1038. */
  1039. typedef struct _HC_RESOURCES {
  1040. /* values for Flags field */
  1041. #define HCR_IO_REGS 0x0000001
  1042. #define HCR_IRQ 0x0000002
  1043. #define HCR_MEM_REGS 0x0000004
  1044. ULONG Flags;
  1045. USB_CONTROLLER_FLAVOR ControllerFlavor;
  1046. /* interrupt */
  1047. ULONG InterruptVector;
  1048. KIRQL InterruptLevel;
  1049. KAFFINITY Affinity;
  1050. BOOLEAN ShareIRQ;
  1051. KINTERRUPT_MODE InterruptMode;
  1052. PKINTERRUPT InterruptObject;
  1053. /* io ports */
  1054. /* memory mapped */
  1055. PVOID DeviceRegisters;
  1056. ULONG DeviceRegistersLength;
  1057. PUCHAR CommonBufferVa;
  1058. HW_32BIT_PHYSICAL_ADDRESS CommonBufferPhys;
  1059. /* BIOS detected
  1060. filled in by miniport
  1061. */
  1062. BOOLEAN DetectedLegacyBIOS;
  1063. BOOLEAN Restart;
  1064. } HC_RESOURCES, *PHC_RESOURCES;
  1065. typedef USB_MINIPORT_STATUS
  1066. (USBMPFN *PMPFN_START_CONTROLLER) (
  1067. PDEVICE_DATA,
  1068. PHC_RESOURCES
  1069. );
  1070. /*
  1071. MINIPORT_StopController
  1072. disconnect interrupt, free memory etc.
  1073. on return (non Failable) the device is considered stopped and
  1074. powered down and will no longer receicve calls to CORE functions.
  1075. NOTES:
  1076. - The miniport will only receive a stop request if it was
  1077. successfuly started.
  1078. - Miniport should disable all interrupts from the hardware.
  1079. - if Hardware Present is FALSE the miniport should not access
  1080. memory registers or ioports.
  1081. IRQL = PASSIVE_LEVEL
  1082. VOID
  1083. MINIPORT StopController(
  1084. PDEVICE_DATA DeviceData,
  1085. BOOLEAN HardwarePresent
  1086. );
  1087. */
  1088. typedef VOID
  1089. (USBMPFN *PMPFN_STOP_CONTROLLER) (
  1090. PDEVICE_DATA,
  1091. BOOLEAN
  1092. );
  1093. /*
  1094. MINIPORT_ResetController
  1095. Reset the host controller hardware
  1096. This function is serialized with the ISR and DPC and holds
  1097. the core function lock in order to provide a safe environment
  1098. or the miniport to reset the host hardware.
  1099. VOID
  1100. MINIPORT ResetController(
  1101. PDEVICE_DATA DeviceData
  1102. );
  1103. */
  1104. typedef VOID
  1105. (USBMPFN *PMPFN_RESET_CONTROLLER) (
  1106. PDEVICE_DATA
  1107. );
  1108. /*
  1109. MINIPORT_SuspendController
  1110. IRQL = PASSIVE_LEVEL
  1111. VOID
  1112. MINIPORT SuspendController(
  1113. PDEVICE_DATA DeviceData
  1114. );
  1115. */
  1116. typedef VOID
  1117. (USBMPFN *PMPFN_SUSPEND_CONTROLLER) (
  1118. PDEVICE_DATA
  1119. );
  1120. /*
  1121. MINIPORT_ResumeController
  1122. Attempts to resume HC HW from the suspend state. The miniport
  1123. may fail this in the event the controller has been hosed by the
  1124. BIOS. In that even the port driver may attempt to power cycle.
  1125. IRQL = PASSIVE_LEVEL
  1126. VOID
  1127. MINIPORT ResumeController(
  1128. PDEVICE_DATA DeviceData
  1129. );
  1130. */
  1131. typedef USB_MINIPORT_STATUS
  1132. (USBMPFN *PMPFN_RESUME_CONTROLLER) (
  1133. PDEVICE_DATA
  1134. );
  1135. /*
  1136. MINIPORT_FlushInterrupts
  1137. Flush Interrupts on the USB the controller HW
  1138. IRQL = PASSIVE_LEVEL
  1139. VOID
  1140. MINIPORT FlushInterrupts(
  1141. PDEVICE_DATA DeviceData
  1142. );
  1143. */
  1144. typedef VOID
  1145. (USBMPFN *PMPFN_FLUSH_INTERRUPTS) (
  1146. PDEVICE_DATA
  1147. );
  1148. /*
  1149. MINIPORT_TakePortControl
  1150. Pre start controller initialization
  1151. IRQL = PASSIVE_LEVEL
  1152. VOID
  1153. MINIPORT_TakePortControl(
  1154. PDEVICE_DATA DeviceData
  1155. );
  1156. */
  1157. typedef VOID
  1158. (USBMPFN *PMPFN_TAKE_PORT_CONTROL) (
  1159. PDEVICE_DATA
  1160. );
  1161. /*
  1162. MINIPORT_EnableInterrupts
  1163. Enable Interrupts by the USB the controller HW
  1164. IRQL = PASSIVE_LEVEL
  1165. VOID
  1166. MINIPORT EnableInterrupts(
  1167. PDEVICE_DATA DeviceData
  1168. );
  1169. */
  1170. typedef VOID
  1171. (USBMPFN *PMPFN_ENABLE_INTERRUPTS) (
  1172. PDEVICE_DATA
  1173. );
  1174. /*
  1175. MINIPORT_DisableInterrupts
  1176. Disable Interrupts by the USB the controller HW
  1177. On return from this function the controller is expected to
  1178. not generate ANY interrupts.
  1179. Also the controller should ack all interrupts since on return
  1180. from this routine the ISR & ISRDPC will no longer be called.
  1181. IRQL = This function is synchronized with the ISR
  1182. VOID
  1183. MINIPORT DisableInterrupts(
  1184. PDEVICE_DATA DeviceData
  1185. );
  1186. */
  1187. typedef VOID
  1188. (USBMPFN *PMPFN_DISABLE_INTERRUPTS) (
  1189. PDEVICE_DATA
  1190. );
  1191. /***************************************************************
  1192. ROOT HUB Functions
  1193. MINIPORT_RH_GetRootHubData
  1194. MINIPORT_RH_DisableIrq
  1195. MINIPORT_RH_EnableIrq
  1196. MINIPORT_RH_GetStatus
  1197. MINIPORT_RH_GetPortStatus
  1198. MINIPORT_RH_GetHubStatus
  1199. Port Functions, all use PMPFN_RH_PORT_FUNCTION
  1200. MINIPORT_RH_SetFeaturePortReset
  1201. MINIPORT_RH_SetFeaturePortSuspend
  1202. MINIPORT_RH_SetFeaturePortPower
  1203. MINIPORT_RH_SetFeaturePortEnable
  1204. MINIPORT_RH_ClearFeaturePortEnable
  1205. MINIPORT_RH_ClearFeaturePortSuspend
  1206. MINIPORT_RH_ClearFeaturePortPower
  1207. MINIPORT_RH_ClearFeaturePortConnectChange
  1208. MINIPORT_RH_ClearFeaturePortResetChange
  1209. MINIPORT_RH_ClearFeaturePortEnableChange
  1210. MINIPORT_RH_ClearFeaturePortSuspendChange
  1211. MINIPORT_RH_ClearFeaturePortOvercurrentChange
  1212. ****************************************************************/
  1213. /*
  1214. root hub port status data as defined in the Hub Class
  1215. section of the CORE (USB 1.1) spec.
  1216. */
  1217. typedef struct _RH_PORT_STATUS {
  1218. union {
  1219. struct {
  1220. /* Status bits 0.. 15 */
  1221. ULONG Connected:1;
  1222. ULONG Enabled:1;
  1223. ULONG Suspended:1;
  1224. ULONG OverCurrent:1;
  1225. ULONG Reset:1;
  1226. ULONG Reserved0:3;
  1227. ULONG PowerOn:1;
  1228. ULONG LowSpeed:1;
  1229. ULONG HighSpeed:1;
  1230. ULONG Reserved1:4;
  1231. /* borrowed from reserved bits to indicate
  1232. port disposition */
  1233. ULONG OwnedByCC:1;
  1234. /* Change bits 16..31 */
  1235. ULONG ConnectChange:1;
  1236. ULONG EnableChange:1;
  1237. ULONG SuspendChange:1;
  1238. ULONG OverCurrentChange:1;
  1239. ULONG ResetChange:1;
  1240. ULONG Reserved2:11;
  1241. };
  1242. ULONG ul;
  1243. };
  1244. } RH_PORT_STATUS, *PRH_PORT_STATUS;
  1245. C_ASSERT(sizeof(RH_PORT_STATUS) == sizeof(ULONG));
  1246. typedef struct _RH_HUB_STATUS {
  1247. /* Status bits 0.. 15 */
  1248. union {
  1249. struct {
  1250. ULONG LocalPowerLost:1;
  1251. ULONG OverCurrent:1;
  1252. ULONG Reserved:14;
  1253. /* Change bits 16..31 */
  1254. ULONG LocalPowerChange:1;
  1255. ULONG OverCurrentChange:1;
  1256. ULONG Reserved2:14;
  1257. };
  1258. ULONG ul;
  1259. };
  1260. } RH_HUB_STATUS, *PRH_HUB_STATUS;
  1261. C_ASSERT(sizeof(RH_HUB_STATUS) == sizeof(ULONG));
  1262. /*
  1263. Hub Charateristics as defined
  1264. in 11.11.2 of the USB core spec.
  1265. */
  1266. /* PowerSwitchType */
  1267. #define USBPORT_RH_POWER_SWITCH_GANG 0
  1268. #define USBPORT_RH_POWER_SWITCH_PORT 1
  1269. typedef union _RH_HUB_CHARATERISTICS {
  1270. USHORT us;
  1271. struct {
  1272. /*
  1273. 00 = Gang switched
  1274. 01 = port power switched
  1275. 1x = 1.0 hubs with no power
  1276. switching
  1277. */
  1278. USHORT PowerSwitchType:2; /* 0-1 */
  1279. USHORT CompoundDevice:1; /* 2 */
  1280. USHORT OverCurrentProtection:2; /* 3-4 */
  1281. USHORT Reserved:11; /* 5-15 */
  1282. };
  1283. } RH_HUB_CHARATERISTICS, *PRH_HUB_CHARATERISTICS;
  1284. C_ASSERT(sizeof(RH_HUB_CHARATERISTICS) == sizeof(USHORT));
  1285. typedef struct _ROOTHUB_DATA {
  1286. ULONG NumberOfPorts; // number of ports on this hub
  1287. RH_HUB_CHARATERISTICS HubCharacteristics;
  1288. USHORT pad;
  1289. ULONG PowerOnToPowerGood; // port power on till power good in 2ms
  1290. ULONG HubControlCurrent; // max current in mA
  1291. } ROOTHUB_DATA, *PROOTHUB_DATA;
  1292. /*
  1293. MINIPORT_RH_GetRootHubData
  1294. get information about the root hub, port
  1295. driver uses this information to emulate
  1296. the root hub for the miniport
  1297. IRQL = PASSIVE_LEVEL
  1298. VOID
  1299. MINIPORT_RH_GetRootHubData(
  1300. PDEVICE_DATA DeviceData,
  1301. PROOTHUB_DATA HubData
  1302. );
  1303. */
  1304. typedef VOID
  1305. (USBMPFN *PMPFN_RH_GET_ROOTHUB_DATA) (
  1306. PDEVICE_DATA,
  1307. PROOTHUB_DATA
  1308. );
  1309. /*
  1310. MINIPORT_RH_GetStatus
  1311. Used to support the GET_STATUS command sent to the root hub device.
  1312. may return with the following bits set in Status
  1313. USB_GETSTATUS_SELF_POWERED 0x01
  1314. USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02
  1315. are we self powered?
  1316. are we a remote wakeup source?
  1317. see section 9.4.5 USB 1.1 spec
  1318. IRQL = PASSIVE_LEVEL
  1319. USB_MINIPORT_STATUS
  1320. MINIPORT_RH_GetStatus(
  1321. PDEVICE_DATA DeviceData
  1322. PUSHORT Status
  1323. );
  1324. */
  1325. typedef USB_MINIPORT_STATUS
  1326. (USBMPFN *PMPFN_RH_GET_STATUS) (
  1327. PDEVICE_DATA,
  1328. PUSHORT
  1329. );
  1330. /*
  1331. MINIPORT_RH_DisableIrq (OPTIONAL)
  1332. If the comntroller is capable of generating interrupts
  1333. on root hub status changes then it must provide this
  1334. service to disable/enable the feature.
  1335. IRQL = DPC_LEVEL
  1336. VOID
  1337. MINIPORT_RH_DisableIrq(
  1338. PDEVICE_DATA DeviceData
  1339. );
  1340. */
  1341. typedef VOID
  1342. (USBMPFN *PMPFN_RH_DISABLE_IRQ) (
  1343. PDEVICE_DATA
  1344. );
  1345. /*
  1346. MINIPORT_RH_EnableIrq (OPTIONAL)
  1347. IRQL = DPC_LEVEL
  1348. VOID
  1349. MINIPORT_RH_EnableIrq(
  1350. PDEVICE_DATA DeviceData
  1351. );
  1352. */
  1353. typedef VOID
  1354. (USBMPFN *PMPFN_RH_ENABLE_IRQ) (
  1355. PDEVICE_DATA
  1356. );
  1357. /*
  1358. MINIPORT_RH_GetPortStatus
  1359. Used to support the GET_STATUS hub class command sent
  1360. to the root hub interface for a port.
  1361. PortNumber = 1,2, etc
  1362. see section 11.16.2.5 of USB 1.1 spec
  1363. IRQL = PASSIVE_LEVEL
  1364. USB_MINIPORT_STATUS
  1365. MINIPORT_RH_GetPortStatus(
  1366. PDEVICE_DATA DeviceData,
  1367. USHORT PortNumber,
  1368. PRH_PORT_STATUS PortStatus
  1369. );
  1370. */
  1371. typedef USB_MINIPORT_STATUS
  1372. (USBMPFN *PMPFN_RH_GET_PORT_STATUS) (
  1373. PDEVICE_DATA,
  1374. USHORT,
  1375. PRH_PORT_STATUS
  1376. );
  1377. /*
  1378. MINIPORT_RH_GetHubStatus
  1379. Used to support the GET_STATUS hub class command sent
  1380. to the root hub interface for a hub.
  1381. IRQL = PASSIVE_LEVEL
  1382. USB_MINIPORT_STATUS
  1383. MINIPORT_RH_GetHubStatus(
  1384. PDEVICE_DATA DeviceData,
  1385. PRH_HUB_STATUS HubStatus
  1386. );
  1387. */
  1388. typedef USB_MINIPORT_STATUS
  1389. (USBMPFN *PMPFN_RH_GET_HUB_STATUS) (
  1390. PDEVICE_DATA,
  1391. PRH_HUB_STATUS
  1392. );
  1393. /*
  1394. MINIPORT_RH_PORT_FUNCTION
  1395. format for root hub services that act on ports.
  1396. PortNumber = 1,2, etc
  1397. IRQL = PASSIVE_LEVEL
  1398. USB_MINIPORT_STATUS
  1399. MINIPORT_RH_PORT_FUNCTION(
  1400. PDEVICE_DATA DeviceData,
  1401. USHORT PortNumber
  1402. );
  1403. The following services use the MINIPORT_RH_PORT_FUNCTION
  1404. format
  1405. MINIPORT_RH_SetFeaturePortReset
  1406. MINIPORT_RH_SetFeaturePortPower
  1407. MINIPORT_RH_SetFeaturePortEnable
  1408. MINIPORT_RH_SetFeaturePortSuspend
  1409. MINIPORT_RH_ClearFeaturePortEnable
  1410. MINIPORT_RH_ClearFeaturePortPower
  1411. MINIPORT_RH_ClearFeaturePortEnableChange
  1412. MINIPORT_RH_ClearFeaturePortConnectChange
  1413. MINIPORT_RH_ClearFeaturePortResetChange
  1414. */
  1415. typedef USB_MINIPORT_STATUS
  1416. (USBMPFN *PMPFN_RH_PORT_FUNCTION) (
  1417. PDEVICE_DATA,
  1418. USHORT
  1419. );
  1420. /***************************************************************
  1421. INTERRUPT Functions
  1422. these functions are not serialized
  1423. ****************************************************************/
  1424. /*
  1425. MINIPORT_InterruptService
  1426. IRQL = ANY
  1427. BOOLEAN
  1428. MINIPORT_InterruptService (
  1429. PDEVICE_DATA DeviceData
  1430. );
  1431. */
  1432. typedef BOOLEAN
  1433. (USBMPFN *PMPFN_INTERRUPT_SERVICE) (
  1434. PDEVICE_DATA
  1435. );
  1436. /*
  1437. MINIPORT_InterruptDpc
  1438. Called by port in response to an interrupt generated by the HW.
  1439. This function is not serialize with other core functions since
  1440. which allow it to call services in USBPORT that result in
  1441. immediate calls to core functions.
  1442. The port driver passes a flag to indicate if interrupts need
  1443. to be re-enabled on completion of this routine. This is to handle
  1444. the rare case where interrupts have been disabled just after the
  1445. ISR has queued a DPC.
  1446. IRQL = DISPATCH_LEVEL
  1447. VOID
  1448. MINIPORT_InterruptDpc (
  1449. PDEVICE_DATA DeviceData
  1450. BOOLEAN EnableInterrupts
  1451. );
  1452. */
  1453. typedef VOID
  1454. (USBMPFN *PMPFN_INTERRUPT_DPC) (
  1455. PDEVICE_DATA,
  1456. BOOLEAN
  1457. );
  1458. /***************************************************************
  1459. DEBUG/TEST Functions
  1460. ****************************************************************/
  1461. /*
  1462. MINIPORT_SendOnePacket
  1463. IRQL = ANY
  1464. used to support the single-step debug application. This api is
  1465. OPTIONAL
  1466. VOID
  1467. MINIPORT_SendOnePacket (
  1468. PDEVICE_DATA DeviceData,
  1469. PPACKET_PARAMETERS PacketParameters,
  1470. PUCHAR PacketData,
  1471. PULONG PacketLength,
  1472. PUCHAR WorkspaceVirtualAddress,
  1473. HW_32BIT_PHYSICAL_ADDRESS WorkspacePhysicalAddress,
  1474. ULONG WorkspaceLength,
  1475. PUSBD_STATUS UsbdStatus
  1476. );
  1477. */
  1478. typedef enum _SS_PACKET_TYPE {
  1479. ss_Setup = 0,
  1480. ss_In,
  1481. ss_Out,
  1482. ss_Iso_In,
  1483. ss_Iso_Out
  1484. } SS_PACKET_TYPE;
  1485. typedef enum _SS_PACKET_SPEED {
  1486. ss_Low = 0,
  1487. ss_Full,
  1488. ss_High
  1489. } SS_PACKET_SPEED;
  1490. typedef enum _SS_PACKET_DATA_TOGGLE {
  1491. ss_Toggle0 = 0,
  1492. ss_Toggle1
  1493. } SS_PACKET_DATA_TOGGLE;
  1494. typedef struct _MP_PACKET_PARAMETERS {
  1495. UCHAR DeviceAddress;
  1496. UCHAR EndpointAddress;
  1497. USHORT MaximumPacketSize;
  1498. USHORT ErrorCount;
  1499. USHORT Pad;
  1500. SS_PACKET_TYPE Type;
  1501. SS_PACKET_SPEED Speed;
  1502. SS_PACKET_DATA_TOGGLE Toggle;
  1503. /* 2.0 hubs */
  1504. USHORT HubDeviceAddress;
  1505. USHORT PortTTNumber;
  1506. } MP_PACKET_PARAMETERS, *PMP_PACKET_PARAMETERS;
  1507. typedef USB_MINIPORT_STATUS
  1508. (USBMPFN *PMPFN_SEND_ONE_PACKET) (
  1509. PDEVICE_DATA,
  1510. PMP_PACKET_PARAMETERS,
  1511. PUCHAR,
  1512. PULONG,
  1513. PUCHAR,
  1514. HW_32BIT_PHYSICAL_ADDRESS,
  1515. ULONG,
  1516. USBD_STATUS *
  1517. );
  1518. /***************************************************************
  1519. API Functions
  1520. These are called at IRQL passive_level
  1521. ****************************************************************/
  1522. /*
  1523. MINIPORT_PassThru
  1524. IRQL = PASSIVE_LEVEL
  1525. USB_MINIPORT_STATUS
  1526. MINIPORT_PassThru (
  1527. PDEVICE_DATA DeviceData,
  1528. GUID *FunctionGuid,
  1529. ULONG ParameterLength,
  1530. PVOID Parameters
  1531. );
  1532. */
  1533. typedef USB_MINIPORT_STATUS
  1534. (USBMPFN *PMPFN_PASS_THRU) (
  1535. PDEVICE_DATA,
  1536. GUID *,
  1537. ULONG,
  1538. PVOID
  1539. );
  1540. /***************************************************************
  1541. ***************************************************************
  1542. REGISTRATION PACKET
  1543. ***************************************************************
  1544. ****************************************************************/
  1545. /* HCI Hardware Types */
  1546. typedef enum _USB_HCI_TYPE {
  1547. USB_UNKNOWN_HCI = 0,
  1548. USB_OHCI,
  1549. USB_UHCI,
  1550. USB_EHCI
  1551. } USB_HCI_TYPE;
  1552. /* Miniport Option Flags */
  1553. /* resources required by miniport */
  1554. #define USB_MINIPORT_OPT_NEED_IRQ 0x00000001
  1555. #define USB_MINIPORT_OPT_NEED_IOPORT 0x00000002
  1556. #define USB_MINIPORT_OPT_NEED_MEMORY 0x00000004
  1557. /* USB version */
  1558. #define USB_MINIPORT_OPT_USB11 0x00000008
  1559. #define USB_MINIPORT_OPT_USB20 0x00000010
  1560. /* support selective suspend */
  1561. #define USB_MINIPORT_OPT_NO_SS 0x00000020
  1562. /* disables synchronization of the ISRDPC and the
  1563. MP_DisableInterrupts function. usbed by UHCI
  1564. to clear/ set PIRQD in config space. */
  1565. #define USB_MINIPORT_OPT_NO_IRQ_SYNC 0x00000040
  1566. /* indicates controller poll routine should be called
  1567. this will always be at least ounce evert 500ms
  1568. */
  1569. #define USB_MINIPORT_OPT_POLL_CONTROLLER 0x00000080
  1570. /* for bridge drivers with no hw resources */
  1571. #define USB_MINIPORT_OPT_NO_PNP_RESOURCES 0x00000100
  1572. /* poll whe HW suspended */
  1573. #define USB_MINIPORT_OPT_POLL_IN_SUSPEND 0x00000200
  1574. #define USB_MINIPORT_HCI_VERSION USB_MINIPORT_HCI_VERSION_1
  1575. #define USB_MINIPORT_HCI_VERSION_1 100
  1576. #define USB_MINIPORT_HCI_VERSION_2 200
  1577. /*
  1578. Bus Bandwidth defined by spec
  1579. */
  1580. #define USB_11_BUS_BANDWIDTH 12000
  1581. #define USB_20_BUS_BANDWIDTH 400000
  1582. #define USB_HCI_MN 0x10000001
  1583. /* version shipped with XP 2600 this must remaon unchanged */
  1584. typedef struct _USBPORT_REGISTRATION_PACKET_V1 {
  1585. /* begin version (1) interface definition */
  1586. /* Host Controller HCI Type */
  1587. USB_HCI_TYPE HciType;
  1588. /* registration parameters */
  1589. ULONG OptionFlags;
  1590. /*
  1591. Total bus bandwidth avaibale in MBits
  1592. */
  1593. ULONG BusBandwidth;
  1594. LONG Reserved;
  1595. ULONG DeviceDataSize;
  1596. ULONG EndpointDataSize;
  1597. ULONG TransferContextSize;
  1598. /* 7 char ASCII NULL terminated name */
  1599. UCHAR Name[8];
  1600. /*
  1601. Amount of global common buffer needed
  1602. this memory is passed to the miniport on
  1603. a start and freed on a stop
  1604. */
  1605. ULONG CommonBufferBytes;
  1606. /* miniport Functions */
  1607. PMPFN_OPEN_ENDPOINT MINIPORT_OpenEndpoint;
  1608. PMPFN_POKE_ENDPOINT MINIPORT_PokeEndpoint;
  1609. PMPFN_QENDPOINT_REQUIREMENTS MINIPORT_QueryEndpointRequirements;
  1610. PMPFN_CLOSE_ENDPOINT MINIPORT_CloseEndpoint;
  1611. PMPFN_START_CONTROLLER MINIPORT_StartController;
  1612. PMPFN_STOP_CONTROLLER MINIPORT_StopController;
  1613. PMPFN_SUSPEND_CONTROLLER MINIPORT_SuspendController;
  1614. PMPFN_RESUME_CONTROLLER MINIPORT_ResumeController;
  1615. PMPFN_INTERRUPT_SERVICE MINIPORT_InterruptService;
  1616. PMPFN_INTERRUPT_DPC MINIPORT_InterruptDpc;
  1617. PMPFN_SUBMIT_TRANSFER MINIPORT_SubmitTransfer;
  1618. PMPFN_SUBMIT_ISO_TRANSFER MINIPORT_SubmitIsoTransfer;
  1619. PMPFN_ABORT_TRANSFER MINIPORT_AbortTransfer;
  1620. PMPFN_GET_ENDPOINT_STATE MINIPORT_GetEndpointState;
  1621. PMPFN_SET_ENDPOINT_STATE MINIPORT_SetEndpointState;
  1622. PMPFN_POLL_ENDPOINT MINIPORT_PollEndpoint;
  1623. PMPFN_CHECK_CONTROLLER MINIPORT_CheckController;
  1624. PMPFN_GET_32BIT_FRAME_NUMBER MINIPORT_Get32BitFrameNumber;
  1625. PMPFN_INTERRUPT_NEXT_SOF MINIPORT_InterruptNextSOF;
  1626. PMPFN_ENABLE_INTERRUPTS MINIPORT_EnableInterrupts;
  1627. PMPFN_DISABLE_INTERRUPTS MINIPORT_DisableInterrupts;
  1628. PMPFN_POLL_CONTROLLER MINIPORT_PollController;
  1629. PMPFN_SET_ENDPOINT_DATA_TOGGLE MINIPORT_SetEndpointDataToggle;
  1630. PMPFN_GET_ENDPOINT_STATUS MINIPORT_GetEndpointStatus;
  1631. PMPFN_SET_ENDPOINT_STATUS MINIPORT_SetEndpointStatus;
  1632. PMPFN_RESET_CONTROLLER MINIPORT_ResetController;
  1633. /* root hub functions */
  1634. PMPFN_RH_GET_ROOTHUB_DATA MINIPORT_RH_GetRootHubData;
  1635. PMPFN_RH_GET_STATUS MINIPORT_RH_GetStatus;
  1636. PMPFN_RH_GET_PORT_STATUS MINIPORT_RH_GetPortStatus;
  1637. PMPFN_RH_GET_HUB_STATUS MINIPORT_RH_GetHubStatus;
  1638. /* root hub port functions */
  1639. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_SetFeaturePortReset;
  1640. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_SetFeaturePortPower;
  1641. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_SetFeaturePortEnable;
  1642. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_SetFeaturePortSuspend;
  1643. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortEnable;
  1644. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortPower;
  1645. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortSuspend;
  1646. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortEnableChange;
  1647. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortConnectChange;
  1648. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortResetChange;
  1649. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortSuspendChange;
  1650. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortOvercurrentChange;
  1651. /* optional root hub functions */
  1652. PMPFN_RH_DISABLE_IRQ MINIPORT_RH_DisableIrq;
  1653. PMPFN_RH_ENABLE_IRQ MINIPORT_RH_EnableIrq;
  1654. /* OPTIONAL DEBUG SERVICES
  1655. Miniport should return USBMP_STATUS_NOT_SUPPORTED for the
  1656. services not supported.
  1657. */
  1658. PMPFN_SEND_ONE_PACKET MINIPORT_StartSendOnePacket;
  1659. PMPFN_SEND_ONE_PACKET MINIPORT_EndSendOnePacket;
  1660. /* PASS-THRU API function
  1661. */
  1662. PMPFN_PASS_THRU MINIPORT_PassThru;
  1663. /* interface Services */
  1664. PPORTFN_DBGPRINT USBPORTSVC_DbgPrint;
  1665. PPORTFN_TEST_DEBUG_BREAK USBPORTSVC_TestDebugBreak;
  1666. PPORTFN_ASSERT_FAILURE USBPORTSVC_AssertFailure;
  1667. PPORTFN_GET_MINIPORT_REGESTRY_KEY_VALUE USBPORTSVC_GetMiniportRegistryKeyValue;
  1668. PPORTFN_INVALIDATE_ROOTHUB USBPORTSVC_InvalidateRootHub;
  1669. PPORTFN_INVALIDATE_ENDPOINT USBPORTSVC_InvalidateEndpoint;
  1670. PPORTFN_COMPLETE_TRANSFER USBPORTSVC_CompleteTransfer;
  1671. PPORTFN_COMPLETE_ISO_TRANSFER USBPORTSVC_CompleteIsoTransfer;
  1672. PPORTFN_LOGENTRY USBPORTSVC_LogEntry;
  1673. PPORTFN_PHYS_TO_VIRTUAL USBPORTSVC_MapHwPhysicalToVirtual;
  1674. PPORTFN_REQUEST_ASYNC_CALLBACK USBPORTSVC_RequestAsyncCallback;
  1675. PPORTFN_READWRITE_CONFIG_SPACE USBPORTSVC_ReadWriteConfigSpace;
  1676. PPORTFN_WAIT USBPORTSVC_Wait;
  1677. PPORTFN_INVALIDATE_CONTROLLER USBPORTSVC_InvalidateController;
  1678. PPORTFN_BUGCHECK USBPORTSVC_BugCheck;
  1679. PPORTFN_NOTIFY_DOUBLE_BUFFER USBPORTSVC_NotifyDoubleBuffer;
  1680. PMPFN_REBALANCE_ENDPOINT MINIPORT_RebalanceEndpoint;
  1681. PMPFN_FLUSH_INTERRUPTS MINIPORT_FlushInterrupts;
  1682. } USBPORT_REGISTRATION_PACKET_V1, *PUSBPORT_REGISTRATION_PACKET_V1;
  1683. /*
  1684. Miniport version 2 (current) api packet
  1685. */
  1686. typedef struct _USBPORT_REGISTRATION_PACKET {
  1687. /* begin version (1) interface definition */
  1688. /* Host Controller HCI Type */
  1689. USB_HCI_TYPE HciType;
  1690. /* registration parameters */
  1691. ULONG OptionFlags;
  1692. /*
  1693. Total bus bandwidth avaibale in MBits
  1694. */
  1695. ULONG BusBandwidth;
  1696. LONG Reserved;
  1697. ULONG DeviceDataSize;
  1698. ULONG EndpointDataSize;
  1699. ULONG TransferContextSize;
  1700. /* 7 char ASCII NULL terminated name */
  1701. UCHAR Name[8];
  1702. /*
  1703. Amount of global common buffer needed
  1704. this memory is passed to the miniport on
  1705. a start and freed on a stop
  1706. */
  1707. ULONG CommonBufferBytes;
  1708. /* miniport Functions */
  1709. PMPFN_OPEN_ENDPOINT MINIPORT_OpenEndpoint;
  1710. PMPFN_POKE_ENDPOINT MINIPORT_PokeEndpoint;
  1711. PMPFN_QENDPOINT_REQUIREMENTS MINIPORT_QueryEndpointRequirements;
  1712. PMPFN_CLOSE_ENDPOINT MINIPORT_CloseEndpoint;
  1713. PMPFN_START_CONTROLLER MINIPORT_StartController;
  1714. PMPFN_STOP_CONTROLLER MINIPORT_StopController;
  1715. PMPFN_SUSPEND_CONTROLLER MINIPORT_SuspendController;
  1716. PMPFN_RESUME_CONTROLLER MINIPORT_ResumeController;
  1717. PMPFN_INTERRUPT_SERVICE MINIPORT_InterruptService;
  1718. PMPFN_INTERRUPT_DPC MINIPORT_InterruptDpc;
  1719. PMPFN_SUBMIT_TRANSFER MINIPORT_SubmitTransfer;
  1720. PMPFN_SUBMIT_ISO_TRANSFER MINIPORT_SubmitIsoTransfer;
  1721. PMPFN_ABORT_TRANSFER MINIPORT_AbortTransfer;
  1722. PMPFN_GET_ENDPOINT_STATE MINIPORT_GetEndpointState;
  1723. PMPFN_SET_ENDPOINT_STATE MINIPORT_SetEndpointState;
  1724. PMPFN_POLL_ENDPOINT MINIPORT_PollEndpoint;
  1725. PMPFN_CHECK_CONTROLLER MINIPORT_CheckController;
  1726. PMPFN_GET_32BIT_FRAME_NUMBER MINIPORT_Get32BitFrameNumber;
  1727. PMPFN_INTERRUPT_NEXT_SOF MINIPORT_InterruptNextSOF;
  1728. PMPFN_ENABLE_INTERRUPTS MINIPORT_EnableInterrupts;
  1729. PMPFN_DISABLE_INTERRUPTS MINIPORT_DisableInterrupts;
  1730. PMPFN_POLL_CONTROLLER MINIPORT_PollController;
  1731. PMPFN_SET_ENDPOINT_DATA_TOGGLE MINIPORT_SetEndpointDataToggle;
  1732. PMPFN_GET_ENDPOINT_STATUS MINIPORT_GetEndpointStatus;
  1733. PMPFN_SET_ENDPOINT_STATUS MINIPORT_SetEndpointStatus;
  1734. PMPFN_RESET_CONTROLLER MINIPORT_ResetController;
  1735. /* root hub functions */
  1736. PMPFN_RH_GET_ROOTHUB_DATA MINIPORT_RH_GetRootHubData;
  1737. PMPFN_RH_GET_STATUS MINIPORT_RH_GetStatus;
  1738. PMPFN_RH_GET_PORT_STATUS MINIPORT_RH_GetPortStatus;
  1739. PMPFN_RH_GET_HUB_STATUS MINIPORT_RH_GetHubStatus;
  1740. /* root hub port functions */
  1741. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_SetFeaturePortReset;
  1742. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_SetFeaturePortPower;
  1743. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_SetFeaturePortEnable;
  1744. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_SetFeaturePortSuspend;
  1745. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortEnable;
  1746. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortPower;
  1747. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortSuspend;
  1748. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortEnableChange;
  1749. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortConnectChange;
  1750. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortResetChange;
  1751. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortSuspendChange;
  1752. PMPFN_RH_PORT_FUNCTION MINIPORT_RH_ClearFeaturePortOvercurrentChange;
  1753. /* optional root hub functions */
  1754. PMPFN_RH_DISABLE_IRQ MINIPORT_RH_DisableIrq;
  1755. PMPFN_RH_ENABLE_IRQ MINIPORT_RH_EnableIrq;
  1756. /* OPTIONAL DEBUG SERVICES
  1757. Miniport should return USBMP_STATUS_NOT_SUPPORTED for the
  1758. services not supported.
  1759. */
  1760. PMPFN_SEND_ONE_PACKET MINIPORT_StartSendOnePacket;
  1761. PMPFN_SEND_ONE_PACKET MINIPORT_EndSendOnePacket;
  1762. /* PASS-THRU API function
  1763. */
  1764. PMPFN_PASS_THRU MINIPORT_PassThru;
  1765. /* interface Services */
  1766. PPORTFN_DBGPRINT USBPORTSVC_DbgPrint;
  1767. PPORTFN_TEST_DEBUG_BREAK USBPORTSVC_TestDebugBreak;
  1768. PPORTFN_ASSERT_FAILURE USBPORTSVC_AssertFailure;
  1769. PPORTFN_GET_MINIPORT_REGESTRY_KEY_VALUE USBPORTSVC_GetMiniportRegistryKeyValue;
  1770. PPORTFN_INVALIDATE_ROOTHUB USBPORTSVC_InvalidateRootHub;
  1771. PPORTFN_INVALIDATE_ENDPOINT USBPORTSVC_InvalidateEndpoint;
  1772. PPORTFN_COMPLETE_TRANSFER USBPORTSVC_CompleteTransfer;
  1773. PPORTFN_COMPLETE_ISO_TRANSFER USBPORTSVC_CompleteIsoTransfer;
  1774. PPORTFN_LOGENTRY USBPORTSVC_LogEntry;
  1775. PPORTFN_PHYS_TO_VIRTUAL USBPORTSVC_MapHwPhysicalToVirtual;
  1776. PPORTFN_REQUEST_ASYNC_CALLBACK USBPORTSVC_RequestAsyncCallback;
  1777. PPORTFN_READWRITE_CONFIG_SPACE USBPORTSVC_ReadWriteConfigSpace;
  1778. PPORTFN_WAIT USBPORTSVC_Wait;
  1779. PPORTFN_INVALIDATE_CONTROLLER USBPORTSVC_InvalidateController;
  1780. PPORTFN_BUGCHECK USBPORTSVC_BugCheck;
  1781. PPORTFN_NOTIFY_DOUBLE_BUFFER USBPORTSVC_NotifyDoubleBuffer;
  1782. PMPFN_REBALANCE_ENDPOINT MINIPORT_RebalanceEndpoint;
  1783. PMPFN_FLUSH_INTERRUPTS MINIPORT_FlushInterrupts;
  1784. /* end version (1) definition */
  1785. /* begin version (2) definition */
  1786. PMPFN_RH_PORT_FUNCTION MINIPORT_Chirp_RH_Port;
  1787. PMPFN_TAKE_PORT_CONTROL MINIPORT_TakePortControl;
  1788. PVOID pad2;
  1789. PVOID pad3;
  1790. /* end version (2) definition */
  1791. } USBPORT_REGISTRATION_PACKET, *PUSBPORT_REGISTRATION_PACKET;
  1792. /**************************************************************
  1793. **************************************************************
  1794. USBPORT DLL Services
  1795. ***************************************************************
  1796. ***************************************************************/
  1797. #ifndef USBPORT
  1798. DECLSPEC_IMPORT
  1799. NTSTATUS
  1800. USBPORT_RegisterUSBPortDriver(
  1801. PDRIVER_OBJECT DriverObject,
  1802. ULONG MiniportHciVersion,
  1803. PUSBPORT_REGISTRATION_PACKET RegistrationPacket
  1804. );
  1805. DECLSPEC_IMPORT
  1806. ULONG
  1807. USBPORT_GetHciMn(
  1808. );
  1809. #endif
  1810. /* miniport must define these */
  1811. #undef PDEVICE_DATA
  1812. #undef PTRANSFER_CONTEXT
  1813. #undef PENDPOINT_DATA
  1814. #endif /* __USB_HCDI_H__ */