Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4932 → Rev 5051

/drivers/usb/usbhid/keyboard.inc
60,7 → 60,7
proc keyboard_driver_add_device
; 1. Allocate memory for keyboard_device_data. If failed, return NULL.
movi eax, sizeof.keyboard_device_data
call Kmalloc
invoke Kmalloc
test eax, eax
jz .nothing
; 2. Initialize keyboard_device_data: store pointer to USB layer data,
154,7 → 154,7
; store pointer to keyboard_device_data in the stack
push eax
; call kernel API
stdcall RegKeyboard, kbd_functions, eax
invoke RegKeyboard, kbd_functions, eax
; restore pointer to keyboard_device_data from the stack,
; putting keyboard handle from API to the stack
xchg eax, [esp]
167,7 → 167,7
.nothing:
ret
.fail_free:
call Kfree
invoke Kfree
xor eax, eax
ret
endp
179,10 → 179,10
; 1. If an autorepeat timer is active, stop it.
cmp [edi+keyboard_device_data.timer], 0
jz @f
stdcall CancelTimerHS, [edi+keyboard_device_data.timer]
invoke CancelTimerHS, [edi+keyboard_device_data.timer]
@@:
; 2. Unregister keyboard in the kernel.
stdcall DelKeyboard, [edi+keyboard_device_data.handle]
invoke DelKeyboard, [edi+keyboard_device_data.handle]
; We should free data in CloseKeyboard, not here.
ret
endp
245,11 → 245,11
mov eax, [edi+keyboard_device_data.timer]
test eax, eax
jz @f
stdcall CancelTimerHS, eax
invoke CancelTimerHS, eax
@@:
; 1h. Start the new autorepeat timer with 250 ms initial delay
; and 50 ms subsequent delays.
stdcall TimerHS, 25, 5, autorepeat_timer, edi
invoke TimerHS, 25, 5, autorepeat_timer, edi
mov [edi+keyboard_device_data.timer], eax
if ~HID_DUMP_UNCLAIMED
.unclaimed:
265,7 → 265,7
mov eax, [edi+keyboard_device_data.timer]
test eax, eax
jz @f
stdcall CancelTimerHS, eax
invoke CancelTimerHS, eax
mov [edi+keyboard_device_data.timer], 0
@@:
pop ecx
321,10 → 321,10
jnc @f
push ecx
mov ecx, 0xE0
call SetKeyboardData
invoke SetKeyboardData
pop ecx
@@:
call SetKeyboardData
invoke SetKeyboardData
ret
endp
 
359,7 → 359,7
.device_data dd ?
end virtual
mov eax, [.device_data]
call Kfree
invoke Kfree
ret 4
endp
 
392,7 → 392,7
add eax, 8 + 3
and eax, not 3
push eax
call Kmalloc
invoke Kmalloc
pop ecx
test eax, eax
jz .nothing
444,7 → 444,7
or edx, [ebx+usb_device_data.interface_number]
mov [eax+4], edx
; 8. Submit output control request.
stdcall USBControlTransferAsync, [ebx+usb_device_data.configpipe], \
invoke USBControlTransferAsync, [ebx+usb_device_data.configpipe], \
eax, edi, [size], after_set_keyboard_lights, ebx, 0
; If failed, free the buffer now.
; If succeeded, the callback will free the buffer.
451,7 → 451,7
test eax, eax
jnz .nothing
lea eax, [edi-8]
call Kfree
invoke Kfree
.nothing:
ret
endp
470,6 → 470,6
; Ignore status, just free the buffer allocated by SetKeyboardLights.
mov eax, [.buffer]
sub eax, 8
call Kfree
invoke Kfree
ret 20
endp
/drivers/usb/usbhid/mouse.inc
34,7 → 34,7
proc mouse_driver_add_device
; Just allocate memory; no initialization needed.
movi eax, sizeof.mouse_device_data
call Kmalloc
invoke Kmalloc
ret
endp
 
44,7 → 44,7
proc mouse_driver_disconnect
; Free the allocated memory.
mov eax, edi
call Kfree
invoke Kfree
ret
endp
 
