Subversion Repositories Kolibri OS

Rev

Rev 4992 | Rev 5014 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4992 Rev 4997
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line -...
7
 
-
 
8
; standard driver stuff
7
 
Line 9... Line 8...
9
format MS COFF
8
format MS COFF
Line 10... Line -...
10
 
-
 
11
DEBUG = 1
9
 
12
 
10
DEBUG = 1
Line -... Line 11...
-
 
11
 
-
 
12
__DEBUG__ = 1
-
 
13
__DEBUG_LEVEL__ = 1
13
; this is for DEBUGF macro from 'fdo.inc'
14
 
14
__DEBUG__ = 1
15
node equ ftdi_context
15
__DEBUG_LEVEL__ = 1
16
node.next equ ftdi_context.next_context
16
 
17
 
Line 128... Line 129...
128
interface               dd      ?
129
interface               dd      ?
129
index                   dd      ?
130
index                   dd      ?
130
inEP                    dd      ?
131
inEP                    dd      ?
131
outEP                   dd      ?
132
outEP                   dd      ?
132
nullP                   dd      ? 
133
nullP                   dd      ? 
-
 
134
lockPID                 dd      ?
133
next_context            dd      ?
135
next_context            dd      ?
134
ends
136
ends
Line 135... Line 137...
135
 
137
 
136
struct IOCTL
138
struct IOCTL
Line 179... Line 181...
179
.nothing:
181
.nothing:
180
        ret
182
        ret
181
endp
183
endp
Line 182... Line 184...
182
 
184
 
Line 183... Line 185...
183
 
185
 
-
 
186
proc AddDevice stdcall uses ebx esi, .config_pipe:DWORD, .config_descr:DWORD, .interface:DWORD
184
proc AddDevice stdcall uses ebx, .config_pipe:DWORD, .config_descr:DWORD, .interface:DWORD
187
        
185
        
188
        stdcall USBGetParam, [.config_pipe], 0
186
        stdcall USBGetParam, [.config_pipe], 0
189
        mov     edx, eax
187
        DEBUGF 1,'K : Device detected Vendor: %x\n', [eax+usb_descr.idVendor]
190
        DEBUGF 1,'K : Device detected Vendor: %x\n', [eax+usb_descr.idVendor]
188
        cmp     word[eax+usb_descr.idVendor], 0x0403
191
        cmp     word[eax+usb_descr.idVendor], 0x0403
189
        jnz     .notftdi
192
        jnz     .notftdi
190
        DEBUGF 1,'K : FTDI USB device detected\n'
193
        DEBUGF 1,'K : FTDI USB device detected\n'
191
        movi    eax, sizeof.ftdi_context
194
        movi    eax, sizeof.ftdi_context
192
        call    Kmalloc
195
        call    Kmalloc
193
        test    eax, eax
196
        test    eax, eax
194
        jnz     @f
-
 
195
        mov     esi, nomemory_msg
197
        jnz     @f
196
        call    SysMsgBoardStr
198
        mov     esi, nomemory_msg
197
        xor     eax, eax
199
        call    SysMsgBoardStr
198
        jmp     .nothing
200
        jmp     .nothing
Line 199... Line 201...
199
@@:
201
  @@:
200
        DEBUGF 1,'K : Adding struct to list %x\n', eax
202
        DEBUGF 1,'K : Adding struct to list %x\n', eax
201
        call    linkedlist.add
203
        call    linkedlist_add
-
 
204
        
-
 
205
        mov     ebx, [.config_pipe]
-
 
206
        mov     [eax + ftdi_context.nullP], ebx
-
 
207
        mov     [eax + ftdi_context.index], 0
-
 
208
        mov     [eax + ftdi_context.lockPID], 0
-
 
209
        
-
 
210
        cmp     [edx+usb_descr.bcdDevice], 0x400
-
 
211
        jnz     @f
-
 
212
        mov     [eax + ftdi_context.chipType], TYPE_BM
-
 
213
  @@:      
