Minor driver changes. Also fixed offset mistakes

git-svn-id: svn://kolibrios.org@4979 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
gtament 2014-06-17 17:43:10 +00:00
parent 54ee05721e
commit 81384e65b4
2 changed files with 76 additions and 64 deletions

View File

@ -1,55 +1,49 @@
head dd 1 head dd 0
node equ ftdi_context node equ ftdi_context
node.next equ ftdi_context.next_context node.next equ ftdi_context.next_context
linkedlist: linkedlist:
.init:
push eax
xor eax, eax
mov [head], eax
pop eax
ret
.add: .add:
push ebx push ebx
mov ebx, [head] mov ebx, [head]
mov [head], eax mov [head], eax
mov [eax + node.next], ebx mov [eax + node.next], ebx
pop ebx pop ebx
ret ret
.delete: .delete:
push ebx ecx push ebx ecx
mov ebx, eax ; eax - pointer to node for delete mov ebx, eax ; eax - pointer to node for delete
cmp eax, [head] cmp eax, [head]
jz .unlink_head jz .unlink_head
.getnext: .getnext:
cmp [ebx+node.next], eax cmp [ebx+node.next], eax
jz .unlink jz .unlink
cmp [ebx+node.next], 0 cmp [ebx+node.next], 0
jz .invalid_pointer jz .invalid_pointer
mov ebx, [ebx+node.next] mov ebx, [ebx+node.next]
jmp .getnext jmp .getnext
.unlink: .unlink:
mov ecx, [eax+node.next] mov ecx, [eax+node.next]
mov [ebx+node.next], ecx mov [ebx+node.next], ecx
jmp @f jmp @f
.unlink_head: .unlink_head:
mov ebx, [eax+node.next] mov ebx, [eax+node.next]
mov [head], ebx mov [head], ebx
@@: @@:
mov ecx, eax mov ecx, eax
call Kfree call Kfree
.invalid_pointer: .invalid_pointer:
pop ecx ebx pop ecx ebx
ret ret
.gethead: .gethead:
mov eax, [head] mov eax, [head]
ret ret
restore node restore node
restore next restore node.next

View File