153,7 → 153,7
; in: edi -> mouse_device_data (pointer returned from mouse_driver_add_device)
proc mouse_driver_end_packet
; Call the kernel, passing collected state.
stdcall SetMouseData, \
invoke SetMouseData, \
[edi+mouse_device_data.buttons], \
[edi+mouse_device_data.dx], \
[edi+mouse_device_data.dy], \
/drivers/usb/usbhid/report.inc
353,7 → 353,7
mov [last_collection], eax
; 1b. Allocate state of global items.
movi eax, sizeof.global_items
call Kmalloc
invoke Kmalloc
test eax, eax
jz .memory_error
; 1c. Zero-initialize it and move pointer to edi.
373,7 → 373,7
test eax, eax
jz @f
push [eax+usage_list_item.next]
call Kfree
invoke Kfree
pop eax
jmp @b
@@:
496,7 → 496,7
cmp [ebx+report_set.data], 0
jnz .invalid_report
mov eax, 256*4
call Kmalloc
invoke Kmalloc
test eax, eax
jz .memory_error
mov [ebx+report_set.data], eax
521,7 → 521,7
jnz .report_allocated
; 7b. Allocate.
movi eax, sizeof.report
call Kmalloc
invoke Kmalloc
test eax, eax
jz .memory_error
; 7c. Initialize.
568,7 → 568,7
mov edx, [num_usage_ranges]
lea eax, [eax+edx*sizeof.usage_range+4]
@@:
call Kmalloc
invoke Kmalloc
pop edx
test eax, eax
jz .memory_error
688,7 → 688,7
; allocate, zero-initialize, update parent, if there is one,
; make it current.
movi eax, sizeof.collection
call Kmalloc
invoke Kmalloc
test eax, eax
jz .memory_error
push eax edi
817,7 → 817,7
; For Push, allocate new global_items structure,
; initialize from the current one and make it current.
movi eax, sizeof.global_items
call Kmalloc
invoke Kmalloc
test eax, eax
jz .memory_error
push esi eax
835,7 → 835,7
jz .invalid_report
push eax
xchg eax, edi
call Kfree
invoke Kfree
pop edi
jmp .item_parsed
; -------------------------------- Local items --------------------------------
862,7 → 862,7
push 1
.new_usage:
movi eax, sizeof.usage_list_item
call Kmalloc
invoke Kmalloc
pop edx
test eax, eax
jz .memory_error
912,7 → 912,7
inc [delimiter_depth]
push esi
mov esi, delimiter_note
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
jmp .item_parsed
.delimiter.close:
954,7 → 954,7
.memory_error:
mov esi, nomemory_msg
.end_str:
call SysMsgBoardStr
invoke SysMsgBoardStr
.end:
; Free all global_items structures.
test edi, edi
961,7 → 961,7
jz @f
push [edi+global_items.next]
xchg eax, edi
call Kfree
invoke Kfree
pop edi
jmp .end
@@:
971,7 → 971,7
test eax, eax
jz @f
push [eax+usage_list_item.next]
call Kfree
invoke Kfree
pop eax
jmp @b
@@:
1116,7 → 1116,7
mov eax, [esi+collection.parent]
@@:
xchg eax, esi
call Kfree
invoke Kfree
jmp .free_collections
.collections_done:
; 3. Free all three report sets.
1136,19 → 1136,19
test eax, eax
jz .field_done
push [eax+report_field_group.next]
call Kfree
invoke Kfree
pop eax
jmp .field_loop
.field_done:
mov eax, [edi+report.next]
xchg eax, edi
call Kfree
invoke Kfree
jmp .report_loop
.report_done:
cmp [esi+report_set.numbered], 0
jz @f
mov eax, [esi+report_set.data]
call Kfree
invoke Kfree
@@:
add esi, sizeof.report_set
dec dword [esp]
/drivers/usb/usbhid/usbhid.asm
1,5 → 1,6
; standard driver stuff
format MS COFF
; standard driver stuff; version of driver model = 5
format PE DLL native 0.05
entry START
 
DEBUG = 1
 
7,14 → 8,8
__DEBUG__ = 1
__DEBUG_LEVEL__ = 1
 
include '../proc32.inc'
include '../imports.inc'
include '../fdo.inc'
include '../../struct.inc'
 
public START
public version
 
; Compile-time settings.
; If set, the code will dump all descriptors as they are read to the debug board.
USB_DUMP_DESCRIPTORS = 1
103,12 → 98,17
control rb 8 ; control packet to device
ends
 
section '.flat' code readable align 16
section '.flat' code readable writable executable
include '../../macros.inc'
include '../../proc32.inc'
include '../../peimport.inc'
include '../../fdo.inc'
; The start procedure.
proc START
virtual at esp
dd ? ; return address
.reason dd ?
.cmdline dd ?
end virtual
; 1. Test whether the procedure is called with the argument DRV_ENTRY.
; If not, return 0.
118,10 → 118,10
; 2. Register self as a USB driver.
; The name is my_driver = 'usbhid'; IOCTL interface is not supported;
; usb_functions is an offset of a structure with callback functions.
stdcall RegUSBDriver, my_driver, eax, usb_functions
invoke RegUSBDriver, my_driver, eax, usb_functions
; 3. Return the returned value of RegUSBDriver.
.nothing:
ret 4
ret
endp
 