-
 
214
        cmp     [edx+usb_descr.bcdDevice], 0x200
-
 
215
        jnz     @f
-
 
216
        mov     [eax + ftdi_context.chipType], TYPE_AM
-
 
217
  @@:     
-
 
218
        cmp     [edx+usb_descr.bcdDevice], 0x500
-
 
219
        jnz     @f
-
 
220
        mov     [eax + ftdi_context.chipType], TYPE_2232C        
-
 
221
  @@:      
-
 
222
        cmp     [edx+usb_descr.bcdDevice], 0x600
-
 
223
        jnz     @f
-
 
224
        mov     [eax + ftdi_context.chipType], TYPE_R
-
 
225
  @@:      
-
 
226
        cmp     [edx+usb_descr.bcdDevice], 0x700
-
 
227
        jnz     @f
-
 
228
        mov     [eax + ftdi_context.chipType], TYPE_2232H
-
 
229
  @@:      
-
 
230
        cmp     [edx+usb_descr.bcdDevice], 0x900
-
 
231
        jnz     @f
-
 
232
        mov     [eax + ftdi_context.chipType], TYPE_232H
-
 
233
  @@:      
Line 202... Line 234...
202
        
234
        cmp     [edx+usb_descr.bcdDevice], 0x1000
203
        mov     ebx, [.config_pipe]
235
        jnz     @f
204
        mov     [eax + ftdi_context.nullP], ebx
236
        mov     [eax + ftdi_context.chipType], TYPE_BM
205
        mov     [eax + ftdi_context.index], 0
237
  @@:
206
        
238
  
207
        DEBUGF 1,'K : Open first pipe\n'
239
        DEBUGF 1,'K : Open first pipe\n'
208
        mov     ebx, eax
240
        mov     ebx, eax
Line 209... Line -...
209
        stdcall USBOpenPipe, [.config_pipe],  0x81,  0x40,  BULK_PIPE, 0
-
 
210
        mov     [ebx + ftdi_context.inEP], eax
-
 
211
        DEBUGF 1,'K : Open second pipe\n'
241
        stdcall USBOpenPipe, [.config_pipe],  0x81,  0x40,  BULK_PIPE, 0
212
        stdcall USBOpenPipe, [.config_pipe],  0x02,  0x40,  BULK_PIPE, 0
242
        mov     [ebx + ftdi_context.inEP], eax
-
 
243
        DEBUGF 1,'K : Open second pipe\n'
213
        mov     [ebx + ftdi_context.outEP], eax        
244
        stdcall USBOpenPipe, [.config_pipe],  0x02,  0x40,  BULK_PIPE, 0
214
 
245
        mov     [ebx + ftdi_context.outEP], eax        
215
  .nothing:
246
           
Line 240... Line 271...
240
        test    eax, eax           ;0
271
        test    eax, eax           ;0
241
        jz      .version
272
        jz      .version
242
        dec     eax                 ;1
273
        dec     eax                 ;1
243
        jz      .ftdi_get_list
274
        jz      .ftdi_get_list
Line -... Line 275...
-
 
275
        
-
 
276
        push    eax
-
 
277
        mov     esi, [edi+input]
-
 
278
        mov     eax, [esi+4]
-
 
279
        call    linkedlist_isvalid
-
 
280
        test    eax, eax
-
 
281
        pop     eax        
-
 
282
        jnz     .endswitch
-
 
283
        
-
 
284
        dec     eax
-
 
285
        jz      .ftdi_lock      ;2
-
 
286
        dec     eax
-
 
287
        jz      .ftdi_unlock    ;3
-
 
288
        
-
 
289
        mov     ebx, [esi+4]
-
 
290
        mov     ecx, [ebx + ftdi_context.lockPID]     
-
 
291
        cmp     ecx, [esi]
-
 
292
        jz      .pid_ok
-
 
293
        mov     esi, [edi+output]
-
 
294
        mov     dword[esi], 'LCKD'
-
 
295
        jmp     .endswitch
