Create a branch for cmake bringup.
[reactos.git] / drivers / usb / nt4compat / usbdriver / hcd.h
1 #ifndef __HCD_H__
2 #define __HCD_H__
3
4 #define HCD_TYPE_MASK 0xf0
5 #define HCD_TYPE_UHCI 0x10
6 #define HCD_TYPE_OHCI 0x20
7 #define HCD_TYPE_EHCI 0x30
8
9 #define hcd_type( hCD ) ( ( ( hCD )->flags ) & HCD_TYPE_MASK )
10 #define usb2( hCD ) ( hcd_type( hCD ) == HCD_TYPE_EHCI )
11
12 #define HCD_ID_MASK 0xf
13
14 #define HCD_DISP_READ_PORT_COUNT 1 // the param is a pointer to UCHAR
15 #define HCD_DISP_READ_RH_DEV_CHANGE 2 // the param is a buffer to hold conn change on all the port
16 // must have the rh dev_lock acquired
17
18 struct _HCD;
19 struct _USB_DEV_MANAGER;
20 struct _USB_DEV;
21 struct _USB_ENDPOINT;
22 struct _URB;
23
24 typedef VOID ( *PHCD_SET_DEV_MGR )( struct _HCD* hcd, struct _USB_DEV_MANAGER *dev_mgr );
25 typedef struct _USB_DEV_MANAGER* ( *PHCD_GET_DEV_MGR )( struct _HCD* hcd );
26 typedef ULONG ( *PHCD_GET_TYPE )( struct _HCD* hcd );
27 typedef VOID ( *PHCD_SET_ID )( struct _HCD* hcd, UCHAR id );
28 typedef UCHAR ( *PHCD_GET_ID )( struct _HCD* hcd );
29 typedef UCHAR ( *PHCD_ALLOC_ADDR )( struct _HCD* hcd );
30 typedef VOID ( *PHCD_FREE_ADDR )( struct _HCD* hcd, UCHAR addr );
31 typedef NTSTATUS ( *PHCD_SUBMIT_URB )( struct _HCD* hcd, struct _USB_DEV *pdev, struct _USB_ENDPOINT *pendp, struct _URB *purb );
32 typedef VOID ( *PHCD_GENERIC_URB_COMPLETION )( struct _URB *purb, PVOID context ); //we can get te hcd from purb
33 typedef struct _USB_DEV* ( *PHCD_GET_ROOT_HUB )( struct _HCD* hcd );
34 typedef VOID ( *PHCD_SET_ROOT_HUB )( struct _HCD* hcd, struct _USB_DEV *root_hub );
35 typedef BOOLEAN ( *PHCD_REMOVE_DEVICE )( struct _HCD* hcd, struct _USB_DEV *pdev );
36 typedef BOOLEAN ( *PHCD_RH_RESET_PORT )( struct _HCD* hcd, UCHAR port_idx ); //must have the rh dev_lock acquired
37 typedef BOOLEAN ( *PHCD_RELEASE )( struct _HCD* hcd ); //must have the rh dev_lock acquired
38 typedef NTSTATUS( *PHCD_CANCEL_URB)( struct _HCD* hcd, struct _USB_DEV *pdev, struct _USB_ENDPOINT* pendp, struct _URB *purb );
39 typedef BOOLEAN ( *PHCD_START )( struct _HCD* hcd ); //must have the rh dev_lock acquired
40 typedef NTSTATUS ( *PHCD_DISPATCH )( struct _HCD* hcd, LONG disp_code, PVOID param ); // locking depends on type of code
41
42 typedef struct _HCD
43 {
44 PHCD_SET_DEV_MGR hcd_set_dev_mgr;
45 PHCD_GET_DEV_MGR hcd_get_dev_mgr;
46 PHCD_GET_TYPE hcd_get_type;
47 PHCD_SET_ID hcd_set_id;
48 PHCD_GET_ID hcd_get_id;
49 PHCD_ALLOC_ADDR hcd_alloc_addr;
50 PHCD_FREE_ADDR hcd_free_addr;
51 PHCD_SUBMIT_URB hcd_submit_urb;
52 PHCD_GENERIC_URB_COMPLETION hcd_generic_urb_completion;
53 PHCD_GET_ROOT_HUB hcd_get_root_hub;
54 PHCD_SET_ROOT_HUB hcd_set_root_hub;
55 PHCD_REMOVE_DEVICE hcd_remove_device;
56 PHCD_RH_RESET_PORT hcd_rh_reset_port;
57 PHCD_RELEASE hcd_release;
58 PHCD_CANCEL_URB hcd_cancel_urb;
59 PHCD_START hcd_start;
60 PHCD_DISPATCH hcd_dispatch;
61
62 //interfaces for all the host controller
63 ULONG flags; //hcd types | hcd id
64 ULONG conn_count; //statics for connection activities
65 struct _USB_DEV_MANAGER *dev_mgr; //pointer manager
66 UCHAR dev_addr_map[ 128 / 8 ]; //bitmap for the device addrs
67 struct _DEVICE_EXTENSION *pdev_ext;
68
69 } HCD, *PHCD;
70
71 #endif