; This procedure is called when new HID device is detected.
138,11 → 138,11
DEBUGF 1,'K : USB HID device detected\n'
; 1. Allocate memory for device data.
movi eax, sizeof.usb_device_data
call Kmalloc
invoke Kmalloc
test eax, eax
jnz @f
mov esi, nomemory_msg
call SysMsgBoardStr
invoke SysMsgBoardStr
jmp .return0
@@:
; zero-initialize it
215,11 → 215,11
.cfgerror:
; 6a. Print a message.
mov esi, invalid_config_descr_msg
call SysMsgBoardStr
invoke SysMsgBoardStr
; 6b. Free memory allocated for device data.
.free:
xchg eax, ebx
call Kfree
invoke Kfree
.return0:
; 6c. Return an error.
xor eax, eax
255,7 → 255,7
mov eax, [.config_pipe]
mov [ebx+usb_device_data.configpipe], eax
xor ecx, ecx
stdcall USBControlTransferAsync, eax, edx, ecx, ecx, idle_set, ebx, ecx
invoke USBControlTransferAsync, eax, edx, ecx, ecx, idle_set, ebx, ecx
; 7. Return pointer to usb_device_data.
xchg eax, ebx
jmp .nothing
295,7 → 295,7
.cfgerror:
mov esi, invalid_config_descr_msg
.abort_with_msg:
call SysMsgBoardStr
invoke SysMsgBoardStr
jmp .nothing
.found_report:
; 2. Send request for the Report descriptor.
304,7 → 304,7
test eax, eax
jz .cfgerror
push eax
call Kmalloc
invoke Kmalloc
pop ecx
; If failed, say a message and stop initialization.
mov esi, nomemory_msg
320,13 → 320,13
(REPORT_DESCR_TYPE shl 24); descriptor type
mov [edx+4], ax ; Interface number
mov [edx+6], cx ; descriptor length
stdcall USBControlTransferAsync, [ebx+usb_device_data.configpipe], \
invoke USBControlTransferAsync, [ebx+usb_device_data.configpipe], \
edx, esi, ecx, got_report, ebx, 0
; 2c. If failed, free the buffer and stop initialization.
test eax, eax
jnz .nothing
xchg eax, esi
call Kfree
invoke Kfree
.nothing:
pop esi ebx ; restore used registers to be stdcall
ret 20
353,7 → 353,7
.generic_fail:
push esi
mov esi, reportfail
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
jmp .exit
.has_something:
386,7 → 386,7
movzx ecx, [edx+endpoint_descr.bEndpointAddress]
movzx eax, [edx+endpoint_descr.bInterval]
movzx edx, [edx+endpoint_descr.wMaxPacketSize]
stdcall USBOpenPipe, [ebx+usb_device_data.configpipe], ecx, edx, INTERRUPT_PIPE, eax
invoke USBOpenPipe, [ebx+usb_device_data.configpipe], ecx, edx, INTERRUPT_PIPE, eax
test eax, eax
jz got_report.exit
mov [ebx+usb_device_data.intpipe], eax
418,11 → 418,11
; for extract_field_value.
add eax, 4+3
and eax, not 3
call Kmalloc
invoke Kmalloc
test eax, eax
jnz @f
mov esi, nomemory_msg
call SysMsgBoardStr
invoke SysMsgBoardStr
jmp got_report.exit
@@:
mov [ebx+usb_device_data.input_buffer], eax
430,7 → 430,7
call ask_for_input
got_report.exit:
mov eax, [buffer]
call Kfree
invoke Kfree
ret
endp
 
439,7 → 439,7
proc ask_for_input
; just call USBNormalTransferAsync with correct parameters,
; allow short packets
stdcall USBNormalTransferAsync, \
invoke USBNormalTransferAsync, \
[ebx+usb_device_data.intpipe], \
[ebx+usb_device_data.input_buffer], \
[ebx+usb_device_data.input_transfer_size], \
492,7 → 492,7
ret
.fail:
mov esi, transfer_error_msg
call SysMsgBoardStr
invoke SysMsgBoardStr
jmp .nothing
endp
 
507,12 → 507,12
; 1. Say a message.
mov ebx, [.device_data]
mov esi, disconnectmsg
stdcall SysMsgBoardStr
invoke SysMsgBoardStr
; 2. Ask HID layer to release all HID-related resources.
hid_cleanup
; 3. Free the device data.
xchg eax, ebx
call Kfree
invoke Kfree
; 4. Return.
.nothing:
pop edi esi ebx ; restore used registers to be stdcall
534,9 → 534,7
invalid_report_msg db 'K : report descriptor is invalid',13,10,0
delimiter_note db 'K : note: alternate usage ignored',13,10,0
 
; Exported variable: kernel API version.
align 4
version dd 50005h
; Structure with callback functions.
usb_functions:
dd 12
549,5 → 547,6
; Workers data
workers_globals
 
; for uninitialized data
;section '.data' data readable writable align 16
align 4
data fixups
end data