-
 
296
        
244
        
297
  .pid_ok:  
245
        push    eax edi
298
        push    eax edi
246
        xor     ecx, ecx
299
        xor     ecx, ecx
247
        xor     esi, esi
300
        xor     esi, esi
248
        call    CreateEvent        
301
        call    CreateEvent        
249
        mov     [EventData], eax
302
        mov     [EventData], eax
250
        mov     [EventData+4], edx
303
        mov     [EventData+4], edx
Line 251... Line 304...
251
        pop     edi eax 
304
        pop     edi eax 
252
        
305
        
253
        dec     eax                 ;2
306
        dec     eax                 ;4
254
        jz      .ftdi_set_bitmode
307
        jz      .ftdi_set_bitmode
255
        dec     eax                 ;3
308
        dec     eax                 ;5
256
        jz      .ftdi_setrtshigh   
309
        jz      .ftdi_setrtshigh   
-
 
310
        dec     eax                 ;6
-
 
311
        jz      .ftdi_setrtslow  
-
 
312
        dec     eax
-
 
313
        jz      .ftdi_setdtrhigh
-
 
314
        dec     eax
-
 
315
        jz      .ftdi_setdtrlow
-
 
316
        dec     eax
-
 
317
        jz      .ftdi_usb_reset
-
 
318
        dec     eax
-
 
319
        jz      .ftdi_setflowctrl
-
 
320
        dec     eax
-
 
321
        jz      .ftdi_set_event_char
-
 
322
        dec     eax
-
 
323
        jz      .ftdi_set_error_char
-
 
324
        dec     eax
-
 
325
        jz      .ftdi_set_latency_timer
-
 
326
        dec     eax
-
 
327
        jz      .ftdi_get_latency_timer
-
 
328
        dec     eax
-
 
329
        jz      .ftdi_read_pins
-
 
330
        dec     eax
-
 
331
        jz      .ftdi_poll_modem_status
-
 
332
        dec     eax
-
 
333
        jz      .ftdi_write_data
-
 
334
        dec     eax
-
 
335
        jz      .ftdi_set_baudrate
-
 
336
        dec     eax
-
 
337
        jz      .ftdi_set_line_property
-
 
338
        dec     eax
-
 
339
        jz      .ftdi_purge_rx_buf
Line 257... Line 340...
257
        dec     eax                 ;4
340
        dec     eax
258
        jz      .ftdi_setrtslow     
341
        jz      .ftdi_purge_tx_buf
259
        
342
        
260
  .version:     
343
  .version:     
Line 267... Line 350...
267
        mov     cx, word[ebx + ftdi_context.index]
350
        mov     cx, word[ebx + ftdi_context.index]
268
        mov     word[ConfPacket+4], cx
351
        mov     word[ConfPacket+4], cx
269
        xor     cx, cx
352
        xor     cx, cx
270
        mov     word[ConfPacket+6], cx
353
        mov     word[ConfPacket+6], cx
271
  .own_index:
354
  .own_index:
272
        mov    ebx, [edi]
355
        mov    ebx, [edi+4]
273
        DEBUGF 1,'K : ConfPacket %x %x\n', [ConfPacket], [ConfPacket+4]          
356
        DEBUGF 1,'K : ConfPacket %x %x\n', [ConfPacket], [ConfPacket+4]          
274
        lea     esi, [ConfPacket]
357
        lea     esi, [ConfPacket]
275
        lea     edi, [EventData]        
358
        lea     edi, [EventData]        
276
        stdcall USBControlTransferAsync, [ebx + ftdi_context.nullP],  esi, 0, 0, control_callback, edi, 0
359
        stdcall USBControlTransferAsync, [ebx + ftdi_context.nullP],  esi, 0, 0, control_callback, edi, 0
277
        DEBUGF 1, 'K : Returned value is %d\n', eax
360
        DEBUGF 1, 'K : Returned value is %d\n', eax
Line 282... Line 365...
282
        
365
        
