ReactOS  0.4.13-dev-100-gc8611ae
fbtusb.h
Go to the documentation of this file.
1 // Copyright (c) 2004, Antony C. Roberts
2 
3 // Use of this file is subject to the terms
4 // described in the LICENSE.TXT file that
5 // accompanies this file.
6 //
7 // Your use of this file indicates your
8 // acceptance of the terms described in
9 // LICENSE.TXT.
10 //
11 // http://www.freebt.net
12 
13 #ifndef _FREEBT_H
14 #define _FREEBT_H
15 
16 #include <initguid.h>
17 #include <wdm.h>
18 #include <wmilib.h>
19 #include <wmistr.h>
20 #include <windef.h>
21 #include "usbdi.h"
22 #include "usbdlib.h"
23 
24 // Pull in all the command, event and structure definitions
25 #include "fbtHciDefs.h"
26 
27 // Standard USB Wireless/Bluetooth class, etc
28 #define FREEBT_USB_STDCLASS 0xE0 // Wireless Controller
29 #define FREEBT_USB_STDSUBCLASS 0x01 // RF Controller
30 #define FREEBT_USB_STDPROTOCOL 0x01 // Bluetooth Programming
31 
32 // Recommended Bluetooth Endpoints
33 #define FREEBT_STDENDPOINT_HCICMD 0x00 // HCI Command
34 #define FREEBT_STDENDPOINT_HCIEVENT 0x81 // HCI Event
35 #define FREEBT_STDENDPOINT_ACLIN 0x82 // HCI Data In
36 #define FREEBT_STDENDPOINT_ACLOUT 0x02 // HCI Data Out
37 #define FREEBT_STDENDPOINT_AUDIOIN 0x83 // SCO In
38 #define FREEBT_STDENDPOINT_AUDIOOUT 0x03 // SCO Out
39 
40 
41 #define OBTTAG (ULONG) 'OBTU'
42 
43 #undef ExAllocatePool
44 #define ExAllocatePool(type, size) ExAllocatePoolWithTag(type, size, OBTTAG);
45 
46 #if DBG
47 
48 #define FreeBT_DbgPrint(level, _x_) \
49  if((level) <= DebugLevel) { \
50  DbgPrint _x_; \
51  }
52 
53 #else
54 
55 #define FreeBT_DbgPrint(level, _x_)
56 
57 #endif
58 
59 typedef struct _GLOBALS
60 {
62 
63 } GLOBALS;
64 
65 #define IDLE_INTERVAL 5000
66 
67 typedef enum _PIPETYPE
68 {
75 
77 
78 typedef enum _DEVSTATE
79 {
80  NotStarted, // not started
81  Stopped, // device stopped
82  Working, // started and working
83  PendingStop, // stop pending
84  PendingRemove, // remove pending
85  SurpriseRemoved, // removed by surprise
86  Removed // removed
87 
88 } DEVSTATE;
89 
90 typedef enum _QUEUE_STATE
91 {
92  HoldRequests, // device is not started yet
93  AllowRequests, // device is ready to process
94  FailRequests // fail both existing and queued up requests
95 
96 } QUEUE_STATE;
97 
98 typedef enum _WDM_VERSION
99 {
104 
105 } WDM_VERSION;
106 
107 #define INITIALIZE_PNP_STATE(_Data_) \
108  (_Data_)->DeviceState = NotStarted;\
109  (_Data_)->PrevDevState = NotStarted;
110 
111 #define SET_NEW_PNP_STATE(_Data_, _state_) \
112  (_Data_)->PrevDevState = (_Data_)->DeviceState;\
113  (_Data_)->DeviceState = (_state_);
114 
115 #define RESTORE_PREVIOUS_PNP_STATE(_Data_) \
116  (_Data_)->DeviceState = (_Data_)->PrevDevState;
117 
118 
119 // registry path used for parameters
120 // global to all instances of the driver
121 #define FREEBT_REGISTRY_PARAMETERS_PATH L"\\REGISTRY\\Machine\\System\\CurrentControlSet\\SERVICES\\BULKUSB\\Parameters"
122 
123 typedef struct _FREEBT_PIPE_CONTEXT
124 {
127 
129 
130 // A structure representing the instance information associated with
131 // this particular device.
132 typedef struct _DEVICE_EXTENSION
133 {
134  // Functional Device Object
136 
137  // Device object we call when submitting Urbs
139 
140  // The bus driver object
142 
143  // Name buffer for our named Functional device object link
144  // The name is generated based on the driver's class GUID
146 
147  // Bus drivers set the appropriate values in this structure in response
148  // to an IRP_MN_QUERY_CAPABILITIES IRP. Function and filter drivers might
149  // alter the capabilities set by the bus driver.
151 
152  // Configuration Descriptor
154 
155  // Interface Information structure
157 
158  // Pipe context for the driver
160 
161  // current state of device
163 
164  // state prior to removal query
166 
167  // obtain and hold this lock while changing the device state,
168  // the queue state and while processing the queue.
170 
171  // current system power state
173 
174  // current device power state
176 
177  // Pending I/O queue state
179 
180  // Pending I/O queue
182 
183  // I/O Queue Lock
185 
187 
189 
191 
193 
194  // Selective Suspend variables
197  PUSB_IDLE_CALLBACK_INFO IdleCallbackInfo;
203 
204  // Default power state to power down to on self-susped
206 
207  // remote wakeup variables
212 
213  // Open handle count
215 
216  // Selective suspend model uses timers, dpcs and work item.
218 
220 
221  // This event is cleared when a DPC/Work Item is queued.
222  // and signaled when the work-item completes.
223  // This is essential to prevent the driver from unloading
224  // while we have DPC or work-item queued up.
226 
227  // WMI information
229 
230  // WDM version
232 
233  // Pipe type
235 
236  // User accessible object name
238 
239  // A never triggered event used for delaying execution
241 
242  // Significant pipes
248 
250 
251 
253 {
256 
258 
259 extern GLOBALS Globals;
260 extern ULONG DebugLevel;
261 
262 #endif
ULONG DebugLevel
Definition: fbtusb.c:26
USBD_PIPE_INFORMATION AudioOutPipe
Definition: fbtusb.h:247
struct _DEVICE_EXTENSION * PDEVICE_EXTENSION
KEVENT StopEvent
Definition: fbtusb.h:188
_PIPETYPE
Definition: fbtusb.h:67
PIRP WaitWakeIrp
Definition: fbtusb.h:208
BOOLEAN PipeOpen
Definition: fbtusb.h:125
UNICODE_STRING FreeBT_RegistryPath
Definition: fbtusb.h:61
KSPIN_LOCK IdleReqStateLock
Definition: fbtusb.h:201
DEVICE_CAPABILITIES
Definition: iotypes.h:927
FREEBT_PIPETYPE PipeType
Definition: fbtusb.h:126
struct _DEVICE_EXTENSION DEVICE_EXTENSION
enum _DEVSTATE DEVSTATE
ULONG OutStandingIO
Definition: fbtusb.h:190
enum _SYSTEM_POWER_STATE SYSTEM_POWER_STATE
enum _QUEUE_STATE QUEUE_STATE
SYSTEM_POWER_STATE SysPower
Definition: fbtusb.h:172
LONG FlagWWOutstanding
Definition: fbtusb.h:210
struct _FREEBT_PIPE_CONTEXT * PFREEBT_PIPE_CONTEXT
FREEBT_PIPETYPE PipeType
Definition: fbtusb.h:234
ULONG PowerDownLevel
Definition: fbtusb.h:205
_DEVSTATE
Definition: fbtusb.h:78
struct _FREEBT_PIPE_CONTEXT FREEBT_PIPE_CONTEXT
PUSBD_INTERFACE_INFORMATION UsbInterface
Definition: fbtusb.h:156
USBD_PIPE_INFORMATION EventPipe
Definition: fbtusb.h:243
KEVENT DelayEvent
Definition: fbtusb.h:240
_WDM_VERSION
Definition: fbtusb.h:98
long LONG
Definition: pedump.c:60
LONG SSRegistryEnable
Definition: fbtusb.h:196
LONG WaitWakeEnable
Definition: fbtusb.h:211
USBD_PIPE_INFORMATION DataOutPipe
Definition: fbtusb.h:245
USBD_PIPE_INFORMATION AudioInPipe
Definition: fbtusb.h:246
KSPIN_LOCK QueueLock
Definition: fbtusb.h:184
unsigned char BOOLEAN
DEVSTATE DeviceState
Definition: fbtusb.h:162
PDEVICE_EXTENSION DeviceExtension
Definition: fbtusb.h:254
KEVENT RemoveEvent
Definition: fbtusb.h:186
PDEVICE_OBJECT FunctionalDeviceObject
Definition: fbtusb.h:135
Definition: fbtusb.h:81
WMILIB_CONTEXT WmiLibInfo
Definition: fbtusb.h:228
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
KDPC DeferredProcCall
Definition: fbtusb.h:219
KTIMER Timer
Definition: fbtusb.h:217
WDM_VERSION WdmVersion
Definition: fbtusb.h:231
__wchar_t WCHAR
Definition: xmlstorage.h:180
USBD_PIPE_INFORMATION DataInPipe
Definition: fbtusb.h:244
KEVENT NoDpcWorkItemPendingEvent
Definition: fbtusb.h:225
KEVENT NoIdleReqPendEvent
Definition: fbtusb.h:202
PDEVICE_OBJECT PhysicalDeviceObject
Definition: fbtusb.h:141
enum _PIPETYPE FREEBT_PIPETYPE
Definition: fbtusb.h:82
PUSB_CONFIGURATION_DESCRIPTOR UsbConfigurationDescriptor
Definition: fbtusb.h:153
Definition: ketypes.h:687
struct _IRP_COMPLETION_CONTEXT IRP_COMPLETION_CONTEXT
LIST_ENTRY NewRequestsQueue
Definition: fbtusb.h:181
enum _WDM_VERSION WDM_VERSION
DEVICE_POWER_STATE DevPower
Definition: fbtusb.h:175
KSPIN_LOCK DevStateLock
Definition: fbtusb.h:169
UNICODE_STRING InterfaceName
Definition: fbtusb.h:145
Definition: typedefs.h:117
DEVICE_CAPABILITIES DeviceCapabilities
Definition: fbtusb.h:150
DEVSTATE PrevDevState
Definition: fbtusb.h:165
PDEVICE_OBJECT TopOfStackDeviceObject
Definition: fbtusb.h:138
KSPIN_LOCK IOCountLock
Definition: fbtusb.h:192
LONG IdleReqPend
Definition: fbtusb.h:199
LONG FlagWWCancel
Definition: fbtusb.h:209
struct _IRP_COMPLETION_CONTEXT * PIRP_COMPLETION_CONTEXT
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
PFREEBT_PIPE_CONTEXT PipeContext
Definition: fbtusb.h:159
_QUEUE_STATE
Definition: fbtusb.h:90
PUSB_IDLE_CALLBACK_INFO IdleCallbackInfo
Definition: fbtusb.h:197
unsigned int ULONG
Definition: retypes.h:1
QUEUE_STATE QueueState
Definition: fbtusb.h:178
struct _GLOBALS GLOBALS
Definition: fbtusb.h:86
PIRP PendingIdleIrp
Definition: fbtusb.h:198
GLOBALS Globals
Definition: clipbrd.c:13
LONG OpenHandleCount
Definition: fbtusb.h:214
LONG FreeIdleIrpCount
Definition: fbtusb.h:200
WCHAR wszDosDeviceName[50]
Definition: fbtusb.h:237