[INF]
[reactos.git] / drivers / usb / nt4compat / usbdrv / events.h
1 #ifndef __EVENTS_H
2 #define __EVENTS_H
3
4 //event definitions
5
6 #define MAX_EVENTS 128
7 #define MAX_TIMER_SVCS 24
8
9 #define USB_EVENT_FLAG_ACTIVE 0x80000000
10
11 #define USB_EVENT_FLAG_QUE_TYPE 0x000000FF
12 #define USB_EVENT_FLAG_QUE_RESET 0x01
13 #define USB_EVENT_FLAG_NOQUE 0x00
14
15 #define USB_EVENT_DEFAULT 0x00 //as a placeholder
16 #define USB_EVENT_INIT_DEV_MGR 0x01
17 #define USB_EVENT_HUB_POLL 0x02
18 #define USB_EVENT_WAIT_RESET_PORT 0x03
19 #define USB_EVENT_CLEAR_TT_BUFFER 0x04
20
21 typedef VOID ( *PROCESS_QUEUE )(
22 PLIST_HEAD event_list,
23 struct _USB_EVENT_POOL *event_pool,
24 struct _USB_EVENT *usb_event,
25 struct _USB_EVENT *out_event
26 );
27
28 typedef VOID ( *PROCESS_EVENT )(
29 PUSB_DEV dev,
30 ULONG event,
31 ULONG context,
32 ULONG param
33 );
34
35 typedef struct _USB_EVENT
36 {
37 LIST_ENTRY event_link;
38 ULONG flags;
39 ULONG event;
40 PUSB_DEV pdev;
41 ULONG context;
42 ULONG param;
43 struct _USB_EVENT *pnext; //vertical queue for serialized operation
44 PROCESS_EVENT process_event;
45 PROCESS_QUEUE process_queue;
46
47 } USB_EVENT, *PUSB_EVENT;
48
49 typedef struct _USB_EVENT_POOL
50 {
51 PUSB_EVENT event_array;
52 LIST_HEAD free_que;
53 LONG free_count;
54 LONG total_count;
55 KSPIN_LOCK pool_lock;
56
57 } USB_EVENT_POOL, *PUSB_EVENT_POOL;
58
59 BOOLEAN
60 init_event_pool(
61 PUSB_EVENT_POOL pool
62 );
63
64 BOOLEAN
65 free_event(
66 PUSB_EVENT_POOL pool,
67 PUSB_EVENT pevent
68 ); //add qhs till pnext == NULL
69
70 PUSB_EVENT
71 alloc_event(
72 PUSB_EVENT_POOL pool,
73 LONG count
74 ); //null if failed
75
76 BOOLEAN
77 destroy_event_pool(
78 PUSB_EVENT_POOL pool
79 );
80
81 VOID
82 lock_event_pool(
83 PUSB_EVENT_POOL pool
84 );
85
86 VOID
87 unlock_event_pool(
88 PUSB_EVENT_POOL pool
89 );
90
91 #define DEV_MGR_TIMER_INTERVAL_NS ( 10 * 1000 * 10 ) //unit 100 ns
92 #define DEV_MGR_TIMER_INTERVAL_MS 10
93
94 typedef VOID ( *TIMER_SVC_HANDLER )(PUSB_DEV dev, PVOID context);
95
96 typedef struct _TIMER_SVC
97 {
98 LIST_ENTRY timer_svc_link;
99 ULONG counter;
100 ULONG threshold;
101 ULONG context;
102 PUSB_DEV pdev;
103 TIMER_SVC_HANDLER func;
104
105 } TIMER_SVC, *PTIMER_SVC;
106
107 typedef struct _TIMER_SVC_POOL
108 {
109 PTIMER_SVC timer_svc_array;
110 LIST_HEAD free_que;
111 LONG free_count;
112 LONG total_count;
113 KSPIN_LOCK pool_lock;
114
115 } TIMER_SVC_POOL, *PTIMER_SVC_POOL;
116
117 BOOLEAN
118 init_timer_svc_pool(
119 PTIMER_SVC_POOL pool
120 );
121 BOOLEAN
122 free_timer_svc(
123 PTIMER_SVC_POOL pool,
124 PTIMER_SVC ptimer
125 );
126
127 PTIMER_SVC
128 alloc_timer_svc(
129 PTIMER_SVC_POOL pool,
130 LONG count
131 ); //null if failed
132
133 BOOLEAN
134 destroy_timer_svc_pool(
135 PTIMER_SVC_POOL pool
136 );
137
138 VOID
139 lock_timer_svc_pool(
140 PTIMER_SVC_POOL pool
141 );
142
143 VOID
144 unlock_timer_svc_pool(
145 PTIMER_SVC_POOL pool
146 );
147
148 #endif