283
  .ftdi_set_bitmode:
366
  .ftdi_set_bitmode:
284
        DEBUGF 1,'K : FTDI Seting bitmode\n'                   
367
        DEBUGF 1,'K : FTDI Seting bitmode\n'                   
285
        mov     word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_BITMODE_REQUEST shl 8)
368
        mov     word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_BITMODE_REQUEST shl 8)
286
        mov     edi, [edi+input]        
369
        mov     edi, [edi+input]        
287
        mov     dx, word[edi+4]                
370
        mov     dx, word[edi+8]                
288
        mov     word[ConfPacket+2], dx                                        
371
        mov     word[ConfPacket+2], dx                                        
Line 289... Line 372...
289
        jmp     .ftdi_out_control_transfer     
372
        jmp     .ftdi_out_control_transfer     
290
 
373
 
Line 326... Line 409...
326
  .ftdi_set_baudrate:
409
  .ftdi_set_baudrate:
327
        mov     edi, [edi+input]
410
        mov     edi, [edi+input]
328
        mov     ebx, [edi]
411
        mov     ebx, [edi]
329
        cmp     [ebx + ftdi_context.chipType], TYPE_2232H
412
        cmp     [ebx + ftdi_context.chipType], TYPE_2232H
330
        jl      .c_clk        
413
        jl      .c_clk        
331
        imul    eax, [edi+4], 10
414
        imul    eax, [edi+8], 10
332
        cmp     eax, H_CLK / 0x3FFF        
415
        cmp     eax, H_CLK / 0x3FFF        
333
        jle     .c_clk
416
        jle     .c_clk
334
  .h_clk:       
417
  .h_clk:       
335
        cmp     dword[edi+4], H_CLK/10
418
        cmp     dword[edi+8], H_CLK/10
336
        jl      .h_nextbaud1
419
        jl      .h_nextbaud1
337
        xor     edx, edx
420
        xor     edx, edx
338
        mov     ecx, H_CLK/10
421
        mov     ecx, H_CLK/10
339
        jmp     .calcend
422
        jmp     .calcend
Line 340... Line 423...
340
        
423
        
341
  .c_clk:
424
  .c_clk:
342
        cmp     dword[edi+4], C_CLK/10
425
        cmp     dword[edi+8], C_CLK/10
343
        jl      .c_nextbaud1
426
        jl      .c_nextbaud1
344
        xor     edx, edx
427
        xor     edx, edx
345
        mov     ecx, C_CLK/10
428
        mov     ecx, C_CLK/10
Line 346... Line 429...
346
        jmp     .calcend  
429
        jmp     .calcend  
347
  
430
  
348
  .h_nextbaud1:
431
  .h_nextbaud1:
349
        cmp     dword[edi+4], H_CLK/(10 + 10/2)
432
        cmp     dword[edi+8], H_CLK/(10 + 10/2)
350
        jl      .h_nextbaud2
433
        jl      .h_nextbaud2
351
        mov     edx, 1
434
        mov     edx, 1
Line 352... Line 435...
352
        mov     ecx, H_CLK/(10 + 10/2)
435
        mov     ecx, H_CLK/(10 + 10/2)
353
        jmp     .calcend
436
        jmp     .calcend
354
        
437
        
355
  .c_nextbaud1:
438
  .c_nextbaud1:
356
        cmp     dword[edi+4], C_CLK/(10 + 10/2)
439
        cmp     dword[edi+8], C_CLK/(10 + 10/2)
357
        jl      .c_nextbaud2
440
        jl      .c_nextbaud2
Line 358... Line 441...
358
        mov     edx, 1
441
        mov     edx, 1
359
        mov     ecx, C_CLK/(10 + 10/2)
442
        mov     ecx, C_CLK/(10 + 10/2)
360
        jmp     .calcend        
443
        jmp     .calcend        
361
        
444
        
362
  .h_nextbaud2:      
445
  .h_nextbaud2:      
363
        cmp     dword[edi+4], H_CLK/(2*10)
