5 //---------------------------------------------------------------------------
8 // --------------------------------------------------------------------
9 // | IRootHCDController |
10 // | IHCDController Intel USB Universal Host Controller - 3A37 |
11 // | IHCDController - Intel USB Universal HostController - 3A38 |
12 // | IHCDController - Intel USB Universal HostController - 3A38 |
13 // |------------------------------------------------------------------|
16 // IHCDController Intel USB Universal Host Controller - 3A37
20 // IUSBQueue <- interacts with -> IUSBRequest
23 // Each IHCDController creates an IUSBHardwareDevice class upon initialization. The
24 // IUSBHardwardeDevice class is used to abstract usb controller specifics. The IHubController
25 // manages all attached devices and handles hub control ioctl requests.
27 // Each IUSBHardwareDevice has one IDMAMemoryManager and one IUSBQueue. The IDMAMemoryManager
28 // is used to handle dma memory allocations. The IUSBQueue manages requests which are send to the
29 // usb hardware. See IUSBRequest class for details.
33 //=========================================================================================
35 // class IRootHCDController
37 // Description: This class serves as the root host controller. The host controller mantains
38 // a list of registered controllers and provides support functions for the host controllers
40 struct IHCDController
;
42 DECLARE_INTERFACE_(IRootHCDController
, IUnknown
)
44 DEFINE_ABSTRACT_UNKNOWN()
46 //-----------------------------------------------------------------------------------------
50 // Description: This function initializes the root host controller. It allocates the resources
51 // required to manage the registered controllers
53 virtual NTSTATUS
Initialize() = 0;
55 //-----------------------------------------------------------------------------------------
59 // Description: this function registers a host controller with the root host controller
61 virtual NTSTATUS
RegisterHCD(struct IHCDController
* Controller
) = 0;
63 //-----------------------------------------------------------------------------------------
67 // Description: this function unregistes a host controller
69 virtual NTSTATUS
UnregisterHCD(struct IHCDController
* Controller
) = 0;
71 //-----------------------------------------------------------------------------------------
75 // Description: returns the number of host controllers registered
77 virtual ULONG
GetControllerCount() = 0;
81 typedef IRootHCDController
*PROOTHDCCONTROLLER
;
83 //=========================================================================================
85 // class IHCDController
87 // Description: This class is used to manage a single USB host controller
90 DECLARE_INTERFACE_(IHCDController
, IUnknown
)
92 DEFINE_ABSTRACT_UNKNOWN()
94 //-----------------------------------------------------------------------------------------
98 // Description: This function initializes the IHCDController implementation.
99 // It creates an IUSBHardwareDevice object and initializes it. It also registeres itself with
100 // the IRootHCDController
102 virtual NTSTATUS
Initialize(IN PROOTHDCCONTROLLER RootHCDController
,
103 IN PDRIVER_OBJECT DriverObject
,
104 IN PDEVICE_OBJECT PhysicalDeviceObject
) = 0;
108 typedef IHCDController
*PHCDCONTROLLER
;
111 //=========================================================================================
113 // class IUSBHardwareDevice
115 // Description: This class provides access to the usb hardware controller
118 struct IDMAMemoryManager
;
121 DECLARE_INTERFACE_(IUSBHardwareDevice
, IUnknown
)
123 DEFINE_ABSTRACT_UNKNOWN()
125 //-----------------------------------------------------------------------------------------
129 // Description: Initializes the usb device controller
131 virtual NTSTATUS
Initialize(PDRIVER_OBJECT DriverObject
,
132 PDEVICE_OBJECT FunctionalDeviceObject
,
133 PDEVICE_OBJECT PhysicalDeviceObject
,
134 PDEVICE_OBJECT LowerDeviceObject
) = 0;
136 //-----------------------------------------------------------------------------------------
140 // Description: handles pnp start request from device. It registeres the interrupt,
141 // sets up the ports and prepares the device. It then starts the controller
143 virtual NTSTATUS
PnpStart(PCM_RESOURCE_LIST RawResources
,
144 PCM_RESOURCE_LIST TranslatedResources
) = 0;
146 //-----------------------------------------------------------------------------------------
150 // Description: handles pnp stop request from device. It unregisteres the interrupt, releases ports and dma object.
152 virtual NTSTATUS
PnpStop(void) = 0;
154 //-----------------------------------------------------------------------------------------
158 // Description: returns the device details such as vendor id, device id, number of ports and speed
160 virtual NTSTATUS
GetDeviceDetails(OUT OPTIONAL PULONG VendorId
,
161 OUT OPTIONAL PULONG DeviceId
,
162 OUT OPTIONAL PULONG NumberOfPorts
,
163 OUT OPTIONAL PULONG Speed
) = 0;
165 //-----------------------------------------------------------------------------------------
167 // GetDmaMemoryManager
169 // Description: returns interface to DMAMemoryManager
170 // Interface is reference counted, you need to call Release method when you are done with it
171 // Do not call Initialize on IDMAMemoryManager, the object is already initialized
173 virtual NTSTATUS
GetDmaMemoryManager(OUT
struct IDMAMemoryManager
**OutMemoryManager
) = 0;
175 //-----------------------------------------------------------------------------------------
179 // Description: returns interface to internal IUSBQueue
180 // Interface is reference counted, you need to call release method when you are done with it
181 // Do not call Initialize on IUSBQueue, the object is already initialized
183 virtual NTSTATUS
GetUSBQueue(OUT
struct IUSBQueue
**OutUsbQueue
) = 0;
185 //-----------------------------------------------------------------------------------------
189 // Description: this function resets the controller
190 // Returns STATUS_SUCCESS when the controller was successfully reset
192 virtual NTSTATUS
ResetController() = 0;
194 //-----------------------------------------------------------------------------------------
198 // Description: this functions resets the port on the controller
201 virtual NTSTATUS
ResetPort(ULONG PortNumber
) = 0;
203 //-----------------------------------------------------------------------------------------
207 // Description: acquires the device lock
209 virtual KIRQL
AcquireDeviceLock(void) = 0;
211 //-----------------------------------------------------------------------------------------
215 // Description: releases the device lock
217 virtual void ReleaseDeviceLock(KIRQL OldLevel
) = 0;
220 typedef IUSBHardwareDevice
*PUSBHARDWAREDEVICE
;
223 //=========================================================================================
225 // class IDMAMemoryManager
227 // Description: This class provides access to the dma buffer. It provides methods to
228 // allocate and free from the dma buffer
231 DECLARE_INTERFACE_(IDMAMemoryManager
, IUnknown
)
233 DEFINE_ABSTRACT_UNKNOWN()
235 //-----------------------------------------------------------------------------------------
239 // Description: initializes the memory manager
241 virtual NTSTATUS
Initialize(IN PUSBHARDWAREDEVICE Device
,
243 IN ULONG DmaBufferSize
,
244 IN PVOID VirtualBase
,
245 IN PHYSICAL_ADDRESS PhysicalAddress
,
246 IN ULONG DefaultBlockSize
) = 0;
248 //-----------------------------------------------------------------------------------------
252 // Description: allocates block of memory from allocator
254 virtual NTSTATUS
Allocate(IN ULONG Size
,
255 OUT PVOID
*OutVirtualBase
,
256 OUT PPHYSICAL_ADDRESS
*OutPhysicalAddress
) = 0;
259 //-----------------------------------------------------------------------------------------
263 // Description: releases memory block
265 virtual NTSTATUS
Release(IN PVOID VirtualBase
,
270 typedef IDMAMemoryManager
*PDMAMEMORYMANAGER
;
273 //=========================================================================================
277 // Description: This class is used to issue request to usb controller. The class is
278 // initialized using InitializeXXX methods. You also need to call SetEndpoint to define the endpoint
279 // In addition you can call SetCompletionDetails if you need to wait for the end of
280 // the request or want to complete an irp. You call AddUSBRequest to add the request to the queue.
281 // Once the request is completed the CompletionCallback is invoked. The CompletionCallback
282 // will take care of any completion details which have been set. If the request is cancelled, the
283 // CancelCallback routine is invoked.
286 DECLARE_INTERFACE_(IUSBRequest
, IUnknown
)
288 DEFINE_ABSTRACT_UNKNOWN()
290 //-----------------------------------------------------------------------------------------
292 // InitializeWithSetupPacket
294 // Description: initializes the request packet with an setup packet
295 // If there is a TransferBuffer, the TransferBufferLength contains the length of the buffer
298 virtual NTSTATUS
InitializeWithSetupPacket(IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket
,
299 IN ULONG TransferBufferLength
,
300 IN PVOID TransferBuffer
) = 0;
303 //TODO: find required parameters for different packet types
307 //-----------------------------------------------------------------------------------------
311 // Description: sets the endpoint of the request.
313 virtual NTSTATUS
SetEndPoint(PUSB_ENDPOINT_DESCRIPTOR EndPoint
);
315 //-----------------------------------------------------------------------------------------
317 // SetCompletionDetails
319 // Description: sets up how the request should be completed
320 // If an irp is passed, then it is completed with status code of the
321 // CompletionCallback or CancelCallback
322 // If an event is passed, then the event is signaled
324 virtual NTSTATUS
SetCompletionDetails(IN OPTIONAL PIRP Irp
,
325 IN OPTIONAL PKEVENT Event
) = 0;
327 //-----------------------------------------------------------------------------------------
329 // CompletionCallback
331 // Description: called when request has been completed. It is called when
332 // IUSBQueue completes the request
334 virtual VOID
CompletionCallback(IN NTSTATUS NtStatusCode
,
335 IN ULONG UrbStatusCode
) = 0;
337 //-----------------------------------------------------------------------------------------
341 // Description: called when request is cancelled. Called by IUSBQueue
343 virtual VOID
CancelCallback(IN NTSTATUS NtStatusCode
) = 0;
347 //=========================================================================================
351 // Description: This class manages pending requests
354 DECLARE_INTERFACE_(IUSBQueue
, IUnknown
)
356 DEFINE_ABSTRACT_UNKNOWN()
358 //-----------------------------------------------------------------------------------------
362 // Description: initializes the object
364 virtual NTSTATUS
Initialize(IN PUSBHARDWAREDEVICE Hardware
,
365 IN OPTIONAL PKSPIN_LOCK Lock
,
366 IN PDMAMEMORYMANAGER MemoryManager
) = 0;
368 //-----------------------------------------------------------------------------------------
370 // GetPendingRequestCount
372 // Description: returns the number of pending requests
374 virtual ULONG
GetPendingRequestCount() = 0;
376 //-----------------------------------------------------------------------------------------
380 // Description: adds an usb request to the queue.
381 // Returns status success when successful
383 virtual NTSTATUS
AddUSBRequest(IUSBRequest
* Request
) = 0;
385 //-----------------------------------------------------------------------------------------
389 // Description: cancels all requests
391 virtual NTSTATUS
CancelRequests() = 0;
393 //-----------------------------------------------------------------------------------------
397 // Description: creates an usb request
399 virtual NTSTATUS
CreateUSBRequest(IUSBRequest
**OutRequest
) = 0;
402 //=========================================================================================
404 // class IHubController
406 // Description: This class implements a hub controller
409 DECLARE_INTERFACE_(IHubController
, IUnknown
)
411 DEFINE_ABSTRACT_UNKNOWN()
413 //----------------------------------------------------------------------------------------
417 // Description: Initializes the hub controller
419 virtual NTSTATUS
Initialize(IN PDRIVER_OBJECT DriverObject
,
420 IN PHCDCONTROLLER Controller
,
421 IN PUSBHARDWAREDEVICE Device
,
422 IN BOOLEAN IsRootHubDevice
,
423 IN ULONG DeviceAddress
) = 0;
425 //----------------------------------------------------------------------------------------
427 // GetHubControllerDeviceObject
429 // Description: Returns the hub controller device object
431 virtual NTSTATUS
GetHubControllerDeviceObject(PDEVICE_OBJECT
* HubDeviceObject
) = 0;
435 typedef IHubController
*PHUBCONTROLLER
;
437 //=========================================================================================
439 // class IDispatchIrp
441 // Description: This class is used to handle irp dispatch requests
444 DECLARE_INTERFACE_(IDispatchIrp
, IUnknown
)
446 DEFINE_ABSTRACT_UNKNOWN()
448 //-----------------------------------------------------------------------------------------
452 // Description: This function handles all pnp requests
454 virtual NTSTATUS
HandlePnp(IN PDEVICE_OBJECT DeviceObject
,
455 IN OUT PIRP Irp
) = 0;
457 //-----------------------------------------------------------------------------------------
461 // Description: This function handles all power pnp requests
463 virtual NTSTATUS
HandlePower(IN PDEVICE_OBJECT DeviceObject
,
464 IN OUT PIRP Irp
) = 0;
466 //-----------------------------------------------------------------------------------------
468 // HandleDeviceControl
470 // Description: handles device io control requests
472 virtual NTSTATUS
HandleDeviceControl(IN PDEVICE_OBJECT DeviceObject
,
473 IN OUT PIRP Irp
) = 0;
476 typedef IDispatchIrp
*PDISPATCHIRP
;