ReactOS 0.4.15-dev-8145-ga541a46
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
59typedef struct _GLOBALS
60{
62
64
65#define IDLE_INTERVAL 5000
66
67typedef enum _PIPETYPE
68{
75
77
78typedef 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
89
90typedef 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
97
98typedef enum _WDM_VERSION
99{
104
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
124{
127
129
130// A structure representing the instance information associated with
131// this particular device.
132typedef 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
259extern GLOBALS Globals;
260extern ULONG DebugLevel;
261
262#endif
unsigned char BOOLEAN
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
_WDM_VERSION
Definition: fbtusb.h:99
@ WinXpOrBetter
Definition: fbtusb.h:100
@ Win2kOrBetter
Definition: fbtusb.h:101
@ Win98OrBetter
Definition: fbtusb.h:103
@ WinMeOrBetter
Definition: fbtusb.h:102
struct _IRP_COMPLETION_CONTEXT * PIRP_COMPLETION_CONTEXT
struct _DEVICE_EXTENSION DEVICE_EXTENSION
enum _QUEUE_STATE QUEUE_STATE
struct _FREEBT_PIPE_CONTEXT * PFREEBT_PIPE_CONTEXT
enum _PIPETYPE FREEBT_PIPETYPE
_PIPETYPE
Definition: fbtusb.h:68
@ HciEventPipe
Definition: fbtusb.h:70
@ AclDataOut
Definition: fbtusb.h:72
@ SCODataIn
Definition: fbtusb.h:73
@ AclDataIn
Definition: fbtusb.h:71
@ HciCommandPipe
Definition: fbtusb.h:69
@ SCODataOut
Definition: fbtusb.h:74
struct _FREEBT_PIPE_CONTEXT FREEBT_PIPE_CONTEXT
struct _IRP_COMPLETION_CONTEXT IRP_COMPLETION_CONTEXT
_DEVSTATE
Definition: fbtusb.h:79
@ Removed
Definition: fbtusb.h:86
@ Stopped
Definition: fbtusb.h:81
@ NotStarted
Definition: fbtusb.h:80
@ Working
Definition: fbtusb.h:82
@ PendingStop
Definition: fbtusb.h:83
@ SurpriseRemoved
Definition: fbtusb.h:85
@ PendingRemove
Definition: fbtusb.h:84
ULONG DebugLevel
Definition: fbtusb.c:26
_QUEUE_STATE
Definition: fbtusb.h:91
@ AllowRequests
Definition: fbtusb.h:93
@ HoldRequests
Definition: fbtusb.h:92
@ FailRequests
Definition: fbtusb.h:94
enum _DEVSTATE DEVSTATE
struct _DEVICE_EXTENSION * PDEVICE_EXTENSION
struct _GLOBALS GLOBALS
enum _WDM_VERSION WDM_VERSION
GLOBALS Globals
Definition: clipbrd.c:13
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
enum _SYSTEM_POWER_STATE SYSTEM_POWER_STATE
long LONG
Definition: pedump.c:60
PDEVICE_OBJECT FunctionalDeviceObject
Definition: fbtusb.h:135
KEVENT DelayEvent
Definition: fbtusb.h:240
USBD_PIPE_INFORMATION DataOutPipe
Definition: fbtusb.h:245
PUSBD_INTERFACE_INFORMATION UsbInterface
Definition: fbtusb.h:156
LONG IdleReqPend
Definition: fbtusb.h:199
KSPIN_LOCK IdleReqStateLock
Definition: fbtusb.h:201
DEVICE_POWER_STATE DevPower
Definition: fbtusb.h:175
LONG FreeIdleIrpCount
Definition: fbtusb.h:200
PDEVICE_OBJECT TopOfStackDeviceObject
Definition: fbtusb.h:138
LONG OpenHandleCount
Definition: fbtusb.h:214
LIST_ENTRY NewRequestsQueue
Definition: fbtusb.h:181
KSPIN_LOCK DevStateLock
Definition: fbtusb.h:169
WMILIB_CONTEXT WmiLibInfo
Definition: fbtusb.h:228
DEVICE_CAPABILITIES DeviceCapabilities
Definition: fbtusb.h:150
PIRP WaitWakeIrp
Definition: fbtusb.h:208
KEVENT RemoveEvent
Definition: fbtusb.h:186
ULONG PowerDownLevel
Definition: fbtusb.h:205
SYSTEM_POWER_STATE SysPower
Definition: fbtusb.h:172
USBD_PIPE_INFORMATION EventPipe
Definition: fbtusb.h:243
KEVENT NoIdleReqPendEvent
Definition: fbtusb.h:202
LONG FlagWWOutstanding
Definition: fbtusb.h:210
USBD_PIPE_INFORMATION AudioInPipe
Definition: fbtusb.h:246
KSPIN_LOCK IOCountLock
Definition: fbtusb.h:192
KTIMER Timer
Definition: fbtusb.h:217
LONG FlagWWCancel
Definition: fbtusb.h:209
USBD_PIPE_INFORMATION AudioOutPipe
Definition: fbtusb.h:247
PIRP PendingIdleIrp
Definition: fbtusb.h:198
ULONG OutStandingIO
Definition: fbtusb.h:190
QUEUE_STATE QueueState
Definition: fbtusb.h:178
WCHAR wszDosDeviceName[50]
Definition: fbtusb.h:237
WDM_VERSION WdmVersion
Definition: fbtusb.h:231
USBD_PIPE_INFORMATION DataInPipe
Definition: fbtusb.h:244
PUSB_IDLE_CALLBACK_INFO IdleCallbackInfo
Definition: fbtusb.h:197
PFREEBT_PIPE_CONTEXT PipeContext
Definition: fbtusb.h:159
PDEVICE_OBJECT PhysicalDeviceObject
Definition: fbtusb.h:141
LONG WaitWakeEnable
Definition: fbtusb.h:211
UNICODE_STRING InterfaceName
Definition: fbtusb.h:145
DEVSTATE DeviceState
Definition: fbtusb.h:162
KSPIN_LOCK QueueLock
Definition: fbtusb.h:184
LONG SSRegistryEnable
Definition: fbtusb.h:196
FREEBT_PIPETYPE PipeType
Definition: fbtusb.h:234
KEVENT StopEvent
Definition: fbtusb.h:188
KDPC DeferredProcCall
Definition: fbtusb.h:219
PUSB_CONFIGURATION_DESCRIPTOR UsbConfigurationDescriptor
Definition: fbtusb.h:153
KEVENT NoDpcWorkItemPendingEvent
Definition: fbtusb.h:225
DEVSTATE PrevDevState
Definition: fbtusb.h:165
BOOLEAN PipeOpen
Definition: fbtusb.h:125
FREEBT_PIPETYPE PipeType
Definition: fbtusb.h:126
UNICODE_STRING FreeBT_RegistryPath
Definition: fbtusb.h:61
PDEVICE_EXTENSION DeviceExtension
Definition: fbtusb.h:254
Definition: ketypes.h:699
Definition: typedefs.h:120
uint32_t ULONG
Definition: typedefs.h:59
DEVICE_CAPABILITIES
Definition: iotypes.h:965
__wchar_t WCHAR
Definition: xmlstorage.h:180