446
        cmp     dword[edi+8], H_CLK/(2*10)
Line 364... Line 447...
364
        jl      .h_nextbaud3
447
        jl      .h_nextbaud3
365
        mov     edx, 2
448
        mov     edx, 2
366
        mov     ecx, H_CLK/(2*10)
449
        mov     ecx, H_CLK/(2*10)
367
        jmp     .calcend
450
        jmp     .calcend
368
        
451
        
369
  .c_nextbaud2:      
452
  .c_nextbaud2:      
Line 370... Line 453...
370
        cmp     dword[edi+4], C_CLK/(2*10)
453
        cmp     dword[edi+8], C_CLK/(2*10)
371
        jl      .c_nextbaud3
454
        jl      .c_nextbaud3
372
        mov     edx, 2
455
        mov     edx, 2
373
        mov     ecx, C_CLK/(2*10)
456
        mov     ecx, C_CLK/(2*10)
374
        jmp     .calcend        
457
        jmp     .calcend        
375
        
458
        
376
  .h_nextbaud3:
459
  .h_nextbaud3:
377
        mov     eax, H_CLK*16/10  ; eax - best_divisor
460
        mov     eax, H_CLK*16/10  ; eax - best_divisor
Line 399... Line 482...
399
        inc     ecx
482
        inc     ecx
400
        jmp     .rounddownbaud
483
        jmp     .rounddownbaud
Line 401... Line 484...
401
        
484
        
402
  .c_nextbaud3:
485
  .c_nextbaud3:
403
        mov     eax, C_CLK*16/10  ; eax - best_divisor
486
        mov     eax, C_CLK*16/10  ; eax - best_divisor
404
        div     dword[edi+4]      ; [edi+4] - baudrate
487
        div     dword[edi+8]      ; [edi+8] - baudrate
405
        push    eax
488
        push    eax
406
        and     eax, 1
489
        and     eax, 1
407
        pop     eax
490
        pop     eax
408
        shr     eax, 1
491
        shr     eax, 1
Line 456... Line 539...
456
        jmp     .own_index
539
        jmp     .own_index
Line 457... Line 540...
457
     
540
     
458
  .ftdi_set_line_property:
541
  .ftdi_set_line_property:
459
        mov     word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_DATA_REQUEST shl 8)
542
        mov     word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_DATA_REQUEST shl 8)
460
        mov     edi, [edi+input]        
543
        mov     edi, [edi+input]        
461
        mov     dx, word[edi+4]                
544
        mov     dx, word[edi+8]                
462
        mov     word[ConfPacket+2], dx
545
        mov     word[ConfPacket+2], dx
Line 463... Line 546...
463
        jmp     .ftdi_out_control_transfer
546
        jmp     .ftdi_out_control_transfer
464
        
547
        
465
  .ftdi_set_latency_timer:
548
  .ftdi_set_latency_timer:
466
        mov     word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_LATENCY_TIMER_REQUEST shl 8)
549
        mov     word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_LATENCY_TIMER_REQUEST shl 8)
467
        mov     edi, [edi+input]        
550
        mov     edi, [edi+input]        
468
        mov     dx, word[edi+4]                
551
        mov     dx, word[edi+8]                
Line 469... Line 552...
469
        mov     word[ConfPacket+2], dx        
552
        mov     word[ConfPacket+2], dx        
470
        jmp     .ftdi_out_control_transfer
553
        jmp     .ftdi_out_control_transfer
471
        
554
        
472
  .ftdi_set_event_char:
555
  .ftdi_set_event_char:
473
        mov     word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_EVENT_CHAR_REQUEST shl 8)
556
        mov     word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_EVENT_CHAR_REQUEST shl 8)
474
        mov     edi, [edi+input]        
557
        mov     edi, [edi+input]        
Line 475... Line 558...
475
        mov     dx, word[edi+4]                
558
        mov     dx, word[edi+8]                
476
        mov     word[ConfPacket+2], dx
