Small fix in ftdi_get_list. Added memset in ftdi_read_data

git-svn-id: svn://kolibrios.org@5037 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
gtament 2014-08-17 18:45:31 +00:00
parent 2fe5245774
commit 88cafe6b95
2 changed files with 54 additions and 52 deletions

View File

@ -5,68 +5,67 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
head dd 0 head dd 0
size dd 0
linkedlist_add: linkedlist_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
linkedlist_delete: linkedlist_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
linkedlist_isvalid: ;eax - pointer to check; returns zero if valid linkedlist_isvalid: ;eax - pointer to check; returns zero if valid
push ebx ecx push ebx ecx
xor ecx, ecx xor ecx, ecx
test eax, eax test eax, eax
jz .invalid_pointer jz .invalid_pointer
mov ebx, [head] mov ebx, [head]
.next_check: .next_check:
cmp eax, ebx cmp eax, ebx
jz .valid_pointer jz .valid_pointer
mov ebx, [ebx + node.next] mov ebx, [ebx + node.next]
test ebx, ebx test ebx, ebx
jz .invalid_pointer jz .invalid_pointer
jmp .next_check jmp .next_check
.invalid_pointer: .invalid_pointer:
inc ecx inc ecx
.valid_pointer: .valid_pointer:
mov eax, ecx mov eax, ecx
pop ecx ebx pop ecx ebx
ret ret
linkedlist_gethead: linkedlist_gethead:
mov eax, [head] mov eax, [head]
ret ret
restore node restore node

View File

@ -22,10 +22,10 @@ __DEBUG_LEVEL__ = 1
node equ ftdi_context 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 '../imports.inc'
include '../../fdo.inc' include '../fdo.inc'
include '../../struct.inc' include '../struct.inc'
public START public START
public version public version
@ -611,6 +611,11 @@ endl
jmp .eventdestroy jmp .eventdestroy
@@: @@:
mov edi, eax mov edi, eax
push edi eax
mov ecx, [esi+8]
xor eax, eax
rep stosb
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
@ -637,7 +642,6 @@ endl
cmp [EventData+8], -1 cmp [EventData+8], -1
jz .error jz .error
add ecx, [EventData+8] add ecx, [EventData+8]
DEBUGF 1, 'K : In buffer %x\n', [edi]
jmp .read_loop jmp .read_loop
;---Dirty hack begin ;---Dirty hack begin
.read_end: .read_end:
@ -687,13 +691,13 @@ endl
jmp .endswitch jmp .endswitch
.ftdi_get_list: .ftdi_get_list:
mov edi, [edi+output]
xor ecx, ecx
call linkedlist_gethead call linkedlist_gethead
test eax, eax test eax, eax
jz .endswitch jz .emptylist
mov edi, [edi+output]
push edi push edi
add edi, 4 add edi, 4
xor ecx, ecx
.nextdev: .nextdev:
inc ecx inc ecx
cmp [eax + ftdi_context.lockPID], 0 cmp [eax + ftdi_context.lockPID], 0
@ -711,6 +715,7 @@ endl
test eax, eax test eax, eax
jnz .nextdev jnz .nextdev
pop edi pop edi
.emptylist:
mov [edi], ecx mov [edi], ecx
jmp .endswitch jmp .endswitch
@ -718,7 +723,6 @@ endl
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]
DEBUGF 1, 'K : to PID %x from PID %x\n', [esi], eax
test eax, eax test eax, eax
jnz .lockedby jnz .lockedby
mov eax, [esi] mov eax, [esi]
@ -733,7 +737,6 @@ endl
mov edi, [edi+output] mov edi, [edi+output]
mov ebx, [esi+4] mov ebx, [esi+4]
mov eax, [ebx + ftdi_context.lockPID] mov eax, [ebx + ftdi_context.lockPID]
DEBUGF 1, 'K : to PID %x from PID %x\n', [esi], eax
cmp eax, [esi] cmp eax, [esi]
jnz .unlockimp jnz .unlockimp
mov [ebx + ftdi_context.lockPID], 0 mov [ebx + ftdi_context.lockPID], 0