@ -10,7 +10,7 @@ __DEBUG_LEVEL__ = 1
include '../proc32.inc' include '../proc32.inc'
include '../imports.inc' include '../imports.inc'
include '../fdo.inc' include '../fdo.inc'
include '../../struct.inc' include '../struct.inc'
public START public START
public version public version
@ -126,6 +126,8 @@ out_size dd ?
ends ends
struct usb_descr struct usb_descr
bLength db ?
bDescriptorType db ?
bcdUSB dw ? bcdUSB dw ?
bDeviceClass db ? bDeviceClass db ?
bDeviceSubClass db ? bDeviceSubClass db ?
@ -140,6 +142,14 @@ iSerialNumber db ?
bNumConfigurations db ? bNumConfigurations db ?
ends ends
struct conf_packet
bmRequestType db ?
bRequest db ?
wValue dw ?
wIndex dw ?
wLength dw ?
ends
section '.flat' code readable align 16 section '.flat' code readable align 16
; The start procedure. ; The start procedure.
proc START stdcall, .reason:DWORD proc START stdcall, .reason:DWORD
@ -147,18 +157,18 @@ proc START stdcall, .reason: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
call linkedlist.init
stdcall RegUSBDriver, my_driver, service_proc, usb_functions stdcall RegUSBDriver, my_driver, service_proc, usb_functions
.nothing: .nothing:
ret 4 ret
endp endp
proc AddDevice stdcall uses ebx, .config_pipe:DWORD, .config_descr:DWORD, .interface:DWORD proc AddDevice stdcall uses ebx, .config_pipe:DWORD, .config_descr:DWORD, .interface:DWORD
stdcall USBGetParam, [.config_pipe], 0 stdcall USBGetParam, [.config_pipe], 0
cmp [eax+usb_descr.idVendor], 0x0403 DEBUGF 1,'K : Device detected Vendor: %x\n', [eax+usb_descr.idVendor]
cmp word[eax+usb_descr.idVendor], 0x0403
jnz .notftdi jnz .notftdi
DEBUGF 1,'K : FTDI USB device detected\n' DEBUGF 1,'K : FTDI USB device detected\n'
movi eax, sizeof.ftdi_context movi eax, sizeof.ftdi_context
@ -206,55 +216,60 @@ locals
ConfPacket rb 8 ConfPacket rb 8
EventData rd 2 EventData rd 2
endl endl
mov edi, [ioctl] mov edi, [ioctl]
mov eax, [edi + io_code] mov eax, [edi + io_code]
DEBUGF 1,'K : FTDI got the request: %d\n', eax DEBUGF 1,'K : FTDI got the request: %d\n', eax
test eax, eax ;0 test eax, eax ;0
jz .version jz .version
dec eax ;1 dec eax ;1
jz .ftdi_get_list jz .ftdi_get_list
dec eax ;2 dec eax ;2
jz .ftdi_set_bitmode jz .ftdi_set_bitmode
.version: .version:
.endswitch: .endswitch:
xor eax, eax xor eax, eax
ret ret
.ftdi_set_bitmode: .ftdi_set_bitmode:
DEBUGF 1,'K : FTDI Seting bitmode\n' DEBUGF 1,'K : FTDI Seting bitmode\n'
xor ecx, ecx
xor esi, esi
call CreateEvent call CreateEvent
mov edi, [ioctl]
DEBUGF 1,'K : Event created %x %x\n' , eax, edx DEBUGF 1,'K : Event created %x %x\n' , eax, edx
mov [EventData], eax mov [EventData], eax
mov [EventData+1], edx mov [EventData+4], edx
mov si, (FTDI_DEVICE_IN_REQTYPE) + (SIO_SET_BITMODE_REQUEST shl 8) mov dword[ConfPacket], (FTDI_DEVICE_IN_REQTYPE) + (SIO_SET_BITMODE_REQUEST shl 8) + (0x0000 shl 16)
mov word[ConfPacket], si
mov edi, [edi+input] mov edi, [edi+input]
mov si, word[edi+1] mov dx, word[edi+4]
DEBUGF 1,'K : Pin value is %x\n', si mov word[ConfPacket+4], dx
mov word[ConfPacket+4], si DEBUGF 1,'K : ConfPacket %x %x\n', [ConfPacket], [ConfPacket+4]
mov ebx, [edi] mov ebx, [edi]
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 stdcall USBControlTransferAsync, [ebx + ftdi_context.nullP], esi, 0, 0, control_callback, edi, 0
DEBUGF 1, 'K : Returned value is %d\n', eax DEBUGF 1, 'K : Returned value is %d\n', eax
mov eax, [EventData]
mov ebx, [EventData+4]
call WaitEvent call WaitEvent
jmp .endswitch jmp .endswitch
.ftdi_read_pins: .ftdi_read_pins:
DEBUGF 1,'K : FTDI Reading pins\n' DEBUGF 1,'K : FTDI Reading pins\n'
call CreateEvent call CreateEvent
mov [EventData], eax mov [EventData], eax
mov [EventData+1], edx mov [EventData+4], edx
mov eax, FTDI_DEVICE_IN_REQTYPE + (SIO_READ_PINS_REQUEST shl 8) mov eax, FTDI_DEVICE_IN_REQTYPE + (SIO_READ_PINS_REQUEST shl 8)
mov dword[ConfPacket], eax mov dword[ConfPacket], eax
jmp .endswitch jmp .endswitch
.ftdi_get_list: .ftdi_get_list:
call linkedlist.gethead call linkedlist.gethead
DEBUGF 1, 'K : FTDI Device pointer %x\n' , eax
mov edi, [edi+output] mov edi, [edi+output]
mov edi, eax mov [edi], eax
DEBUGF 1, 'K : FTDI Device pointer %x\n', [edi]
mov eax, 4 mov eax, 4
mov edi, [ioctl]
mov [edi+out_size], eax mov [edi+out_size], eax
jmp .endswitch jmp .endswitch
endp endp
@ -270,7 +285,9 @@ align 4
proc control_callback stdcall uses ebx, .pipe:DWORD, .status:DWORD, .buffer:DWORD, .length:DWORD, .calldata:DWORD proc control_callback stdcall uses ebx, .pipe:DWORD, .status:DWORD, .buffer:DWORD, .length:DWORD, .calldata:DWORD
mov eax, [.calldata] mov eax, [.calldata]
mov ebx, [.calldata+1] mov ebx, [.calldata+4]
DEBUGF 1,'K : EventData %x %x', [.calldata], [.calldata+4]
xor edx, edx
call RaiseEvent call RaiseEvent
DEBUGF 1, 'K : status is %d\n', [.status+24h] DEBUGF 1, 'K : status is %d\n', [.status+24h]
ret ret
@ -281,7 +298,8 @@ proc DeviceDisconnected stdcall uses ebx esi edi, .device_data:DWORD
DEBUGF 1, 'K : FTDI deleting device data\n' DEBUGF 1, 'K : FTDI deleting device data\n'
mov eax, [.device_data] mov eax, [.device_data]
;call linkedlist.delete call linkedlist.delete
ret
endp endp
include 'linkedlist.inc' include 'linkedlist.inc'