559
        mov     word[ConfPacket+2], dx
477
        jmp     .ftdi_out_control_transfer
560
        jmp     .ftdi_out_control_transfer
478
 
561
 
479
  .ftdi_set_error_char:
562
  .ftdi_set_error_char:
480
        mov     word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_ERROR_CHAR_REQUEST shl 8)
563
        mov     word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_ERROR_CHAR_REQUEST shl 8)
Line 481... Line 564...
481
        mov     edi, [edi+input]        
564
        mov     edi, [edi+input]        
482
        mov     dx, word[edi+4]                
565
        mov     dx, word[edi+8]                
483
        mov     word[ConfPacket+2], dx
566
        mov     word[ConfPacket+2], dx
484
        jmp     .ftdi_out_control_transfer 
567
        jmp     .ftdi_out_control_transfer 
485
        
568
        
486
  .ftdi_setflowctrl:
569
  .ftdi_setflowctrl:
487
        mov     dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_FLOW_CTRL_REQUEST shl 8) + (0 shl 16)      
570
        mov     dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_FLOW_CTRL_REQUEST shl 8) + (0 shl 16)      
488
        mov     edi, [edi+input]
571
        mov     edi, [edi+input]
489
        mov     ebx, [edi]
572
        mov     ebx, [edi]
490
        mov     cx, word[edi+4]   
573
        mov     cx, word[edi+8]   
Line 491... Line 574...
491
        or      ecx, [ebx + ftdi_context.index]
574
        or      ecx, [ebx + ftdi_context.index]
492
        mov     word[ConfPacket+4], cx
575
        mov     word[ConfPacket+4], cx
493
        xor     cx, cx
-
 
494
        mov     word[ConfPacket+6], cx
-
 
495
        jmp     .own_index
576
        xor     cx, cx
496
 
577
        mov     word[ConfPacket+6], cx
-
 
578
        jmp     .own_index
-
 
579
 
-
 
580
  .ftdi_read_pins:
-
 
581
        DEBUGF 1,'K : FTDI Reading pins\n'
497
  .ftdi_read_pins:
582
        mov     edi, [edi+input]                                  
498
        DEBUGF 1,'K : FTDI Reading pins\n'
583
        mov     ebx, [edi] 
499
        mov     dword[ConfPacket], FTDI_DEVICE_IN_REQTYPE + (SIO_READ_PINS_REQUEST shl 8) + (0 shl 16)
584
        mov     dword[ConfPacket], FTDI_DEVICE_IN_REQTYPE + (SIO_READ_PINS_REQUEST shl 8) + (0 shl 16)
500
        mov     dword[ConfPacket+4], 0x00000001
585
        mov     ecx, [ebx + ftdi_context.index]
501
        mov     edi, [edi+input]                                  
586
        mov     word[ConfPacket+4], cx
Line 509... Line 594...
509
        mov     eax, [EventData]
594
        mov     eax, [EventData]
510
        mov     ebx, [EventData+4]
595
        mov     ebx, [EventData+4]
511
        call    WaitEvent     
596
        call    WaitEvent     
512
        jmp     .endswitch
597
        jmp     .endswitch
Line 513... Line 598...
513
        
598
 
-
 
599
  .ftdi_write_data:
-
 
600
        mov     edi, [edi+input]
-
 
601
        mov     ebx, [edi+4]
-
 
602
        mov     eax, [edi+8]
-
 
603
        xor     ecx, ecx        ; ecx - offset     
-
 
604
  .dataleft:
-
 
605
        mov     edx, [ebx + ftdi_context.writeBufChunkSize] ; edx - write_size
-
 
606
        push    ecx
-
 
607
        add     ecx, edx
-
 
608
        cmp     ecx, [edi+8]
-
 
609
        pop     ecx
-
 
610
        jle     .morethanchunk
-
 
611
        mov     edx, [edi+8]           
-
 
612
        sub     edx, ecx
514
   .ftdi_read_data:
613
  .morethanchunk:
