Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. :ts=4
  4. Module Name:
  5. roothub.h
  6. Abstract:
  7. This file contains the interface functions
  8. for the root hub code.
  9. Environment:
  10. Kernel & user mode
  11. Revision History:
  12. 2-13-96 : created
  13. --*/
  14. #define RH_RESET_TIMELENGTH 10 /* Default to 10 ms. */
  15. #define RH_NUMBER_OF_PORTS 2
  16. #define RH_SUCCESS 0
  17. #define RH_NAK 1
  18. #define RH_STALL 2
  19. #define RH_PORT_SC_BASE 0x0010
  20. typedef LONG RHSTATUS;
  21. #include <PSHPACK1.H>
  22. #define RECIPIENT_DEVICE 0
  23. #define RECIPIENT_INTRFACE 1
  24. #define RECIPIENT_ENDPOINT 2
  25. #define RECIPIENT_PORT 3
  26. typedef struct _RH_SETUP {
  27. struct _bmRequestType {
  28. UCHAR Recipient:5;
  29. UCHAR Type:2;
  30. UCHAR Dir:1;
  31. } bmRequestType;
  32. UCHAR bRequest;
  33. union _wValue {
  34. struct {
  35. UCHAR lowPart;
  36. UCHAR hiPart;
  37. };
  38. USHORT W;
  39. } wValue;
  40. USHORT wIndex;
  41. USHORT wLength;
  42. } RH_SETUP, *PRH_SETUP;
  43. typedef struct _RH_PORT_STATUS {
  44. //
  45. // Status bits
  46. //
  47. unsigned Connected:1;
  48. unsigned Enabled:1;
  49. unsigned Suspended:1;
  50. unsigned OverCurrent:1;
  51. unsigned Reset:1;
  52. unsigned Reserved0:3;
  53. unsigned PowerOn:1;
  54. unsigned LowSpeed:1;
  55. unsigned Reserved1:6;
  56. //
  57. // Change bits
  58. //
  59. unsigned ConnectChange:1;
  60. unsigned EnableChange:1;
  61. unsigned SuspendChange:1;
  62. unsigned OverCurrentChange:1;
  63. unsigned ResetChange:1;
  64. unsigned Reserved2:11;
  65. } RH_PORT_STATUS, *PRH_PORT_STATUS;
  66. #include <POPPACK.H>
  67. #define UHCD_FAKE_CONNECT_CHANGE 0x00000001
  68. #define UHCD_FAKE_DISCONNECT 0x00000002
  69. typedef struct _ROOTHUB_PORT {
  70. PDEVICE_OBJECT DeviceObject; // HCD DeviceObject
  71. USHORT Address; // offset of the port
  72. BOOLEAN ResetChange;
  73. BOOLEAN SuspendChange;
  74. } ROOTHUB_PORT, *PROOTHUB_PORT;
  75. typedef struct _ROOTHUB {
  76. ULONG Sig;
  77. PDEVICE_OBJECT DeviceObject; // HCD DeviceObject
  78. UCHAR NumberOfPorts;
  79. UCHAR ConfigurationValue; // current configuration value,
  80. // zero is unconfigured
  81. BOOLEAN DoSelectiveSuspend;
  82. UCHAR Pad[1];
  83. ULONG *DisabledPort;
  84. ROOTHUB_PORT Port[0]; // port structs
  85. } ROOTHUB, *PROOTHUB;
  86. VOID
  87. RootHubTimerHandler(
  88. IN PVOID TimerContext
  89. );
  90. PROOTHUB
  91. RootHub_Initialize(
  92. IN PDEVICE_OBJECT DeviceObject,
  93. IN ULONG NumberOfPorts,
  94. IN BOOLEAN DoSelectiveSuspend
  95. );
  96. RHSTATUS
  97. RootHub_Endpoint0(
  98. IN PROOTHUB RootHub,
  99. IN PRH_SETUP SetupPacket,
  100. IN PUCHAR DeviceAddress,
  101. IN PUCHAR Buffer,
  102. IN OUT PULONG BufferLength
  103. );
  104. RHSTATUS
  105. RootHub_Endpoint1(
  106. IN PROOTHUB RootHub,
  107. IN PUCHAR Buffer,
  108. IN OUT PULONG BufferLength
  109. );
  110. RHSTATUS
  111. RootHub_StandardCommand(
  112. IN PROOTHUB RootHub,
  113. IN PRH_SETUP SetupPacket,
  114. IN OUT PUCHAR DeviceAddress,
  115. IN OUT PUCHAR Buffer,
  116. IN OUT PULONG BufferLength
  117. );
  118. RHSTATUS
  119. RootHub_ClassCommand(
  120. IN PROOTHUB RootHub,
  121. IN PRH_SETUP SetupPacket,
  122. IN OUT PUCHAR Buffer,
  123. IN OUT PULONG BufferLength
  124. );
  125. BOOLEAN
  126. RootHub_PortsIdle(
  127. IN PROOTHUB RootHub
  128. );
  129. //
  130. // Services provided by HCD
  131. //
  132. typedef
  133. VOID
  134. (*PROOTHUB_TIMER_ROUTINE) (
  135. IN PVOID TimerContext
  136. );
  137. //
  138. // UHCD_RootHub_Timer
  139. //
  140. // Inputs:
  141. // HcdPtr - pointer passed to Root hub
  142. // during initialization
  143. // WaitTime - time to wait in ms until
  144. // calling callback.
  145. // RootHubTimerRoutine - VOID fn(PVOID TimerContext)
  146. // context is ptr returned from
  147. // RootHub_Initialize routine.
  148. // TimerContext - pointer to be passed to the callback routine
  149. //
  150. // Returns:
  151. // None
  152. //
  153. VOID
  154. UHCD_RootHub_Timer(
  155. IN PVOID HcdPtr,
  156. IN LONG WaitTime,
  157. IN PROOTHUB_TIMER_ROUTINE RootHubTimerRoutine,
  158. IN PVOID TimerContext
  159. );
  160. USHORT
  161. UHCD_RootHub_ReadPort(
  162. IN PROOTHUB_PORT HubPort
  163. );
  164. VOID
  165. UHCD_RootHub_WritePort(
  166. IN PROOTHUB_PORT HubPort,
  167. IN USHORT DataVal
  168. );