Rev 3520 | Rev 3745 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3520 | Rev 3577 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | terms of USB protocol - SET_ADDRESS + SET_CONFIGURATION, the first |
2 | terms of USB protocol - SET_ADDRESS + SET_CONFIGURATION, the first |
3 | configuration is always selected. The kernel also reads device descriptor to |
3 | configuration is always selected. The kernel also reads device descriptor to |
4 | print some information, reads and parses configuration descriptor. For every |
4 | print some information, reads and parses configuration descriptor. For every |
5 | interface the kernel looks for class code of this interface and loads the |
5 | interface the kernel looks for class code of this interface and loads the |
6 | corresponding COFF driver. Currently the correspondence is hardcoded into |
6 | corresponding COFF driver. Currently the correspondence is hardcoded into |
7 | the kernel code and looks as follows: 3 = usbhid.obj, 8 = usbstor.obj, |
7 | the kernel code and looks as follows: 3 = usbhid.obj, 7 = usbprint.obj, |
8 | 9 is handled by the kernel itself, other = usbother.obj. |
8 | 8 = usbstor.obj, 9 is handled by the kernel itself, other = usbother.obj. |
Line 9... | Line 9... | ||
9 | 9 | ||
10 | The driver must be standard driver in COFF format, exporting procedure |
10 | The driver must be standard driver in COFF format, exporting procedure |
11 | named "START" and a variable named "version". Loader calls "START" procedure |
11 | named "START" and a variable named "version". Loader calls "START" procedure |
12 | as stdcall with one parameter DRV_ENTRY = 1; if initialization is successful, |
12 | as stdcall with one parameter DRV_ENTRY = 1; if initialization is successful, |
Line 44... | Line 44... | ||
44 | void* pipe0, |
44 | void* pipe0, |
45 | void* configdescr, |
45 | void* configdescr, |
46 | void* interfacedescr |
46 | void* interfacedescr |
47 | ); |
47 | ); |
Line 48... | Line 48... | ||
48 | 48 | ||
49 | The parameter 'controlpipe' is a handle of the control pipe for endpoint zero |
49 | The parameter 'pipe0' is a handle of the control pipe for endpoint zero |
50 | of the device. It can be used as the argument of USBControlTransferAsync. |
50 | of the device. It can be used as the argument of USBControlTransferAsync. |
51 | The parameter 'configdescr' points to USB configuration descriptor |
51 | The parameter 'configdescr' points to USB configuration descriptor |
52 | and all associated data, as returned by GET_DESCRIPTOR request. |
52 | and all associated data, as returned by GET_DESCRIPTOR request. |
53 | The total length of all associated data is contained in the configuration |
53 | The total length of all associated data is contained in the configuration |
Line 91... | Line 91... | ||
91 | The parameter 'type' selects the type of the endpoint as defined by USB: |
91 | The parameter 'type' selects the type of the endpoint as defined by USB: |
92 | 0 = control, 1 = isochronous (not supported yet), 2 = bulk, 3 = interrupt. |
92 | 0 = control, 1 = isochronous (not supported yet), 2 = bulk, 3 = interrupt. |
93 | The parameter 'interval' is ignored for control and bulk endpoints. |
93 | The parameter 'interval' is ignored for control and bulk endpoints. |
94 | For interrupt endpoints, it sets the polling interval in milliseconds. |
94 | For interrupt endpoints, it sets the polling interval in milliseconds. |
95 | The function returns a handle to the pipe or NULL on failure. |
95 | The function returns a handle to the pipe or NULL on failure. |
- | 96 | The output handle becomes invalid when a) it is explicitly closed with |
|
- | 97 | the following function or b) the function DeviceDisconnected provided |
|
- | 98 | by the driver returns. |
|
- | 99 | ||
- | 100 | void __stdcall USBClosePipe( |
|
- | 101 | void* pipe |
|
- | 102 | ); |
|
- | 103 | ||
- | 104 | Releases all resources associated with the given pipe. The only parameter |
|
- | 105 | must be a handle returned by USBOpenPipe. |
|
- | 106 | When a device is disconnected, all associated pipes are closed by the kernel; |
|
- | 107 | there is no need to ever call this function if all pipes are used continuously |
|
- | 108 | while a device is connected. |
|
Line 96... | Line 109... | ||
96 | 109 | ||
97 | void* __stdcall USBNormalTransferAsync( |
110 | void* __stdcall USBNormalTransferAsync( |
98 | void* pipe, |
111 | void* pipe, |
99 | void* buffer, |
112 | void* buffer, |
Line 102... | Line 115... | ||
102 | void* calldata, |
115 | void* calldata, |
103 | int flags |
116 | int flags |
104 | ); |
117 | ); |
105 | void* __stdcall USBControlTransferAsync( |
118 | void* __stdcall USBControlTransferAsync( |
106 | void* pipe, |
119 | void* pipe, |
107 | void* config, |
120 | void* setup, |
108 | void* buffer, |
121 | void* buffer, |
109 | int size, |
122 | int size, |
110 | void* callback, |
123 | void* callback, |
111 | void* calldata, |
124 | void* calldata, |
112 | int flags |
125 | int flags |
Line 114... | Line 127... | ||
114 | 127 | ||
115 | The first function inserts a bulk or interrupt transfer to the transfer queue |
128 | The first function inserts a bulk or interrupt transfer to the transfer queue |
116 | for given pipe. Type and direction of transfer are fixed for bulk and interrupt |
129 | for given pipe. Type and direction of transfer are fixed for bulk and interrupt |
117 | endpoints and are set in USBOpenPipe. The second function inserts a control |
130 | endpoints and are set in USBOpenPipe. The second function inserts a control |
118 | transfer to the transfer queue for given pipe. Direction of a control transfer |
131 | transfer to the transfer queue for given pipe. Direction of a control transfer |
119 | is concluded from 'config' packet, bit 7 of byte 0 is set for IN transfers |
132 | is concluded from 'setup' packet, bit 7 of byte 0 is set for IN transfers |
120 | and cleared for OUT transfers. These function return immediately; when data |
133 | and cleared for OUT transfers. These function return immediately; when data |
Line 121... | Line 134... | ||
121 | are transferred, the callback function will be called. |
134 | are transferred, the callback function will be called. |
122 | 135 | ||
123 | The parameter 'pipe' is a handle returned by USBOpenPipe. |
136 | The parameter 'pipe' is a handle returned by USBOpenPipe. |
124 | The parameter 'config' of USBControlTransferAsync points to 8-byte |
137 | The parameter 'setup' of USBControlTransferAsync points to 8-byte |
125 | configuration packet as defined by USB. |
138 | configuration packet as defined by USB. |
126 | The parameter 'buffer' is a pointer to buffer. For IN transfers, it will be |
139 | The parameter 'buffer' is a pointer to buffer. For IN transfers, it will be |
127 | filled with the data. For OUT transfers, it should contain data to be |
140 | filled with the data. For OUT transfers, it should contain data to be |
Line 172... | Line 185... | ||
172 | USB_STATUS_UNDERRUN = 9 ; too few data from endpoint |
185 | USB_STATUS_UNDERRUN = 9 ; too few data from endpoint |
173 | USB_STATUS_BUFOVERRUN = 12 ; overflow of internal controller buffer |
186 | USB_STATUS_BUFOVERRUN = 12 ; overflow of internal controller buffer |
174 | ; possible only for isochronous transfers |
187 | ; possible only for isochronous transfers |
175 | USB_STATUS_BUFUNDERRUN = 13 ; underflow of internal controller buffer |
188 | USB_STATUS_BUFUNDERRUN = 13 ; underflow of internal controller buffer |
176 | ; possible only for isochronous transfers |
189 | ; possible only for isochronous transfers |
- | 190 | USB_STATUS_CLOSED = 16 ; pipe closed, either explicitly with USBClosePipe |
|
177 | USB_STATUS_DISCONNECTED = 16 ; device disconnected |
191 | ; or due to device disconnect |
Line 178... | Line 192... | ||
178 | 192 | ||
179 | If several transfers are queued for the same pipe, their callback functions |
193 | If several transfers are queued for the same pipe, their callback functions |
- | 194 | are called in the same order as they were queued. |
|
180 | are called in the same order as they were queued. |
195 | When a pipe is closed, either explicitly with USBClosePipe, or |
181 | When the device is disconnected, all callback functions are called |
196 | implicitly due to device disconnect, all callback functions are called |
182 | with USB_STATUS_DISCONNECTED. The call to DeviceDisconnected() occurs after |
197 | with USB_STATUS_CLOSED. The call to DeviceDisconnected() occurs after |