forked from KolibriOS/kolibrios
Converted to PE. Added explaining debug messages. Now two levels of debug output. Improved readability.
git-svn-id: svn://kolibrios.org@5087 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
b6edc1a03f
commit
33f53bbf8d
@ -12,7 +12,7 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
format MS COFF
|
format PE DLL native 0.05
|
||||||
|
|
||||||
DEBUG = 1
|
DEBUG = 1
|
||||||
|
|
||||||
@ -23,13 +23,10 @@ node equ ftdi_context
|
|||||||
node.next equ ftdi_context.next_context
|
node.next equ ftdi_context.next_context
|
||||||
|
|
||||||
include '../../proc32.inc'
|
include '../../proc32.inc'
|
||||||
include '../../imports.inc'
|
include '../../peimport.inc'
|
||||||
include '../../fdo.inc'
|
include '../../fdo.inc'
|
||||||
include '../../struct.inc'
|
include '../../struct.inc'
|
||||||
|
|
||||||
public START
|
|
||||||
public version
|
|
||||||
|
|
||||||
; USB constants
|
; USB constants
|
||||||
DEVICE_DESCR_TYPE = 1
|
DEVICE_DESCR_TYPE = 1
|
||||||
CONFIG_DESCR_TYPE = 2
|
CONFIG_DESCR_TYPE = 2
|
||||||
@ -178,14 +175,14 @@ wIndex dw ?
|
|||||||
wLength dw ?
|
wLength dw ?
|
||||||
ends
|
ends
|
||||||
|
|
||||||
section '.flat' code readable align 16
|
section '.flat' code readable executable
|
||||||
; The start procedure.
|
; The start procedure.
|
||||||
proc START stdcall, .reason:DWORD
|
proc START c, .reason:DWORD, .cmdline:DWORD
|
||||||
|
|
||||||
xor eax, eax ; initialize return value
|
xor eax, eax ; initialize return value
|
||||||
cmp [.reason], 1 ; compare the argument
|
cmp [.reason], 1 ; compare the argument
|
||||||
jnz .nothing
|
jnz .nothing
|
||||||
stdcall RegUSBDriver, my_driver, service_proc, usb_functions
|
invoke RegUSBDriver, my_driver, service_proc, usb_functions
|
||||||
|
|
||||||
.nothing:
|
.nothing:
|
||||||
ret
|
ret
|
||||||
@ -194,20 +191,20 @@ endp
|
|||||||
|
|
||||||
proc AddDevice stdcall uses ebx esi edi, .config_pipe:DWORD, .config_descr:DWORD, .interface:DWORD
|
proc AddDevice stdcall uses ebx esi edi, .config_pipe:DWORD, .config_descr:DWORD, .interface:DWORD
|
||||||
|
|
||||||
stdcall USBGetParam, [.config_pipe], 0
|
invoke USBGetParam, [.config_pipe], 0
|
||||||
mov edx, eax
|
mov edx, eax
|
||||||
DEBUGF 1,'K : Detected device vendor: %x\n', [eax+usb_descr.idVendor]
|
DEBUGF 2,'K : Detected device vendor: 0x%x\n', [eax+usb_descr.idVendor]
|
||||||
cmp word[eax+usb_descr.idVendor], 0x0403
|
cmp word[eax+usb_descr.idVendor], 0x0403
|
||||||
jnz .notftdi
|
jnz .notftdi
|
||||||
mov eax, sizeof.ftdi_context
|
mov eax, sizeof.ftdi_context
|
||||||
call Kmalloc
|
invoke Kmalloc
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
mov esi, nomemory_msg
|
mov esi, nomemory_msg
|
||||||
call SysMsgBoardStr
|
invoke SysMsgBoardStr
|
||||||
jmp .nothing
|
jmp .nothing
|
||||||
@@:
|
@@:
|
||||||
DEBUGF 1,'K : Adding struct to list %x\n', eax
|
DEBUGF 2,'K : Adding struct to list 0x%x\n', eax
|
||||||
call linkedlist_add
|
call linkedlist_add
|
||||||
|
|
||||||
mov ebx, [.config_pipe]
|
mov ebx, [.config_pipe]
|
||||||
@ -222,7 +219,7 @@ proc AddDevice stdcall uses ebx esi edi, .config_pipe:DWORD, .config_descr:DWORD
|
|||||||
jmp .slow
|
jmp .slow
|
||||||
|
|
||||||
mov cx, [edx+usb_descr.bcdDevice]
|
mov cx, [edx+usb_descr.bcdDevice]
|
||||||
DEBUGF 1, 'K : Chip type %x\n', ecx
|
DEBUGF 2, 'K : Chip type 0x%x\n', ecx
|
||||||
cmp cx, 0x400
|
cmp cx, 0x400
|
||||||
jnz @f
|
jnz @f
|
||||||
mov [eax + ftdi_context.chipType], TYPE_BM
|
mov [eax + ftdi_context.chipType], TYPE_BM
|
||||||
@ -262,11 +259,13 @@ proc AddDevice stdcall uses ebx esi edi, .config_pipe:DWORD, .config_descr:DWORD
|
|||||||
add [eax + ftdi_context.maxPacketSize], 512-64
|
add [eax + ftdi_context.maxPacketSize], 512-64
|
||||||
.slow:
|
.slow:
|
||||||
mov ebx, eax
|
mov ebx, eax
|
||||||
stdcall USBOpenPipe, [.config_pipe], 0x81, [ebx + ftdi_context.maxPacketSize], BULK_PIPE, 0
|
invoke USBOpenPipe, [.config_pipe], 0x81, \
|
||||||
|
[ebx + ftdi_context.maxPacketSize], BULK_PIPE, 0
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .nothing
|
jz .nothing
|
||||||
mov [ebx + ftdi_context.outEP], eax
|
mov [ebx + ftdi_context.outEP], eax
|
||||||
stdcall USBOpenPipe, [.config_pipe], 0x02, [ebx + ftdi_context.maxPacketSize], BULK_PIPE, 0
|
invoke USBOpenPipe, [.config_pipe], 0x02, \
|
||||||
|
[ebx + ftdi_context.maxPacketSize], BULK_PIPE, 0
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .nothing
|
jz .nothing
|
||||||
mov [ebx + ftdi_context.inEP], eax
|
mov [ebx + ftdi_context.inEP], eax
|
||||||
@ -288,7 +287,6 @@ inp_size equ IOCTL.inp_size
|
|||||||
output equ IOCTL.output
|
output equ IOCTL.output
|
||||||
out_size equ IOCTL.out_size
|
out_size equ IOCTL.out_size
|
||||||
|
|
||||||
align 4
|
|
||||||
proc service_proc stdcall uses ebx esi edi, ioctl:DWORD
|
proc service_proc stdcall uses ebx esi edi, ioctl:DWORD
|
||||||
locals
|
locals
|
||||||
ConfPacket rb 10
|
ConfPacket rb 10
|
||||||
@ -347,7 +345,7 @@ endl
|
|||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
.bulkevent:
|
.bulkevent:
|
||||||
xor esi, esi
|
xor esi, esi
|
||||||
call CreateEvent
|
invoke CreateEvent
|
||||||
mov [EventData], eax
|
mov [EventData], eax
|
||||||
mov [EventData+4], edx
|
mov [EventData+4], edx
|
||||||
pop edi eax
|
pop edi eax
|
||||||
@ -409,12 +407,12 @@ endl
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jz @f
|
jz @f
|
||||||
mov eax, dword[ConfPacket]
|
mov eax, dword[ConfPacket]
|
||||||
call Kfree
|
invoke Kfree
|
||||||
@@:
|
@@:
|
||||||
;---Dirty hack end
|
;---Dirty hack end
|
||||||
mov eax, [EventData]
|
mov eax, [EventData]
|
||||||
mov ebx, [EventData+4]
|
mov ebx, [EventData+4]
|
||||||
call DestroyEvent
|
invoke DestroyEvent
|
||||||
jmp .endswitch
|
jmp .endswitch
|
||||||
|
|
||||||
.ftdi_out_control_transfer_withinp:
|
.ftdi_out_control_transfer_withinp:
|
||||||
@ -428,75 +426,117 @@ endl
|
|||||||
mov word[ConfPacket+6], cx
|
mov word[ConfPacket+6], cx
|
||||||
.own_index:
|
.own_index:
|
||||||
mov ebx, [edi+4]
|
mov ebx, [edi+4]
|
||||||
DEBUGF 1,'K : ConfPacket %x %x\n', [ConfPacket], [ConfPacket+4]
|
DEBUGF 2,'K : ConfPacket 0x%x 0x%x\n', [ConfPacket], [ConfPacket+4]
|
||||||
lea esi, [ConfPacket]
|
lea esi, [ConfPacket]
|
||||||
lea edi, [EventData]
|
lea edi, [EventData]
|
||||||
stdcall USBControlTransferAsync, [ebx + ftdi_context.nullP], esi, 0, 0, control_callback, edi, 0
|
invoke USBControlTransferAsync, [ebx + ftdi_context.nullP], esi, 0,\
|
||||||
|
0, control_callback, edi, 0
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .error
|
jz .error
|
||||||
mov eax, [EventData]
|
mov eax, [EventData]
|
||||||
mov ebx, [EventData+4]
|
mov ebx, [EventData+4]
|
||||||
call WaitEvent
|
invoke WaitEvent
|
||||||
mov eax, [EventData+8]
|
mov eax, [EventData+8]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .endswitch
|
jz .endswitch
|
||||||
jmp .error
|
jmp .error
|
||||||
|
|
||||||
.ftdi_setrtshigh:
|
.ftdi_setrtshigh:
|
||||||
;DEBUGF 1,'K : FTDI Setting RTS pin HIGH\n'
|
DEBUGF 2,'K : FTDI Setting RTS pin HIGH PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_MODEM_CTRL_REQUEST shl 8) + (SIO_SET_RTS_HIGH shl 16)
|
[edi+4]
|
||||||
|
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_SET_MODEM_CTRL_REQUEST shl 8) \
|
||||||
|
+ (SIO_SET_RTS_HIGH shl 16)
|
||||||
jmp .ftdi_out_control_transfer_noinp
|
jmp .ftdi_out_control_transfer_noinp
|
||||||
|
|
||||||
.ftdi_setrtslow:
|
.ftdi_setrtslow:
|
||||||
;DEBUGF 1,'K : FTDI Setting RTS pin LOW\n'
|
DEBUGF 2,'K : FTDI Setting RTS pin LOW PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_MODEM_CTRL_REQUEST shl 8) + (SIO_SET_RTS_LOW shl 16)
|
[edi+4]
|
||||||
|
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_SET_MODEM_CTRL_REQUEST shl 8) \
|
||||||
|
+ (SIO_SET_RTS_LOW shl 16)
|
||||||
jmp .ftdi_out_control_transfer_noinp
|
jmp .ftdi_out_control_transfer_noinp
|
||||||
|
|
||||||
.ftdi_setdtrhigh:
|
.ftdi_setdtrhigh:
|
||||||
;DEBUGF 1,'K : FTDI Setting DTR pin HIGH\n'
|
DEBUGF 2,'K : FTDI Setting DTR pin HIGH PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_MODEM_CTRL_REQUEST shl 8) + (SIO_SET_DTR_HIGH shl 16)
|
[edi+4]
|
||||||
|
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_SET_MODEM_CTRL_REQUEST shl 8) \
|
||||||
|
+ (SIO_SET_DTR_HIGH shl 16)
|
||||||
jmp .ftdi_out_control_transfer_noinp
|
jmp .ftdi_out_control_transfer_noinp
|
||||||
|
|
||||||
.ftdi_setdtrlow:
|
.ftdi_setdtrlow:
|
||||||
;DEBUGF 1,'K : FTDI Setting DTR pin LOW\n'
|
DEBUGF 2,'K : FTDI Setting DTR pin LOW PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_MODEM_CTRL_REQUEST shl 8) + (SIO_SET_DTR_LOW shl 16)
|
[edi+4]
|
||||||
|
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_SET_MODEM_CTRL_REQUEST shl 8) \
|
||||||
|
+ (SIO_SET_DTR_LOW shl 16)
|
||||||
jmp .ftdi_out_control_transfer_noinp
|
jmp .ftdi_out_control_transfer_noinp
|
||||||
|
|
||||||
.ftdi_usb_reset:
|
.ftdi_usb_reset:
|
||||||
;DEBUGF 1,'K : FTDI Reseting\n'
|
DEBUGF 2,'K : FTDI Reseting PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_RESET_REQUEST shl 8) + (SIO_RESET_SIO shl 16)
|
[edi+4]
|
||||||
|
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_RESET_REQUEST shl 8) \+
|
||||||
|
(SIO_RESET_SIO shl 16)
|
||||||
jmp .ftdi_out_control_transfer_noinp
|
jmp .ftdi_out_control_transfer_noinp
|
||||||
|
|
||||||
.ftdi_purge_rx_buf:
|
.ftdi_purge_rx_buf:
|
||||||
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_RESET_REQUEST shl 8) + (SIO_RESET_PURGE_RX shl 16)
|
DEBUGF 2, 'K : FTDI Purge TX buffer PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
|
[edi+4]
|
||||||
|
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_RESET_REQUEST shl 8) \
|
||||||
|
+ (SIO_RESET_PURGE_RX shl 16)
|
||||||
jmp .ftdi_out_control_transfer_noinp
|
jmp .ftdi_out_control_transfer_noinp
|
||||||
|
|
||||||
.ftdi_purge_tx_buf:
|
.ftdi_purge_tx_buf:
|
||||||
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_RESET_REQUEST shl 8) + (SIO_RESET_PURGE_TX shl 16)
|
DEBUGF 2, 'K : FTDI Purge RX buffer PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
|
[edi+4]
|
||||||
|
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_RESET_REQUEST shl 8) \
|
||||||
|
+ (SIO_RESET_PURGE_TX shl 16)
|
||||||
jmp .ftdi_out_control_transfer_noinp
|
jmp .ftdi_out_control_transfer_noinp
|
||||||
|
|
||||||
.ftdi_set_bitmode:
|
.ftdi_set_bitmode:
|
||||||
mov word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_BITMODE_REQUEST shl 8)
|
DEBUGF 2, 'K : FTDI Set bitmode 0x%x, bitmask 0x%x %d PID: %d Dev handler 0x0x%x\n', \
|
||||||
|
[edi+8]:2,[edi+10]:2,[edi],[edi+4]
|
||||||
|
mov word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_SET_BITMODE_REQUEST shl 8)
|
||||||
jmp .ftdi_out_control_transfer_withinp
|
jmp .ftdi_out_control_transfer_withinp
|
||||||
|
|
||||||
.ftdi_set_line_property:
|
.ftdi_set_line_property:
|
||||||
mov word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_DATA_REQUEST shl 8)
|
DEBUGF 2, 'K : FTDI Set line property 0x%x PID: %d Dev handler 0x0x%x\n', \
|
||||||
|
[edi+8]:4,[edi],[edi+4]
|
||||||
|
mov word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_SET_DATA_REQUEST shl 8)
|
||||||
jmp .ftdi_out_control_transfer_withinp
|
jmp .ftdi_out_control_transfer_withinp
|
||||||
|
|
||||||
.ftdi_set_latency_timer:
|
.ftdi_set_latency_timer:
|
||||||
mov word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_LATENCY_TIMER_REQUEST shl 8)
|
DEBUGF 2, 'K : FTDI Set latency %d PID: %d Dev handler 0x0x%x\n', \
|
||||||
|
[edi+8],[edi],[edi+4]
|
||||||
|
mov word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_SET_LATENCY_TIMER_REQUEST shl 8)
|
||||||
jmp .ftdi_out_control_transfer_withinp
|
jmp .ftdi_out_control_transfer_withinp
|
||||||
|
|
||||||
.ftdi_set_event_char:
|
.ftdi_set_event_char:
|
||||||
mov word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_EVENT_CHAR_REQUEST shl 8)
|
DEBUGF 2, 'K : FTDI Set event char %c PID: %d Dev handler 0x0x%x\n', \
|
||||||
|
[edi+8],[edi],[edi+4]
|
||||||
|
mov word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_SET_EVENT_CHAR_REQUEST shl 8)
|
||||||
jmp .ftdi_out_control_transfer_withinp
|
jmp .ftdi_out_control_transfer_withinp
|
||||||
|
|
||||||
.ftdi_set_error_char:
|
.ftdi_set_error_char:
|
||||||
mov word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_ERROR_CHAR_REQUEST shl 8)
|
DEBUGF 2, 'K : FTDI Set error char %c PID: %d Dev handler 0x0x%x\n', \
|
||||||
|
[edi+8],[edi],[edi+4]
|
||||||
|
mov word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_SET_ERROR_CHAR_REQUEST shl 8)
|
||||||
jmp .ftdi_out_control_transfer_withinp
|
jmp .ftdi_out_control_transfer_withinp
|
||||||
|
|
||||||
.ftdi_setflowctrl:
|
.ftdi_setflowctrl:
|
||||||
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_FLOW_CTRL_REQUEST shl 8) + (0 shl 16)
|
DEBUGF 2, 'K : FTDI Set flow control PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
|
[edi+4]
|
||||||
|
mov dword[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_SET_FLOW_CTRL_REQUEST shl 8) + (0 shl 16)
|
||||||
mov ebx, [edi+4]
|
mov ebx, [edi+4]
|
||||||
mov cx, word[edi+8]
|
mov cx, word[edi+8]
|
||||||
or ecx, [ebx + ftdi_context.index]
|
or ecx, [ebx + ftdi_context.index]
|
||||||
@ -506,8 +546,11 @@ endl
|
|||||||
jmp .own_index
|
jmp .own_index
|
||||||
|
|
||||||
.ftdi_read_pins:
|
.ftdi_read_pins:
|
||||||
|
DEBUGF 2, 'K : FTDI Read pins PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
|
[edi+4]
|
||||||
mov ebx, [edi+4]
|
mov ebx, [edi+4]
|
||||||
mov dword[ConfPacket], FTDI_DEVICE_IN_REQTYPE + (SIO_READ_PINS_REQUEST shl 8) + (0 shl 16)
|
mov dword[ConfPacket], (FTDI_DEVICE_IN_REQTYPE) /
|
||||||
|
+ (SIO_READ_PINS_REQUEST shl 8) + (0 shl 16)
|
||||||
mov ecx, [ebx + ftdi_context.index]
|
mov ecx, [ebx + ftdi_context.index]
|
||||||
mov word[ConfPacket+4], cx
|
mov word[ConfPacket+4], cx
|
||||||
mov word[ConfPacket+6], 1
|
mov word[ConfPacket+6], 1
|
||||||
@ -516,10 +559,11 @@ endl
|
|||||||
mov ecx, esi
|
mov ecx, esi
|
||||||
add ecx, 8
|
add ecx, 8
|
||||||
mov word[ConfPacket+8], 0
|
mov word[ConfPacket+8], 0
|
||||||
stdcall USBControlTransferAsync, [ebx + ftdi_context.nullP], esi, ecx, 1, control_callback, edi, 0
|
invoke USBControlTransferAsync, [ebx + ftdi_context.nullP], esi, ecx, /
|
||||||
|
1, control_callback, edi, 0
|
||||||
mov eax, [EventData]
|
mov eax, [EventData]
|
||||||
mov ebx, [EventData+4]
|
mov ebx, [EventData+4]
|
||||||
call WaitEvent
|
invoke WaitEvent
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
mov bx, word[ConfPacket+8]
|
mov bx, word[ConfPacket+8]
|
||||||
mov ecx, [ioctl]
|
mov ecx, [ioctl]
|
||||||
@ -531,6 +575,8 @@ endl
|
|||||||
jmp .error
|
jmp .error
|
||||||
|
|
||||||
.ftdi_set_wchunksize:
|
.ftdi_set_wchunksize:
|
||||||
|
DEBUGF 2, 'K : FTDI Set write chunksize %d bytes PID: %d Dev handler 0x0x%x\n', \
|
||||||
|
[edi+8], [edi], [edi+4]
|
||||||
mov ebx, [edi+4]
|
mov ebx, [edi+4]
|
||||||
mov ecx, [edi+8]
|
mov ecx, [edi+8]
|
||||||
cmp [ebx + ftdi_context.maxPacketSize], ecx
|
cmp [ebx + ftdi_context.maxPacketSize], ecx
|
||||||
@ -539,6 +585,8 @@ endl
|
|||||||
jmp .endswitch
|
jmp .endswitch
|
||||||
|
|
||||||
.ftdi_get_wchunksize:
|
.ftdi_get_wchunksize:
|
||||||
|
DEBUGF 2, 'K : FTDI Get write chunksize PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
|
[edi+4]
|
||||||
mov esi, [edi+output]
|
mov esi, [edi+output]
|
||||||
mov edi, [edi+input]
|
mov edi, [edi+input]
|
||||||
mov ebx, [edi+4]
|
mov ebx, [edi+4]
|
||||||
@ -547,6 +595,8 @@ endl
|
|||||||
jmp .endswitch
|
jmp .endswitch
|
||||||
|
|
||||||
.ftdi_set_rchunksize:
|
.ftdi_set_rchunksize:
|
||||||
|
DEBUGF 2, 'K : FTDI Set read chunksize %d bytes PID: %d Dev handler 0x0x%x\n', \
|
||||||
|
[edi+8], [edi], [edi+4]
|
||||||
mov ebx, [edi+4]
|
mov ebx, [edi+4]
|
||||||
mov ecx, [edi+8]
|
mov ecx, [edi+8]
|
||||||
cmp [ebx + ftdi_context.maxPacketSize], ecx
|
cmp [ebx + ftdi_context.maxPacketSize], ecx
|
||||||
@ -555,6 +605,8 @@ endl
|
|||||||
jmp .endswitch
|
jmp .endswitch
|
||||||
|
|
||||||
.ftdi_get_rchunksize:
|
.ftdi_get_rchunksize:
|
||||||
|
DEBUGF 2, 'K : FTDI Get read chunksize PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
|
[edi+4]
|
||||||
mov esi, [edi+output]
|
mov esi, [edi+output]
|
||||||
mov edi, [edi+input]
|
mov edi, [edi+input]
|
||||||
mov ebx, [edi+4]
|
mov ebx, [edi+4]
|
||||||
@ -563,16 +615,18 @@ endl
|
|||||||
jmp .endswitch
|
jmp .endswitch
|
||||||
|
|
||||||
.ftdi_write_data:
|
.ftdi_write_data:
|
||||||
|
DEBUGF 2, 'K : FTDI Write %d bytes PID: %d Dev handler 0x%x\n', [edi+8],\
|
||||||
|
[edi], [edi+4]
|
||||||
mov esi, edi
|
mov esi, edi
|
||||||
add esi, 12
|
add esi, 12
|
||||||
mov ebx, [edi+4]
|
mov ebx, [edi+4]
|
||||||
;---Dirty hack begin
|
;---Dirty hack begin
|
||||||
mov eax, [edi+8]
|
mov eax, [edi+8]
|
||||||
call Kmalloc
|
invoke Kmalloc
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
mov esi, nomemory_msg
|
mov esi, nomemory_msg
|
||||||
call SysMsgBoardStr
|
invoke SysMsgBoardStr
|
||||||
jmp .eventdestroy
|
jmp .eventdestroy
|
||||||
@@:
|
@@:
|
||||||
mov dword[ConfPacket], eax
|
mov dword[ConfPacket], eax
|
||||||
@ -594,10 +648,11 @@ endl
|
|||||||
add esi, ecx
|
add esi, ecx
|
||||||
lea eax, [EventData]
|
lea eax, [EventData]
|
||||||
push ecx ebx esi edi
|
push ecx ebx esi edi
|
||||||
stdcall USBNormalTransferAsync, [ebx + ftdi_context.inEP], esi, edx, bulk_callback, eax, 1
|
invoke USBNormalTransferAsync, [ebx + ftdi_context.inEP], esi, edx, \
|
||||||
|
bulk_callback, eax, 1
|
||||||
mov eax, [EventData]
|
mov eax, [EventData]
|
||||||
mov ebx, [EventData+4]
|
mov ebx, [EventData+4]
|
||||||
call WaitEvent
|
invoke WaitEvent
|
||||||
pop edi esi ebx ecx
|
pop edi esi ebx ecx
|
||||||
cmp [EventData+8], -1
|
cmp [EventData+8], -1
|
||||||
jz .error
|
jz .error
|
||||||
@ -607,26 +662,28 @@ endl
|
|||||||
jmp .write_loop
|
jmp .write_loop
|
||||||
|
|
||||||
.ftdi_read_data:
|
.ftdi_read_data:
|
||||||
|
DEBUGF 2, 'K : FTDI Read %d bytes PID: %d Dev handler 0x%x\n', [edi+8],\
|
||||||
|
[edi], [edi+4]
|
||||||
mov edi, [ioctl]
|
mov edi, [ioctl]
|
||||||
mov esi, [edi+input]
|
mov esi, [edi+input]
|
||||||
mov edi, [edi+output]
|
mov edi, [edi+output]
|
||||||
mov ebx, [esi+4]
|
mov ebx, [esi+4]
|
||||||
;---Dirty hack begin
|
;---Dirty hack begin
|
||||||
mov eax, [esi+8]
|
mov eax, [esi+8]
|
||||||
call Kmalloc
|
invoke Kmalloc
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
mov esi, nomemory_msg
|
mov esi, nomemory_msg
|
||||||
call SysMsgBoardStr
|
invoke SysMsgBoardStr
|
||||||
jmp .eventdestroy
|
jmp .eventdestroy
|
||||||
@@:
|
@@:
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
push edi eax
|
; push edi eax
|
||||||
mov ecx, [esi+8]
|
; mov ecx, [esi+8]
|
||||||
xor eax, eax
|
; xor eax, eax
|
||||||
rep stosb
|
; rep stosb
|
||||||
pop eax edi
|
; pop eax edi
|
||||||
mov dword[ConfPacket], eax ; Store in ConfPAcket ptr to allocated memory
|
mov dword[ConfPacket], eax ; Store in ConfPacket ptr to allocated memory
|
||||||
;---Dirty hack end
|
;---Dirty hack end
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
.read_loop:
|
.read_loop:
|
||||||
@ -641,10 +698,11 @@ endl
|
|||||||
lea eax, [EventData]
|
lea eax, [EventData]
|
||||||
add edi, ecx
|
add edi, ecx
|
||||||
push esi edi ecx ebx
|
push esi edi ecx ebx
|
||||||
stdcall USBNormalTransferAsync, [ebx + ftdi_context.outEP], edi, edx, bulk_callback, eax, 1
|
invoke USBNormalTransferAsync, [ebx + ftdi_context.outEP], edi, edx, \
|
||||||
|
bulk_callback, eax, 1
|
||||||
mov eax, [EventData]
|
mov eax, [EventData]
|
||||||
mov ebx, [EventData+4]
|
mov ebx, [EventData+4]
|
||||||
call WaitEvent
|
invoke WaitEvent
|
||||||
pop ebx ecx edi esi
|
pop ebx ecx edi esi
|
||||||
cmp [EventData+8], -1
|
cmp [EventData+8], -1
|
||||||
jz .error
|
jz .error
|
||||||
@ -662,8 +720,11 @@ endl
|
|||||||
;---Dirty hack end
|
;---Dirty hack end
|
||||||
|
|
||||||
.ftdi_poll_modem_status:
|
.ftdi_poll_modem_status:
|
||||||
|
DEBUGF 2, 'K : FTDI Poll modem status PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
|
[edi+4]
|
||||||
mov ebx, [edi+4]
|
mov ebx, [edi+4]
|
||||||
mov dword[ConfPacket], FTDI_DEVICE_IN_REQTYPE + (SIO_POLL_MODEM_STATUS_REQUEST shl 8) + (0 shl 16)
|
mov dword[ConfPacket], (FTDI_DEVICE_IN_REQTYPE) \
|
||||||
|
+ (SIO_POLL_MODEM_STATUS_REQUEST shl 8) + (0 shl 16)
|
||||||
mov ecx, [ebx + ftdi_context.index]
|
mov ecx, [ebx + ftdi_context.index]
|
||||||
mov word[ConfPacket+4], cx
|
mov word[ConfPacket+4], cx
|
||||||
mov word[ConfPacket+6], 1
|
mov word[ConfPacket+6], 1
|
||||||
@ -671,10 +732,11 @@ endl
|
|||||||
lea edi, [EventData]
|
lea edi, [EventData]
|
||||||
mov ecx, [ioctl]
|
mov ecx, [ioctl]
|
||||||
mov ecx, [ecx+output]
|
mov ecx, [ecx+output]
|
||||||
stdcall USBControlTransferAsync, [ebx + ftdi_context.nullP], esi, ecx, 2, control_callback, edi, 0
|
invoke USBControlTransferAsync, [ebx + ftdi_context.nullP], esi, ecx, \
|
||||||
|
2, control_callback, edi, 0
|
||||||
mov eax, [EventData]
|
mov eax, [EventData]
|
||||||
mov ebx, [EventData+4]
|
mov ebx, [EventData+4]
|
||||||
call WaitEvent
|
invoke WaitEvent
|
||||||
mov ax, word[ecx]
|
mov ax, word[ecx]
|
||||||
xchg ah, al
|
xchg ah, al
|
||||||
and ah, 0xFF
|
and ah, 0xFF
|
||||||
@ -682,8 +744,11 @@ endl
|
|||||||
jmp .endswitch
|
jmp .endswitch
|
||||||
|
|
||||||
.ftdi_get_latency_timer:
|
.ftdi_get_latency_timer:
|
||||||
|
DEBUGF 2, 'K : FTDI Get latency timer PID: %d Dev handler 0x0x%x\n', [edi],\
|
||||||
|
[edi+4]
|
||||||
mov ebx, [edi+4]
|
mov ebx, [edi+4]
|
||||||
mov dword[ConfPacket], FTDI_DEVICE_IN_REQTYPE + (SIO_GET_LATENCY_TIMER_REQUEST shl 8) + (0 shl 16)
|
mov dword[ConfPacket], FTDI_DEVICE_IN_REQTYPE \
|
||||||
|
+ (SIO_GET_LATENCY_TIMER_REQUEST shl 8) + (0 shl 16)
|
||||||
mov ecx, [ebx + ftdi_context.index]
|
mov ecx, [ebx + ftdi_context.index]
|
||||||
mov word[ConfPacket+4], cx
|
mov word[ConfPacket+4], cx
|
||||||
mov word[ConfPacket+6], 1
|
mov word[ConfPacket+6], 1
|
||||||
@ -691,13 +756,15 @@ endl
|
|||||||
lea edi, [EventData]
|
lea edi, [EventData]
|
||||||
mov ecx, [ioctl]
|
mov ecx, [ioctl]
|
||||||
mov ecx, [ecx+output]
|
mov ecx, [ecx+output]
|
||||||
stdcall USBControlTransferAsync, [ebx + ftdi_context.nullP], esi, ecx, 2, control_callback, edi, 0
|
invoke USBControlTransferAsync, [ebx + ftdi_context.nullP], esi, ecx, \
|
||||||
|
2, control_callback, edi, 0
|
||||||
mov eax, [EventData]
|
mov eax, [EventData]
|
||||||
mov ebx, [EventData+4]
|
mov ebx, [EventData+4]
|
||||||
call WaitEvent
|
invoke WaitEvent
|
||||||
jmp .endswitch
|
jmp .endswitch
|
||||||
|
|
||||||
.ftdi_get_list:
|
.ftdi_get_list:
|
||||||
|
DEBUGF 2, 'K : FTDI devices\' list request\n'
|
||||||
mov edi, [edi+output]
|
mov edi, [edi+output]
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
call linkedlist_gethead
|
call linkedlist_gethead
|
||||||
@ -727,6 +794,7 @@ endl
|
|||||||
jmp .endswitch
|
jmp .endswitch
|
||||||
|
|
||||||
.ftdi_lock:
|
.ftdi_lock:
|
||||||
|
DEBUGF 2, 'K : FTDI Lock PID: %d Dev handler 0x0x%x\n', [edi], [edi+4]
|
||||||
mov esi, [edi+input]
|
mov esi, [edi+input]
|
||||||
mov ebx, [esi+4]
|
mov ebx, [esi+4]
|
||||||
mov eax, [ebx + ftdi_context.lockPID]
|
mov eax, [ebx + ftdi_context.lockPID]
|
||||||
@ -740,6 +808,7 @@ endl
|
|||||||
jmp .endswitch
|
jmp .endswitch
|
||||||
|
|
||||||
.ftdi_unlock:
|
.ftdi_unlock:
|
||||||
|
DEBUGF 2, 'K : FTDI Unlock PID: %d Dev handler 0x0x%x\n', [edi], [edi+4]
|
||||||
mov esi, [edi+input]
|
mov esi, [edi+input]
|
||||||
mov edi, [edi+output]
|
mov edi, [edi+output]
|
||||||
mov ebx, [esi+4]
|
mov ebx, [esi+4]
|
||||||
@ -756,6 +825,8 @@ endl
|
|||||||
H_CLK = 120000000
|
H_CLK = 120000000
|
||||||
C_CLK = 48000000
|
C_CLK = 48000000
|
||||||
.ftdi_set_baudrate:
|
.ftdi_set_baudrate:
|
||||||
|
DEBUGF 2, 'K : FTDI Set baudrate to %d PID: %d Dev handle: 0x%x\n',\
|
||||||
|
[edi+8], [edi], [edi+4]
|
||||||
mov ebx, [edi+4]
|
mov ebx, [edi+4]
|
||||||
cmp [ebx + ftdi_context.chipType], TYPE_2232H
|
cmp [ebx + ftdi_context.chipType], TYPE_2232H
|
||||||
jl .c_clk
|
jl .c_clk
|
||||||
@ -883,7 +954,8 @@ C_CLK = 48000000
|
|||||||
or ecx, [ebx + ftdi_context.index]
|
or ecx, [ebx + ftdi_context.index]
|
||||||
|
|
||||||
.preparepacket:
|
.preparepacket:
|
||||||
mov word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) + (SIO_SET_BAUDRATE_REQUEST shl 8)
|
mov word[ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||||
|
+ (SIO_SET_BAUDRATE_REQUEST shl 8)
|
||||||
mov word[ConfPacket+2], ax
|
mov word[ConfPacket+2], ax
|
||||||
mov word[ConfPacket+4], cx
|
mov word[ConfPacket+4], cx
|
||||||
mov word[ConfPacket+6], 0
|
mov word[ConfPacket+6], 0
|
||||||
@ -898,8 +970,8 @@ restore output
|
|||||||
restore out_size
|
restore out_size
|
||||||
|
|
||||||
|
|
||||||
align 4
|
proc control_callback stdcall uses ebx edi esi, .pipe:DWORD, .status:DWORD, \
|
||||||
proc control_callback stdcall uses ebx edi esi, .pipe:DWORD, .status:DWORD, .buffer:DWORD, .length:DWORD, .calldata:DWORD
|
.buffer:DWORD, .length:DWORD, .calldata:DWORD
|
||||||
|
|
||||||
DEBUGF 1, 'K : status is %d\n', [.status]
|
DEBUGF 1, 'K : status is %d\n', [.status]
|
||||||
mov ecx, [.calldata]
|
mov ecx, [.calldata]
|
||||||
@ -909,11 +981,12 @@ proc control_callback stdcall uses ebx edi esi, .pipe:DWORD, .status:DWORD, .buf
|
|||||||
mov [ecx+8], edx
|
mov [ecx+8], edx
|
||||||
xor esi, esi
|
xor esi, esi
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
call RaiseEvent
|
invoke RaiseEvent
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
proc bulk_callback stdcall uses ebx edi esi, .pipe:DWORD, .status:DWORD, .buffer:DWORD, .length:DWORD, .calldata:DWORD
|
proc bulk_callback stdcall uses ebx edi esi, .pipe:DWORD, .status:DWORD, \
|
||||||
|
.buffer:DWORD, .length:DWORD, .calldata:DWORD
|
||||||
|
|
||||||
DEBUGF 1, 'K : status is %d\n', [.status]
|
DEBUGF 1, 'K : status is %d\n', [.status]
|
||||||
mov ecx, [.calldata]
|
mov ecx, [.calldata]
|
||||||
@ -932,34 +1005,31 @@ proc bulk_callback stdcall uses ebx edi esi, .pipe:DWORD, .status:DWORD, .buffer
|
|||||||
.ok:
|
.ok:
|
||||||
xor esi, esi
|
xor esi, esi
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
call RaiseEvent
|
invoke RaiseEvent
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
proc DeviceDisconnected stdcall uses ebx esi edi, .device_data:DWORD
|
proc DeviceDisconnected stdcall uses ebx esi edi, .device_data:DWORD
|
||||||
|
|
||||||
DEBUGF 1, 'K : FTDI deleting device data %x\n', [.device_data]
|
DEBUGF 1, 'K : FTDI deleting device data 0x%x\n', [.device_data]
|
||||||
mov eax, [.device_data]
|
mov eax, [.device_data]
|
||||||
call linkedlist_delete
|
call linkedlist_unlink
|
||||||
|
invoke Kfree
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
include 'linkedlist.inc'
|
include 'linkedlist.inc'
|
||||||
|
|
||||||
; Exported variable: kernel API version.
|
|
||||||
align 4
|
align 4
|
||||||
version dd 50005h
|
|
||||||
; Structure with callback functions.
|
; Structure with callback functions.
|
||||||
usb_functions:
|
usb_functions:
|
||||||
dd 12
|
dd 12
|
||||||
dd AddDevice
|
dd AddDevice
|
||||||
dd DeviceDisconnected
|
dd DeviceDisconnected
|
||||||
|
|
||||||
|
data fixups
|
||||||
|
end data
|
||||||
|
|
||||||
;for DEBUGF macro
|
;for DEBUGF macro
|
||||||
include_debug_strings
|
include_debug_strings
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; for uninitialized data
|
|
||||||
;section '.data' data readable writable align 16
|
|
||||||
|
Loading…
Reference in New Issue
Block a user