1 | ;;; -*- asm -*-
|
---|
2 | ;;;
|
---|
3 | ;;;-----------------------------------------------------------------------------
|
---|
4 | ;;; USB Descriptor(s)
|
---|
5 | ;;;-----------------------------------------------------------------------------
|
---|
6 | ;;; Copyright 2005..2007 Kolja Waschk, ixo.de
|
---|
7 | ;;; Modified by LAP for FPGA4U project, Jan 2007. lap.epfl.ch
|
---|
8 | ;;;-----------------------------------------------------------------------------
|
---|
9 | ;;; Code based on USRP2 firmware (GNU Radio Project), version 3.0.2,
|
---|
10 | ;;; Copyright 2003 Free Software Foundation, Inc.
|
---|
11 | ;;;-----------------------------------------------------------------------------
|
---|
12 | ;;; This code is part of usbjtag. usbjtag is free software; you can redistribute
|
---|
13 | ;;; it and/or modify it under the terms of the GNU General Public License as
|
---|
14 | ;;; published by the Free Software Foundation; either version 2 of the License,
|
---|
15 | ;;; or (at your option) any later version. usbjtag is distributed in the hope
|
---|
16 | ;;; that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
---|
17 | ;;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | ;;; GNU General Public License for more details. You should have received a
|
---|
19 | ;;; copy of the GNU General Public License along with this program in the file
|
---|
20 | ;;; COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
|
---|
21 | ;;; St, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
22 | ;;;-----------------------------------------------------------------------------
|
---|
23 |
|
---|
24 | .module usb_descriptors
|
---|
25 |
|
---|
26 | VID = 0x09FB ; Changed by LAP to match Altera VID
|
---|
27 | PID = 0x6001 ; Changed by LAP to match Altera USBBlaster PID
|
---|
28 | VERSION = 0x0400 ; Product Version (4 indicates *BM device)
|
---|
29 | USB_VER = 0x0110 ; Support USB version 1.10
|
---|
30 | USB_ATTR = 0x80 ; Bus powered, not self-powered, no remote wakeup
|
---|
31 | FTD_ATTR = 0x001C ; Set USB version, use version string, enable suspend PD
|
---|
32 | MAX_POWER = 75 ; need 2*75 mA max
|
---|
33 |
|
---|
34 | DSCR_DEVICE = 1 ; Descriptor type: Device
|
---|
35 | DSCR_CONFIG = 2 ; Descriptor type: Configuration
|
---|
36 | DSCR_STRING = 3 ; Descriptor type: String
|
---|
37 | DSCR_INTRFC = 4 ; Descriptor type: Interface
|
---|
38 | DSCR_ENDPNT = 5 ; Descriptor type: Endpoint
|
---|
39 | DSCR_DEVQUAL = 6 ; Descriptor type: Device Qualifier
|
---|
40 |
|
---|
41 | DSCR_DEVICE_LEN = 18
|
---|
42 | DSCR_CONFIG_LEN = 9
|
---|
43 | DSCR_INTRFC_LEN = 9
|
---|
44 | DSCR_ENDPNT_LEN = 7
|
---|
45 | DSCR_DEVQUAL_LEN = 10
|
---|
46 |
|
---|
47 | ET_CONTROL = 0 ; Endpoint type: Control
|
---|
48 | ET_ISO = 1 ; Endpoint type: Isochronous
|
---|
49 | ET_BULK = 2 ; Endpoint type: Bulk
|
---|
50 | ET_INT = 3 ; Endpoint type: Interrupt
|
---|
51 |
|
---|
52 | ;;; --------------------------------------------------------
|
---|
53 | ;;; external ram data
|
---|
54 | ;;;--------------------------------------------------------
|
---|
55 |
|
---|
56 | .area USBDESCSEG (XDATA)
|
---|
57 |
|
---|
58 | ;;; ----------------------------------------------------------------
|
---|
59 | ;;; descriptors used when operating at high speed (480Mb/sec)
|
---|
60 | ;;; ----------------------------------------------------------------
|
---|
61 |
|
---|
62 | .even ; descriptors must be 2-byte aligned for SUDPTR{H,L} to work
|
---|
63 |
|
---|
64 | ;; The .even directive isn't really honored by the linker. Bummer!
|
---|
65 | ;; (There's no way to specify an alignment requirement for a given area,
|
---|
66 | ;; hence when they're concatenated together, even doesn't work.)
|
---|
67 | ;;
|
---|
68 | ;; We work around this by telling the linker to put USBDESCSEG
|
---|
69 | ;; at 0xE000 absolute. This means that the maximimum length of this
|
---|
70 | ;; segment is 480 bytes, leaving room for the two hash slots
|
---|
71 | ;; at 0xE1EO to 0xE1FF.
|
---|
72 | ;; Note from LAP: TODOOOOO
|
---|
73 |
|
---|
74 | _high_speed_device_descr::
|
---|
75 | .db DSCR_DEVICE_LEN
|
---|
76 | .db DSCR_DEVICE
|
---|
77 | _dscr_usbver::
|
---|
78 | .db <USB_VER ; Specification version (LSB)
|
---|
79 | .db >USB_VER ; Specification version (MSB)
|
---|
80 | .db 0x00 ; device class (vendor specific)
|
---|
81 | .db 0x00 ; device subclass (vendor specific)
|
---|
82 | .db 0x00 ; device protocol (vendor specific)
|
---|
83 | .db 64 ; bMaxPacketSize0 for endpoint 0
|
---|
84 | _dscr_vidpidver::
|
---|
85 | .db <VID ; idVendor
|
---|
86 | .db >VID ; idVendor
|
---|
87 | .db <PID ; idProduct
|
---|
88 | .db >PID ; idProduct
|
---|
89 | .db <VERSION ; bcdDevice
|
---|
90 | .db >VERSION ; bcdDevice
|
---|
91 | _dscr_strorder::
|
---|
92 | .db SI_VENDOR ; iManufacturer (string index)
|
---|
93 | .db SI_PRODUCT ; iProduct (string index)
|
---|
94 | .db SI_SERIAL ; iSerial number (string index)
|
---|
95 | .db 1 ; bNumConfigurations
|
---|
96 |
|
---|
97 | .even
|
---|
98 | _high_speed_devqual_descr::
|
---|
99 | .db DSCR_DEVQUAL_LEN
|
---|
100 | .db DSCR_DEVQUAL
|
---|
101 | .db <USB_VER ; bcdUSB (LSB)
|
---|
102 | .db >USB_VER ; bcdUSB (MSB)
|
---|
103 | .db 0xFF ; bDeviceClass
|
---|
104 | .db 0xFF ; bDeviceSubClass
|
---|
105 | .db 0xFF ; bDeviceProtocol
|
---|
106 | .db 64 ; bMaxPacketSize0
|
---|
107 | .db 1 ; bNumConfigurations (one config at 12Mb/sec)
|
---|
108 | .db 0 ; bReserved
|
---|
109 |
|
---|
110 | .even
|
---|
111 | _high_speed_config_descr::
|
---|
112 | .db DSCR_CONFIG_LEN
|
---|
113 | .db DSCR_CONFIG
|
---|
114 | .db <(_high_speed_config_descr_end - _high_speed_config_descr) ; LSB
|
---|
115 | .db >(_high_speed_config_descr_end - _high_speed_config_descr) ; MSB
|
---|
116 | .db 2 ; bNumInterfaces
|
---|
117 | .db 1 ; bConfigurationValue
|
---|
118 | .db 0 ; iConfiguration
|
---|
119 | _dscr_attrpow::
|
---|
120 | .db USB_ATTR ; bmAttributes
|
---|
121 | .db MAX_POWER ; bMaxPower [Unit: 0.5 mA]
|
---|
122 |
|
---|
123 | ;; interface descriptor
|
---|
124 |
|
---|
125 | .db DSCR_INTRFC_LEN
|
---|
126 | .db DSCR_INTRFC
|
---|
127 | .db 0 ; bInterfaceNumber (zero based)
|
---|
128 | .db 0 ; bAlternateSetting
|
---|
129 | .db 2 ; bNumEndpoints
|
---|
130 | .db 0xFF ; bInterfaceClass (vendor specific)
|
---|
131 | .db 0xFF ; bInterfaceSubClass (vendor specific)
|
---|
132 | .db 0xFF ; bInterfaceProtocol (vendor specific)
|
---|
133 | .db SI_PRODUCT ; iInterface (description)
|
---|
134 |
|
---|
135 | ;; endpoint descriptor
|
---|
136 |
|
---|
137 | .db DSCR_ENDPNT_LEN
|
---|
138 | .db DSCR_ENDPNT
|
---|
139 | .db 0x81 ; bEndpointAddress (ep 1 IN)
|
---|
140 | .db ET_BULK ; bmAttributes
|
---|
141 | .db <64 ; wMaxPacketSize (LSB)
|
---|
142 | .db >64 ; wMaxPacketSize (MSB)
|
---|
143 | .db 0 ; bInterval (iso only)
|
---|
144 |
|
---|
145 | ;; endpoint descriptor
|
---|
146 |
|
---|
147 | .db DSCR_ENDPNT_LEN
|
---|
148 | .db DSCR_ENDPNT
|
---|
149 | .db 0x02 ; bEndpointAddress (ep 2 OUT)
|
---|
150 | .db ET_BULK ; bmAttributes
|
---|
151 | .db <64 ; wMaxPacketSize (LSB)
|
---|
152 | .db >64 ; wMaxPacketSize (MSB)
|
---|
153 | .db 0 ; bInterval (iso only)
|
---|
154 |
|
---|
155 | ;; interface descriptor
|
---|
156 |
|
---|
157 | .db DSCR_INTRFC_LEN
|
---|
158 | .db DSCR_INTRFC
|
---|
159 | .db 1 ; bInterfaceNumber (zero based)
|
---|
160 | .db 0 ; bAlternateSetting
|
---|
161 | .db 2 ; bNumEndpoints
|
---|
162 | .db 0xFF ; bInterfaceClass (vendor specific)
|
---|
163 | .db 0xFF ; bInterfaceSubClass (vendor specific)
|
---|
164 | .db 0xFF ; bInterfaceProtocol (vendor specific)
|
---|
165 | .db SI_PRODUCT ; iInterface (description)
|
---|
166 |
|
---|
167 | ;; endpoint descriptor
|
---|
168 |
|
---|
169 | .db DSCR_ENDPNT_LEN
|
---|
170 | .db DSCR_ENDPNT
|
---|
171 | .db 0x06 ; bEndpointAddress (ep 6 OUT)
|
---|
172 | .db ET_BULK ; bmAttributes
|
---|
173 | .db 0x00 ; wMaxPacketSize (LSB)
|
---|
174 | .db 0x02 ; wMaxPacketSize (MSB)
|
---|
175 | .db 0x00 ; Polling interval
|
---|
176 |
|
---|
177 | ;; endpoint descriptor
|
---|
178 | .db DSCR_ENDPNT_LEN
|
---|
179 | .db DSCR_ENDPNT
|
---|
180 | .db 0x88 ; bEndpointAddress (ep 8 IN)
|
---|
181 | .db ET_BULK ; bmAttributes
|
---|
182 | .db 0x00 ; wMaxPacketSize (LSB)
|
---|
183 | .db 0x02 ; wMaxPacketSize (MSB)
|
---|
184 | .db 0x00 ; Polling interval
|
---|
185 |
|
---|
186 | _high_speed_config_descr_end:
|
---|
187 |
|
---|
188 | ;;; ----------------------------------------------------------------
|
---|
189 | ;;; descriptors used when operating at full speed (12Mb/sec)
|
---|
190 | ;;; ----------------------------------------------------------------
|
---|
191 |
|
---|
192 | .even
|
---|
193 | _full_speed_device_descr::
|
---|
194 | .db DSCR_DEVICE_LEN
|
---|
195 | .db DSCR_DEVICE
|
---|
196 | .db <USB_VER ; Specification version (LSB)
|
---|
197 | .db >USB_VER ; Specification version (MSB)
|
---|
198 | .db 0x00 ; device class (vendor specific)
|
---|
199 | .db 0x00 ; device subclass (vendor specific)
|
---|
200 | .db 0x00 ; device protocol (vendor specific)
|
---|
201 | .db 64 ; bMaxPacketSize0 for endpoint 0
|
---|
202 | .db <VID ; idVendor
|
---|
203 | .db >VID ; idVendor
|
---|
204 | .db <PID ; idProduct
|
---|
205 | .db >PID ; idProduct
|
---|
206 | .db <VERSION ; bcdDevice
|
---|
207 | .db >VERSION ; bcdDevice
|
---|
208 | .db SI_VENDOR ; iManufacturer (string index)
|
---|
209 | .db SI_PRODUCT ; iProduct (string index)
|
---|
210 | .db SI_SERIAL ; iSerial number (None)
|
---|
211 | .db 1 ; bNumConfigurations
|
---|
212 |
|
---|
213 | ;;; describes the other speed (480Mb/sec)
|
---|
214 | .even
|
---|
215 | _full_speed_devqual_descr::
|
---|
216 | .db DSCR_DEVQUAL_LEN
|
---|
217 | .db DSCR_DEVQUAL
|
---|
218 | .db <USB_VER ; bcdUSB
|
---|
219 | .db >USB_VER ; bcdUSB
|
---|
220 | .db 0xFF ; bDeviceClass
|
---|
221 | .db 0xFF ; bDeviceSubClass
|
---|
222 | .db 0xFF ; bDeviceProtocol
|
---|
223 | .db 64 ; bMaxPacketSize0
|
---|
224 | .db 1 ; bNumConfigurations (one config at 480Mb/sec)
|
---|
225 | .db 0 ; bReserved
|
---|
226 |
|
---|
227 | .even
|
---|
228 | _full_speed_config_descr::
|
---|
229 | .db DSCR_CONFIG_LEN
|
---|
230 | .db DSCR_CONFIG
|
---|
231 | .db <(_full_speed_config_descr_end - _full_speed_config_descr) ; LSB
|
---|
232 | .db >(_full_speed_config_descr_end - _full_speed_config_descr) ; MSB
|
---|
233 | .db 2 ; bNumInterfaces
|
---|
234 | .db 1 ; bConfigurationValue
|
---|
235 | .db 0 ; iConfiguration
|
---|
236 | .db USB_ATTR ; bmAttributes
|
---|
237 | .db MAX_POWER ; bMaxPower [Unit: 0.5 mA]
|
---|
238 |
|
---|
239 | ;; interface descriptor
|
---|
240 |
|
---|
241 | .db DSCR_INTRFC_LEN
|
---|
242 | .db DSCR_INTRFC
|
---|
243 | .db 0 ; bInterfaceNumber (zero based)
|
---|
244 | .db 0 ; bAlternateSetting
|
---|
245 | .db 2 ; bNumEndpoints
|
---|
246 | .db 0xFF ; bInterfaceClass (vendor specific)
|
---|
247 | .db 0xFF ; bInterfaceSubClass (vendor specific)
|
---|
248 | .db 0xFF ; bInterfaceProtocol (vendor specific)
|
---|
249 | .db SI_PRODUCT ; iInterface (description)
|
---|
250 |
|
---|
251 | ;; endpoint descriptor
|
---|
252 |
|
---|
253 | .db DSCR_ENDPNT_LEN
|
---|
254 | .db DSCR_ENDPNT
|
---|
255 | .db 0x81 ; bEndpointAddress (ep 1 IN)
|
---|
256 | .db ET_BULK ; bmAttributes
|
---|
257 | .db <64 ; wMaxPacketSize (LSB)
|
---|
258 | .db >64 ; wMaxPacketSize (MSB)
|
---|
259 | .db 0 ; bInterval (iso only)
|
---|
260 |
|
---|
261 | ;; endpoint descriptor
|
---|
262 |
|
---|
263 | .db DSCR_ENDPNT_LEN
|
---|
264 | .db DSCR_ENDPNT
|
---|
265 | .db 0x02 ; bEndpointAddress (ep 2 OUT)
|
---|
266 | .db ET_BULK ; bmAttributes
|
---|
267 | .db <64 ; wMaxPacketSize (LSB)
|
---|
268 | .db >64 ; wMaxPacketSize (MSB)
|
---|
269 | .db 0 ; bInterval (iso only)
|
---|
270 |
|
---|
271 | ;; interface descriptor
|
---|
272 |
|
---|
273 | .db DSCR_INTRFC_LEN
|
---|
274 | .db DSCR_INTRFC
|
---|
275 | .db 1 ; bInterfaceNumber (zero based)
|
---|
276 | .db 0 ; bAlternateSetting
|
---|
277 | .db 2 ; bNumEndpoints
|
---|
278 | .db 0xFF ; bInterfaceClass (vendor specific)
|
---|
279 | .db 0xFF ; bInterfaceSubClass (vendor specific)
|
---|
280 | .db 0xFF ; bInterfaceProtocol (vendor specific)
|
---|
281 | .db SI_PRODUCT ; iInterface (description)
|
---|
282 |
|
---|
283 | ;; endpoint descriptor
|
---|
284 |
|
---|
285 | .db DSCR_ENDPNT_LEN
|
---|
286 | .db DSCR_ENDPNT
|
---|
287 | .db 0x06 ; bEndpointAddress (ep 6 OUT)
|
---|
288 | .db ET_BULK ; bmAttributes
|
---|
289 | .db 0x40 ; wMaxPacketSize (LSB)
|
---|
290 | .db 0x00 ; wMaxPacketSize (MSB)
|
---|
291 | .db 0 ; bInterval (iso only)
|
---|
292 |
|
---|
293 | ;; endpoint descriptor
|
---|
294 |
|
---|
295 | .db DSCR_ENDPNT_LEN
|
---|
296 | .db DSCR_ENDPNT
|
---|
297 | .db 0x88 ; bEndpointAddress (ep 8 IN)
|
---|
298 | .db ET_BULK ; bmAttributes
|
---|
299 | .db 0x40 ; wMaxPacketSize (LSB)
|
---|
300 | .db 0x00 ; wMaxPacketSize (MSB)
|
---|
301 | .db 0 ; bInterval (iso only)
|
---|
302 |
|
---|
303 |
|
---|
304 | _full_speed_config_descr_end:
|
---|
305 |
|
---|
306 | ;;; ----------------------------------------------------------------
|
---|
307 | ;;; string descriptors
|
---|
308 | ;;; ----------------------------------------------------------------
|
---|
309 |
|
---|
310 | _nstring_descriptors::
|
---|
311 | .db (_string_descriptors_end - _string_descriptors) / 2
|
---|
312 |
|
---|
313 | _string_descriptors::
|
---|
314 | .db <str0, >str0
|
---|
315 | .db <str1, >str1
|
---|
316 | .db <str2, >str2
|
---|
317 | .db <str3, >str3
|
---|
318 | _string_descriptors_end:
|
---|
319 |
|
---|
320 | SI_NONE = 0
|
---|
321 | ;; str0 contains the language ID's.
|
---|
322 | .even
|
---|
323 | _str0::
|
---|
324 | str0: .db str0_end - str0
|
---|
325 | .db DSCR_STRING
|
---|
326 | .db 0
|
---|
327 | .db 0
|
---|
328 | .db <0x0409 ; magic code for US English (LSB)
|
---|
329 | .db >0x0409 ; magic code for US English (MSB)
|
---|
330 | str0_end:
|
---|
331 |
|
---|
332 | SI_VENDOR = 1
|
---|
333 | .even
|
---|
334 | _str1::
|
---|
335 | str1: .db str1_end - str1
|
---|
336 | .db DSCR_STRING
|
---|
337 | .db 'F, 0 ; 16-bit unicode
|
---|
338 | .db 'Y, 0
|
---|
339 | .db 'N, 0
|
---|
340 | .db 'U, 0
|
---|
341 | str1_end:
|
---|
342 |
|
---|
343 | SI_PRODUCT = 2
|
---|
344 | .even
|
---|
345 | _str2::
|
---|
346 | str2: .db str2_end - str2
|
---|
347 | .db DSCR_STRING
|
---|
348 | .db 'U, 0
|
---|
349 | .db 'S, 0
|
---|
350 | .db 'B, 0
|
---|
351 | .db '-, 0
|
---|
352 | .db 'B, 0
|
---|
353 | .db 'l, 0
|
---|
354 | .db 'a, 0
|
---|
355 | .db 's, 0
|
---|
356 | .db 't, 0
|
---|
357 | .db 'e, 0
|
---|
358 | .db 'r, 0
|
---|
359 | str2_end:
|
---|
360 |
|
---|
361 | SI_SERIAL = 3
|
---|
362 | .even
|
---|
363 | _str3::
|
---|
364 | str3: .db str3_end - str3
|
---|
365 | .db DSCR_STRING
|
---|
366 | .db '0, 0
|
---|
367 | .db '0, 0
|
---|
368 | .db '0, 0
|
---|
369 | .db '0, 0
|
---|
370 | .db '0, 0
|
---|
371 | .db '0, 0
|
---|
372 | .db '0, 0
|
---|
373 | .db '0, 0
|
---|
374 | str3_end:
|
---|
375 |
|
---|