-
 
614
        stdcall USBNormalTransferAsync, [ebx + ftdi_context.inEP], [edi+12+ecx], edx, bulk_callback, edx, 1
-
 
615
        mov     eax, [EventData]
-
 
616
        mov     ebx, [EventData+4]
-
 
617
        call    WaitEvent        
-
 
618
        add     ecx, [EventData]
-
 
619
        cmp     ecx, [edi+8]
-
 
620
        jl      .dataleft
-
 
621
        jmp     .endswitch
-
 
622
        
-
 
623
  .ftdi_poll_modem_status:
-
 
624
        mov     edi, [edi+input]                                  
-
 
625
        mov     ebx, [edi+4] 
-
 
626
        mov     dword[ConfPacket], FTDI_DEVICE_IN_REQTYPE + (SIO_POLL_MODEM_STATUS_REQUEST shl 8) + (0 shl 16)
-
 
627
        mov     ecx, [ebx + ftdi_context.index]
-
 
628
        mov     word[ConfPacket+4], cx
-
 
629
        mov     word[ConfPacket+6], 1
-
 
630
        lea     esi, [ConfPacket]
-
 
631
        lea     edi, [EventData]
-
 
632
        mov     ecx, [ioctl]
-
 
633
        mov     ecx, [ecx+output]
-
 
634
        stdcall USBControlTransferAsync, [ebx + ftdi_context.nullP],  esi, ecx, 2, control_callback, edi, 0
-
 
635
        DEBUGF 1, 'K : Returned value is %d\n', eax
-
 
636
        mov     eax, [EventData]
-
 
637
        mov     ebx, [EventData+4]
-
 
638
        call    WaitEvent
-
 
639
        mov     ax, word[ecx]
-
 
640
        xchg    ah, al
-
 
641
        and     ah, 0xFF
-
 
642
        mov     word[ecx], ax
-
 
643
        jmp     .endswitch
-
 
644
        
-
 
645
  .ftdi_get_latency_timer:
-
 
646
        mov     edi, [edi+input]                                  
-
 
647
        mov     ebx, [edi+4] 
-
 
648
        mov     dword[ConfPacket], FTDI_DEVICE_IN_REQTYPE + (SIO_GET_LATENCY_TIMER_REQUEST shl 8) + (0 shl 16)
-
 
649
        mov     ecx, [ebx + ftdi_context.index]
-
 
650
        mov     word[ConfPacket+4], cx
-
 
651
        mov     word[ConfPacket+6], 1
-
 
652
        lea     esi, [ConfPacket]
-
 
653
        lea     edi, [EventData]
-
 
654
        mov     ecx, [ioctl]
-
 
655
        mov     ecx, [ecx+output]
-
 
656
        stdcall USBControlTransferAsync, [ebx + ftdi_context.nullP],  esi, ecx, 2, control_callback, edi, 0
-
 
657
        DEBUGF 1, 'K : Returned value is %d\n', eax
-
 
658
        mov     eax, [EventData]
-
 
659
        mov     ebx, [EventData+4]
-
 
660
        call    WaitEvent
Line 515... Line 661...
515
        ;stdcall USBNormalTransferAsync, [ebx + ftdi_context.inEP], [ebx + ftdi_context.readBufPtr], [ebx + 1]
661
        jmp     .endswitch
516
 
662
                
-
 
663
  .ftdi_get_list:
-
 
664
        call    linkedlist_gethead                        
-
 
665
        mov     edi, [edi+output]
-
 
666
  .nextdev:
-
 
667
        cmp     [eax + ftdi_context.lockPID], 0
-
 
668
        jnz      .dev_is_locked        
-
 
669
        mov     dword[edi], 'NLKD'
-
 
670
        jmp     .nextfields
-
 
671
  .dev_is_locked:
-
 
672
        mov     dword[edi], 'LCKD'
-
 
673
  .nextfields:
-
 
674
        mov     bl, [eax + ftdi_context.chipType]
-
 
675
        mov     [edi+4], ebx
-
 
676
        mov     [edi+8], eax
-
 
677
        add     edi, 12
-
 
678
        mov     eax, [eax + ftdi_context.next_context]
-
 
679
        test    eax, eax
-
 
680
        jnz     .nextdev
-
 
681
        jmp     .endswitch
-
 
682
        	   
-
 
683
  .ftdi_lock:
-
 
684
        mov     esi, [edi+input]
-
 
685
        mov     ebx, [esi+4]
-
 
686
        mov     eax, [ebx + ftdi_context.lockPID]
-
 
687
        test    eax, eax
-
 
688
        jnz     .lockedby
-
 
689
        mov     eax, [esi]
517
   .ftdi_get_list:
690
        mov     [ebx + ftdi_context.lockPID], eax
518
        call    linkedlist.gethead                        
691
  .lockedby:
-
 
692
        mov     edi, [edi+output]
-
 
693
        mov     [edi], eax
-
 
694
        jmp     .endswitch
-
 
695
        
-
 
696
  .ftdi_unlock:
-
 
697
        mov     esi, [edi+input]
519
        mov     edi, [edi+output]
698
        mov     edi, [edi+output]
520
        mov     [edi], eax
699
        mov     ebx, [esi+4]
-
 
700
        mov     eax, [ebx + ftdi_context.lockPID]
-
 
701
        cmp     eax, [esi]
-
 
702
        jnz     .unlockimp
-
 
703
        mov     [ebx + ftdi_context.lockPID], 0
-
 
704
        mov     dword[edi], 0
521
        DEBUGF 1, 'K : FTDI Device pointer %x\n', [edi]
705
        jmp     .endswitch   
522
        mov     eax, 4        
706
  .unlockimp:     
Line 523... Line 707...
523
        mov     [edi+out_size], eax
707
        mov     [edi], eax
524
        jmp     .endswitch
708
        jmp     .endswitch  
525
        	   
709
        
Line 537... Line 721...
537
   
721
   
538
        DEBUGF 1, 'K : status is %d\n', [.status] 
722
        DEBUGF 1, 'K : status is %d\n', [.status] 
539
        mov     ecx, [.calldata]
723
        mov     ecx, [.calldata]
540
        mov     eax, [ecx]
724
        mov     eax, [ecx]
-
 
725
        mov     ebx, [ecx+4]
541
        mov     ebx, [ecx+4]
726
        xor     esi, esi
542
        xor     edx, edx
727
        xor     edx, edx
Line 543... Line 728...
543
        call    RaiseEvent
728
        call    RaiseEvent
544
              
729
              
Line -... Line 730...
-
 
730
        ret
-
 
731
endp
-
 
732
 
-
 
733
proc bulk_callback stdcall uses ebx edi esi, .pipe:DWORD, .status:DWORD, .buffer:DWORD, .length:DWORD, .calldata:DWORD
-
 
734
 
-
 
735
        DEBUGF 1, 'K : status is %d\n', [.status] 
-
 
736
        mov     ecx, [.calldata]
-
 
737
        mov     eax, [ecx]
-
 
738
        mov     ebx, [ecx+4]
-
 
739
        mov     edx, [.length]
-
 
740
        mov     edx, [edx]
-
 
741
        mov     [ecx], edx
-
 
742
        xor     esi, esi
-
 
743
        xor     edx, edx          
-
 
744
        call    RaiseEvent
-
 
745
              
Line 545... Line 746...
545
        ret
746
        ret
Line 546... Line 747...
546
endp
747
 
547
 
748
endp
548
 
749
 
549
proc DeviceDisconnected stdcall uses  ebx esi edi, .device_data:DWORD
750
proc DeviceDisconnected stdcall uses  ebx esi edi, .device_data:DWORD
550
 
751
 
Line 551... Line 752...
551
        DEBUGF 1, 'K : FTDI deleting device data\n'
752
        DEBUGF 1, 'K : FTDI deleting device data\n'