From 65d0cef44baee2f44dc3625db5e2c70d801bf439 Mon Sep 17 00:00:00 2001 From: CleverMouse Date: Wed, 26 Jun 2013 23:35:43 +0000 Subject: [PATCH] style fixes, no binary changes (style checker was sick for some time) git-svn-id: svn://kolibrios.org@3711 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/blkdev/hd_drv.inc | 36 +- kernel/trunk/boot/bootcode.inc | 46 +- kernel/trunk/bus/usb/ohci.inc | 2 +- kernel/trunk/detect/dev_hdcd.inc | 28 +- kernel/trunk/detect/sear_par.inc | 16 +- kernel/trunk/drivers/usbhid/keyboard.inc | 478 +++--- kernel/trunk/drivers/usbhid/mouse.inc | 122 +- kernel/trunk/drivers/usbhid/report.inc | 1668 ++++++++++----------- kernel/trunk/drivers/usbhid/sort.inc | 10 +- kernel/trunk/drivers/usbhid/unclaimed.inc | 36 +- kernel/trunk/fs/ext2.inc | 10 +- kernel/trunk/fs/fs_lfn.inc | 28 +- kernel/trunk/gui/skincode.inc | 2 +- kernel/trunk/network/ARP.inc | 10 +- kernel/trunk/network/IPv4.inc | 14 +- kernel/trunk/network/IPv6.inc | 2 +- kernel/trunk/network/PPPoE.inc | 2 +- kernel/trunk/network/icmp.inc | 8 +- kernel/trunk/network/loopback.inc | 2 +- kernel/trunk/network/queue.inc | 2 +- kernel/trunk/network/socket.inc | 16 +- kernel/trunk/network/stack.inc | 14 +- kernel/trunk/network/tcp.inc | 2 +- kernel/trunk/network/tcp_input.inc | 2 +- kernel/trunk/network/tcp_output.inc | 2 +- kernel/trunk/network/udp.inc | 6 +- 26 files changed, 1282 insertions(+), 1282 deletions(-) diff --git a/kernel/trunk/blkdev/hd_drv.inc b/kernel/trunk/blkdev/hd_drv.inc index 8a23656599..e874a206ea 100644 --- a/kernel/trunk/blkdev/hd_drv.inc +++ b/kernel/trunk/blkdev/hd_drv.inc @@ -107,15 +107,15 @@ hd_read_pio: mov al, byte [hdid] add al, 128+64+32 out dx, al; номер головки/номер диска - + call wait_for_hd_idle cmp [hd_error], 0 jne hd_read_error - + ; ATA with 28 or 48 bit for sector number? mov eax, [esp+4] cmp eax, 0x10000000 - jae .lba48 + jae .lba48 .lba28: pushfd cli @@ -142,10 +142,10 @@ hd_read_pio: add al, 128+64+32 out dx, al ; номер головки/номер диска inc edx - mov al, 20h ; READ SECTOR(S) + mov al, 20h ; READ SECTOR(S) out dx, al ; ATACommand регистр команд popfd - jmp .continue + jmp .continue .lba48: pushfd cli @@ -160,14 +160,14 @@ hd_read_pio: out dx, al ; Sector Count Current Sector count (7:0) inc edx mov eax, [esp+4+4] - rol eax,8 + rol eax, 8 out dx, al ; LBA Low Previous LBA (31:24) - xor eax,eax ; because only 32 bit cache + xor eax, eax; because only 32 bit cache inc edx out dx, al ; LBA Mid Previous LBA (39:32) inc edx out dx, al ; LBA High Previous LBA (47:40) - sub edx,2 + sub edx, 2 mov eax, [esp+4+4] out dx, al ; LBA Low Current LBA (7:0) shr eax, 8 @@ -181,7 +181,7 @@ hd_read_pio: add al, 128+64+32 out dx, al; номер головки/номер диска inc edx - mov al, 24h ; READ SECTOR(S) EXT + mov al, 24h ; READ SECTOR(S) EXT out dx, al; ATACommand регистр команд popfd .continue: @@ -339,7 +339,7 @@ cache_write_pio: mov al, 30h ; WRITE SECTOR(S) out dx, al ; ATACommand регистр команд popfd - jmp .continue + jmp .continue .lba48: pushfd cli @@ -354,14 +354,14 @@ cache_write_pio: out dx, al ; Sector Count Current Sector count (7:0) inc edx mov eax, [esi] - rol eax,8 + rol eax, 8 out dx, al ; LBA Low Previous LBA (31:24) - xor eax,eax ; because only 32 bit cache + xor eax, eax; because only 32 bit cache inc edx out dx, al ; LBA Mid Previous LBA (39:32) inc edx out dx, al ; LBA High Previous LBA (47:40) - sub edx,2 + sub edx, 2 mov eax, [esi] out dx, al ; LBA Low Current LBA (7:0) shr eax, 8 @@ -375,7 +375,7 @@ cache_write_pio: add al, 128+64+32 out dx, al; номер головки/номер диска inc edx - mov al, 34h ; WRITE SECTOR(S) EXT + mov al, 34h ; WRITE SECTOR(S) EXT out dx, al; ATACommand регистр команд popfd .continue: @@ -925,10 +925,10 @@ write_cache_chain: uglobal IDEContrRegsBaseAddr dw ? IDEContrProgrammingInterface dw ? -IDE_BAR0_val dw ? -IDE_BAR1_val dw ? -IDE_BAR2_val dw ? -IDE_BAR3_val dw ? +IDE_BAR0_val dw ? +IDE_BAR1_val dw ? +IDE_BAR2_val dw ? +IDE_BAR3_val dw ? endg ; \end{Mario79} diff --git a/kernel/trunk/boot/bootcode.inc b/kernel/trunk/boot/bootcode.inc index 9479d65cde..26fd65ab36 100644 --- a/kernel/trunk/boot/bootcode.inc +++ b/kernel/trunk/boot/bootcode.inc @@ -387,12 +387,12 @@ sayerr: push 0 pop es - xor ax,ax - and word [es:BOOT_IDE_BASE_ADDR], ax ;0 - and word [es:BOOT_IDE_BAR0_16], ax ;0 - and word [es:BOOT_IDE_BAR1_16], ax ;0 - and word [es:BOOT_IDE_BAR2_16], ax ;0 - and word [es:BOOT_IDE_BAR3_16], ax ;0 + xor ax, ax + and word [es:BOOT_IDE_BASE_ADDR], ax ;0 + and word [es:BOOT_IDE_BAR0_16], ax ;0 + and word [es:BOOT_IDE_BAR1_16], ax ;0 + and word [es:BOOT_IDE_BAR2_16], ax ;0 + and word [es:BOOT_IDE_BAR3_16], ax ;0 ; \begin{Mario79} ; find HDD IDE DMA PCI device ; check for PCI BIOS @@ -433,55 +433,55 @@ sayerr: int 0x1A jnc .found - jmp .nopci + jmp .nopci .found_1: ; get memory base BAR4 mov ax, 0xB10A mov di, 0x20 ; memory base is config register at 0x20 - push cx + push cx int 0x1A - jc .no_BAR4 ;.nopci + jc .no_BAR4 ;.nopci and cx, 0xFFF0 ; clear address decode type mov [es:BOOT_IDE_BASE_ADDR], cx .no_BAR4: - pop cx -.found: + pop cx +.found: ; get memory base BAR0 mov ax, 0xB10A mov di, 0x10 ; memory base is config register at 0x20 - push cx + push cx int 0x1A - jc .no_BAR0 ;.nopci + jc .no_BAR0 ;.nopci mov [es:BOOT_IDE_BAR0_16], cx .no_BAR0: - pop cx + pop cx ; get memory base BAR1 mov ax, 0xB10A mov di, 0x14 ; memory base is config register at 0x20 - push cx + push cx int 0x1A - jc .no_BAR1 ;.nopci + jc .no_BAR1 ;.nopci mov [es:BOOT_IDE_BAR1_16], cx .no_BAR1: - pop cx + pop cx ; get memory base BAR2 mov ax, 0xB10A mov di, 0x18 ; memory base is config register at 0x20 - push cx + push cx int 0x1A - jc .no_BAR2 ;.nopci + jc .no_BAR2 ;.nopci mov [es:BOOT_IDE_BAR2_16], cx .no_BAR2: - pop cx + pop cx ; get memory base BAR3 mov ax, 0xB10A mov di, 0x1C ; memory base is config register at 0x20 - push cx + push cx int 0x1A - jc .no_BAR3 ;.nopci + jc .no_BAR3 ;.nopci mov [es:BOOT_IDE_BAR3_16], cx .no_BAR3: - pop cx + pop cx .nopci: ; \end{Mario79} diff --git a/kernel/trunk/bus/usb/ohci.inc b/kernel/trunk/bus/usb/ohci.inc index 5c7516cc7d..5581a78e11 100644 --- a/kernel/trunk/bus/usb/ohci.inc +++ b/kernel/trunk/bus/usb/ohci.inc @@ -243,7 +243,7 @@ NextTD dd ? ; Virtual pointer to the next processed TD. BufEnd dd ? ; Physical address of the last byte in the buffer for this TD. - dd ? ; padding to align with uhci_gtd + dd ? ; padding to align with uhci_gtd ends ; OHCI isochronous transfer descriptor. diff --git a/kernel/trunk/detect/dev_hdcd.inc b/kernel/trunk/detect/dev_hdcd.inc index 62386bf686..a09eefaeeb 100644 --- a/kernel/trunk/detect/dev_hdcd.inc +++ b/kernel/trunk/detect/dev_hdcd.inc @@ -64,20 +64,20 @@ FindHDD_1: jne FindHDD_2_2 inc byte [DRIVE_DATA+1] inc byte [DRIVE_DATA+1] -Print_Device_Name: - pushad - pushfd - mov esi,Sector512+27*2 - mov edi,dev_name - mov ecx,20 - cld +Print_Device_Name: + pushad + pushfd + mov esi, Sector512+27*2 + mov edi, dev_name + mov ecx, 20 + cld @@: - lodsw - xchg ah,al - stosw - loop @b - popfd - popad + lodsw + xchg ah, al + stosw + loop @b + popfd + popad DEBUGF 1, "K : Dev: %s \n", dev_name FindHDD_2_2: ret @@ -91,7 +91,7 @@ FindHDD_3: uglobal SectorAddress DD ? dev_name: - rb 41 + rb 41 endg ;************************************************* ;* ЧТЕНИЕ ИДЕНТИФИКАТОРА ЖЕСТКОГО ДИСКА * diff --git a/kernel/trunk/detect/sear_par.inc b/kernel/trunk/detect/sear_par.inc index 3407307081..e56a92a641 100644 --- a/kernel/trunk/detect/sear_par.inc +++ b/kernel/trunk/detect/sear_par.inc @@ -17,8 +17,8 @@ $Revision$ search_partitions_ide0: test [DRIVE_DATA+1], byte 0x40 jz search_partitions_ide1 - mov eax,[hd_address_table] - mov [hdbase], eax ;0x1f0 + mov eax, [hd_address_table] + mov [hdbase], eax ;0x1f0 mov [hdid], 0x0 mov [hdpos], 1 mov [known_part], 1 @@ -40,8 +40,8 @@ $Revision$ search_partitions_ide1: test [DRIVE_DATA+1], byte 0x10 jz search_partitions_ide2 - mov eax,[hd_address_table] - mov [hdbase], eax ;0x1f0 + mov eax, [hd_address_table] + mov [hdbase], eax ;0x1f0 mov [hdid], 0x10 mov [hdpos], 2 mov [known_part], 1 @@ -63,8 +63,8 @@ $Revision$ search_partitions_ide2: test [DRIVE_DATA+1], byte 0x4 jz search_partitions_ide3 - mov eax,[hd_address_table+16] - mov [hdbase], eax ;0x170 + mov eax, [hd_address_table+16] + mov [hdbase], eax ;0x170 mov [hdid], 0x0 mov [hdpos], 3 mov [known_part], 1 @@ -86,8 +86,8 @@ $Revision$ search_partitions_ide3: test [DRIVE_DATA+1], byte 0x1 jz end_search_partitions_ide - mov eax,[hd_address_table+16] - mov [hdbase], eax ;0x170 + mov eax, [hd_address_table+16] + mov [hdbase], eax ;0x170 mov [hdid], 0x10 mov [hdpos], 4 mov [known_part], 1 diff --git a/kernel/trunk/drivers/usbhid/keyboard.inc b/kernel/trunk/drivers/usbhid/keyboard.inc index d906ce7e34..a6047e789c 100644 --- a/kernel/trunk/drivers/usbhid/keyboard.inc +++ b/kernel/trunk/drivers/usbhid/keyboard.inc @@ -7,36 +7,36 @@ macro workers_globals { ; include global constants from previous workers - workers_globals + workers_globals align 4 ; Callbacks for HID layer. keyboard_driver: - dd keyboard_driver_add_device - dd keyboard_driver_disconnect - dd keyboard_driver_begin_packet - dd keyboard_driver_array_overflow? - dd keyboard_driver_input_field - dd keyboard_driver_end_packet + dd keyboard_driver_add_device + dd keyboard_driver_disconnect + dd keyboard_driver_begin_packet + dd keyboard_driver_array_overflow? + dd keyboard_driver_input_field + dd keyboard_driver_end_packet ; Callbacks for keyboard layer. kbd_functions: - dd 12 - dd CloseKeyboard - dd SetKeyboardLights + dd 12 + dd CloseKeyboard + dd SetKeyboardLights ; Kernel keyboard layer takes input in form of PS/2 scancodes. ; data for keyboard: correspondence between HID usage keys and PS/2 scancodes. -EX = 80h ; if set, precede the scancode with special scancode 0xE0 +EX = 80h ; if set, precede the scancode with special scancode 0xE0 label control_keys byte ; Usages 700E0h ... 700E7h: LCtrl, LShift, LAlt, LWin, RCtrl, RShift, RAlt, RWin db 1Dh, 2Ah, 38h, 5Bh+EX, 1Dh+EX, 36h, 38h+EX, 5Ch+EX ; Usages 70004h ... 70004h + normal_keys_number - 1 label normal_keys byte db 1Eh, 30h, 2Eh, 20h, 12h, 21h, 22h, 23h, 17h, 24h, 25h, 26h, 32h, 31h, 18h, 19h - db 10h, 13h, 1Fh, 14h, 16h, 2Fh, 11h, 2Dh, 15h, 2Ch, 02h, 03h, 04h, 05h, 06h, 07h + db 10h, 13h, 1Fh, 14h, 16h, 2Fh, 11h, 2Dh, 15h, 2Ch, 02h, 03h, 04h, 05h, 06h, 07h db 08h, 09h, 0Ah, 0Bh, 1Ch, 01h, 0Eh, 0Fh, 39h, 0Ch, 0Dh, 1Ah, 1Bh, 2Bh, 0, 27h db 28h, 29h, 33h, 34h, 35h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh, 40h, 41h, 42h, 43h, 44h db 57h, 58h,37h+EX,46h,0,52h+EX,47h+EX,49h+EX,53h+EX,4Fh+EX,51h+EX,4Dh+EX,4Bh+EX,50h+EX,48h+EX,45h - db 35h+EX,37h,4Ah,4Eh,1Ch+EX,4Fh,50h, 51h, 4Bh, 4Ch, 4Dh, 47h, 48h, 49h, 52h, 53h - db 0,5Dh+EX,5Eh+EX + db 35h+EX,37h,4Ah,4Eh,1Ch+EX,4Fh,50h, 51h, 4Bh, 4Ch, 4Dh, 47h, 48h, 49h, 52h, 53h + db 0,5Dh+EX,5Eh+EX normal_keys_number = $ - normal_keys } @@ -45,13 +45,13 @@ struct keyboard_device_data handle dd ? ; keyboard handle from RegKeyboard timer dd ? ; auto-repeat timer handle repeatkey db ? ; auto-repeat key code - rb 3 ; padding -usbdev dd ? ; pointer to device_data of USB and HID layers -modifiers dd ? ; state of LCtrl ... RWin -led_report dd ? ; output report for LEDs state -numlock_bit dd ? ; position of NumLock bit in LED output report -capslock_bit dd ? -scrolllock_bit dd ? ; guess what + rb 3 ; padding +usbdev dd ? ; pointer to device_data of USB and HID layers +modifiers dd ? ; state of LCtrl ... RWin +led_report dd ? ; output report for LEDs state +numlock_bit dd ? ; position of NumLock bit in LED output report +capslock_bit dd ? +scrolllock_bit dd ? ; guess what ends ; This procedure is called when HID layer detects a new keyboard. @@ -59,117 +59,117 @@ ends ; out: eax = device-specific data or NULL on error proc keyboard_driver_add_device ; 1. Allocate memory for keyboard_device_data. If failed, return NULL. - movi eax, sizeof.keyboard_device_data - call Kmalloc - test eax, eax - jz .nothing + movi eax, sizeof.keyboard_device_data + call Kmalloc + test eax, eax + jz .nothing ; 2. Initialize keyboard_device_data: store pointer to USB layer data, ; zero some fields, initialize bit positions to -1. - mov [eax+keyboard_device_data.usbdev], ebx - xor ecx, ecx - mov [eax+keyboard_device_data.timer], ecx - mov [eax+keyboard_device_data.repeatkey], cl - mov [eax+keyboard_device_data.modifiers], ecx - mov [eax+keyboard_device_data.led_report], ecx - dec ecx - mov [eax+keyboard_device_data.numlock_bit], ecx - mov [eax+keyboard_device_data.capslock_bit], ecx - mov [eax+keyboard_device_data.scrolllock_bit], ecx + mov [eax+keyboard_device_data.usbdev], ebx + xor ecx, ecx + mov [eax+keyboard_device_data.timer], ecx + mov [eax+keyboard_device_data.repeatkey], cl + mov [eax+keyboard_device_data.modifiers], ecx + mov [eax+keyboard_device_data.led_report], ecx + dec ecx + mov [eax+keyboard_device_data.numlock_bit], ecx + mov [eax+keyboard_device_data.capslock_bit], ecx + mov [eax+keyboard_device_data.scrolllock_bit], ecx ; 3. Look for LED report and bits corresponding to indicators. ; For now, assume that all LEDs are set by the same report. ; 3a. Save registers. - push ebx esi + push ebx esi ; 3b. Prepare for loop over output reports: get the first output report. ; If there are no output records, skip step 3; ; default values of led_report and *_bit were set in step 2. - mov edx, [edi+collection.output.first_report] - test edx, edx - jz .led_report_set + mov edx, [edi+collection.output.first_report] + test edx, edx + jz .led_report_set .scan_led_report: ; Process one output report. ; 3c. Prepare for loop over field groups in the current report: ; get the first field group. - mov ecx, [edx+report.first_field] + mov ecx, [edx+report.first_field] .scan_led_field: ; Process one field group. ; 3d. If there are no more field groups, exit the loop over field groups. - test ecx, ecx - jz .next_led_report + test ecx, ecx + jz .next_led_report ; For now, assume that all LEDs are plain variable fields, not arrays. ; 3e. Ignore array field groups. - test byte [ecx+report_field_group.flags], HID_FIELD_VARIABLE - jz .next_led_field + test byte [ecx+report_field_group.flags], HID_FIELD_VARIABLE + jz .next_led_field ; 3f. Loop over all fields in the current group. - push [ecx+report_field_group.count] + push [ecx+report_field_group.count] ; esi = pointer to usage of the current field - lea esi, [ecx+report_field_group.common_sizeof] + lea esi, [ecx+report_field_group.common_sizeof] ; ebx = bit position of the current field - mov ebx, [ecx+report_field_group.offset] + mov ebx, [ecx+report_field_group.offset] ; if report is numbered, add extra byte in the start of report - cmp [edx+report.id], 0 - jz .scan_led_usage - add ebx, 8 + cmp [edx+report.id], 0 + jz .scan_led_usage + add ebx, 8 .scan_led_usage: ; for USAGE_LED_*LOCK, store the current bit position in the corresponding field ; and store the current report as the LED report - cmp dword [esi], USAGE_LED_NUMLOCK - jz .numlock - cmp dword [esi], USAGE_LED_CAPSLOCK - jz .capslock - cmp dword [esi], USAGE_LED_SCROLLLOCK - jnz .next_field + cmp dword [esi], USAGE_LED_NUMLOCK + jz .numlock + cmp dword [esi], USAGE_LED_CAPSLOCK + jz .capslock + cmp dword [esi], USAGE_LED_SCROLLLOCK + jnz .next_field .scrolllock: - mov [eax+keyboard_device_data.scrolllock_bit], ebx - jmp @f + mov [eax+keyboard_device_data.scrolllock_bit], ebx + jmp @f .capslock: - mov [eax+keyboard_device_data.capslock_bit], ebx - jmp @f + mov [eax+keyboard_device_data.capslock_bit], ebx + jmp @f .numlock: - mov [eax+keyboard_device_data.numlock_bit], ebx + mov [eax+keyboard_device_data.numlock_bit], ebx @@: - mov [eax+keyboard_device_data.led_report], edx + mov [eax+keyboard_device_data.led_report], edx .next_field: - add esi, 4 - add ebx, [ecx+report_field_group.size] - dec dword [esp] - jnz .scan_led_usage - pop ebx + add esi, 4 + add ebx, [ecx+report_field_group.size] + dec dword [esp] + jnz .scan_led_usage + pop ebx .next_led_field: ; 3g. Continue loop over field groups: get next field group. - mov ecx, [ecx+report_field_group.next] - jmp .scan_led_field + mov ecx, [ecx+report_field_group.next] + jmp .scan_led_field .next_led_report: ; 3h. If the LED report has been set, break from the loop over reports. ; Otherwise, get the next report and continue if the current report is not ; the last for this collection. - cmp [eax+keyboard_device_data.led_report], 0 - jnz .led_report_set - cmp edx, [edi+collection.output.last_report] - mov edx, [edx+report.next] - jnz .scan_led_report + cmp [eax+keyboard_device_data.led_report], 0 + jnz .led_report_set + cmp edx, [edi+collection.output.last_report] + mov edx, [edx+report.next] + jnz .scan_led_report .led_report_set: ; 3i. Restore registers. - pop esi ebx + pop esi ebx ; 4. Register keyboard in the kernel. ; store pointer to keyboard_device_data in the stack - push eax + push eax ; call kernel API - stdcall RegKeyboard, kbd_functions, eax + stdcall RegKeyboard, kbd_functions, eax ; restore pointer to keyboard_device_data from the stack, ; putting keyboard handle from API to the stack - xchg eax, [esp] + xchg eax, [esp] ; put keyboard handle from API from the stack to keyboard_device_data field - pop [eax+keyboard_device_data.handle] + pop [eax+keyboard_device_data.handle] ; If failed, free keyboard_device_data and return NULL. - cmp [eax+keyboard_device_data.handle], 0 - jz .fail_free + cmp [eax+keyboard_device_data.handle], 0 + jz .fail_free ; 5. Return pointer to keyboard_device_data. .nothing: - ret + ret .fail_free: - call Kfree - xor eax, eax - ret + call Kfree + xor eax, eax + ret endp ; This procedure is called when HID layer detects disconnect of a previously @@ -177,14 +177,14 @@ endp ; in: edi -> keyboard_device_data (pointer returned from keyboard_driver_add_device) proc keyboard_driver_disconnect ; 1. If an autorepeat timer is active, stop it. - cmp [edi+keyboard_device_data.timer], 0 - jz @f + cmp [edi+keyboard_device_data.timer], 0 + jz @f stdcall CancelTimerHS, [edi+keyboard_device_data.timer] @@: ; 2. Unregister keyboard in the kernel. - stdcall DelKeyboard, [edi+keyboard_device_data.handle] + stdcall DelKeyboard, [edi+keyboard_device_data.handle] ; We should free data in CloseKeyboard, not here. - ret + ret endp ; This procedure is called when HID layer starts processing a new input packet @@ -192,7 +192,7 @@ endp ; in: edi -> keyboard_device_data (pointer returned from keyboard_driver_add_device) proc keyboard_driver_begin_packet ; Nothing to do. - ret + ret endp ; This procedure is called when HID layer processes every non-empty array field group. @@ -203,10 +203,10 @@ endp proc keyboard_driver_array_overflow? ; The keyboard signals array overflow by filling the entire array with ; USAGE_KBD_ROLLOVER codes. - mov eax, [edx] ; eax = first field in the array - sub eax, USAGE_KBD_ROLLOVER ; eax = 0 if overflow, nonzero otherwise - neg eax ; CF cleared if eax was zero, CF set if eax was nonzero - ret + mov eax, [edx] ; eax = first field in the array + sub eax, USAGE_KBD_ROLLOVER ; eax = 0 if overflow, nonzero otherwise + neg eax ; CF cleared if eax was zero, CF set if eax was nonzero + ret endp ; This procedure is called from HID layer for every field. @@ -220,112 +220,112 @@ end if ; from USAGE_KBD_FIRST_KEY to USAGE_KBD_FIRST_KEY + normal_keys_number - 1, ; excluding zeroes in [normal_keys]. ; 1a. Test whether usage is in the range. - lea eax, [ecx-USAGE_KBD_FIRST_KEY] - cmp eax, normal_keys_number - jae .not_normal_key + lea eax, [ecx-USAGE_KBD_FIRST_KEY] + cmp eax, normal_keys_number + jae .not_normal_key ; 1b. If the corresponding entry in [normal_keys] is zero, ; pass this field to the default handler - if HID_DUMP_UNCLAIMED is enabled, ; default handler is default_driver_input_field, otherwise just ignore the field. - cmp [normal_keys + eax], 0 - jz .unclaimed + cmp [normal_keys + eax], 0 + jz .unclaimed ; 1c. Get the scancode. - movzx ecx, [normal_keys + eax] + movzx ecx, [normal_keys + eax] ; 1d. Further actions are slightly different for key press and key release. ; Decide what to do. - test edx, edx - jz .normal_key_released + test edx, edx + jz .normal_key_released .normal_key_pressed: ; The key is pressed. ; 1e. Store the last pressed key for autorepeat. - mov [edi+keyboard_device_data.repeatkey], cl + mov [edi+keyboard_device_data.repeatkey], cl ; 1f. Copy bit 7 to CF and send scancode with bit 7 cleared. - btr ecx, 7 - call .send_key + btr ecx, 7 + call .send_key ; 1g. Stop the previous autorepeat timer, if any. - mov eax, [edi+keyboard_device_data.timer] - test eax, eax - jz @f - stdcall CancelTimerHS, eax + mov eax, [edi+keyboard_device_data.timer] + test eax, eax + jz @f + stdcall 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 - mov [edi+keyboard_device_data.timer], eax + stdcall TimerHS, 25, 5, autorepeat_timer, edi + mov [edi+keyboard_device_data.timer], eax if ~HID_DUMP_UNCLAIMED .unclaimed: end if - ret + ret .normal_key_released: ; The key is released. ; 1i. Stop the autorepeat timer if it is autorepeating the released key. - cmp [edi+keyboard_device_data.repeatkey], cl - jnz .no_stop_timer - push ecx - mov [edi+keyboard_device_data.repeatkey], 0 - mov eax, [edi+keyboard_device_data.timer] - test eax, eax - jz @f - stdcall CancelTimerHS, eax - mov [edi+keyboard_device_data.timer], 0 + cmp [edi+keyboard_device_data.repeatkey], cl + jnz .no_stop_timer + push ecx + mov [edi+keyboard_device_data.repeatkey], 0 + mov eax, [edi+keyboard_device_data.timer] + test eax, eax + jz @f + stdcall CancelTimerHS, eax + mov [edi+keyboard_device_data.timer], 0 @@: - pop ecx + pop ecx .no_stop_timer: ; 1j. Copy bit 7 to CF and send scancode with bit 7 set. - bts ecx, 7 - call .send_key - ret + bts ecx, 7 + call .send_key + ret .not_normal_key: ; 2. USAGE_KBD_NOEVENT is simply a filler for free array fields, ; ignore it. - cmp ecx, USAGE_KBD_NOEVENT - jz .nothing + cmp ecx, USAGE_KBD_NOEVENT + jz .nothing ; 3. Process modifiers: 8 keys starting at USAGE_KBD_LCTRL. ; 3a. Test whether usage is in range. ; If not, we don't know what this field means, so pass it to the default handler. - lea eax, [ecx-USAGE_KBD_LCTRL] - cmp eax, 8 - jae .unclaimed + lea eax, [ecx-USAGE_KBD_LCTRL] + cmp eax, 8 + jae .unclaimed ; 3b. Further actions are slightly different for modifier press ; and modifier release. Decide what to do. - test edx, edx - jz .modifier_not_pressed + test edx, edx + jz .modifier_not_pressed .modifier_pressed: ; The modifier is pressed. ; 3c. Set the corresponding status bit. ; If it was not set, send the corresponding scancode to the kernel ; with bit 7 cleared. - bts [edi+keyboard_device_data.modifiers], eax - jc @f - movzx ecx, [control_keys+eax] - btr ecx, 7 - call .send_key + bts [edi+keyboard_device_data.modifiers], eax + jc @f + movzx ecx, [control_keys+eax] + btr ecx, 7 + call .send_key @@: .nothing: - ret + ret .modifier_not_pressed: ; The modifier is not pressed. ; 3d. Clear the correspodning status bit. ; If it was set, send the corresponding scancode to the kernel ; with bit 7 set. - btr [edi+keyboard_device_data.modifiers], eax - jnc @f - movzx ecx, [control_keys+eax] - bts ecx, 7 - call .send_key + btr [edi+keyboard_device_data.modifiers], eax + jnc @f + movzx ecx, [control_keys+eax] + bts ecx, 7 + call .send_key @@: - ret + ret ; Helper procedure. Sends scancode from cl to the kernel. ; If CF is set, precede it with special code 0xE0. .send_key: - jnc @f - push ecx - mov ecx, 0xE0 - call SetKeyboardData - pop ecx + jnc @f + push ecx + mov ecx, 0xE0 + call SetKeyboardData + pop ecx @@: - call SetKeyboardData - ret + call SetKeyboardData + ret endp ; This procedure is called when HID layer ends processing a new input packet @@ -333,143 +333,143 @@ endp ; in: edi -> keyboard_device_data (pointer returned from keyboard_driver_add_device) proc keyboard_driver_end_packet ; Nothing to do. - ret + ret endp ; Timer callback for SetTimerHS. proc autorepeat_timer virtual at esp - dd ? ; return address -.data dd ? + dd ? ; return address +.data dd ? end virtual ; Just resend the last pressed key. - mov eax, [.data] - movzx ecx, [eax+keyboard_device_data.repeatkey] + mov eax, [.data] + movzx ecx, [eax+keyboard_device_data.repeatkey] ; Copy bit 7 to CF and send scancode with bit 7 cleared. - btr ecx, 7 - call keyboard_driver_input_field.send_key - ret 4 + btr ecx, 7 + call keyboard_driver_input_field.send_key + ret 4 endp ; This function is called from the keyboard layer ; when it is safe to free keyboard data. proc CloseKeyboard virtual at esp - dd ? ; return address -.device_data dd ? + dd ? ; return address +.device_data dd ? end virtual - mov eax, [.device_data] - call Kfree - ret 4 + mov eax, [.device_data] + call Kfree + ret 4 endp ; This function is called from the keyboard layer ; to update LED state on the keyboard. proc SetKeyboardLights stdcall uses ebx esi edi, device_data, led_state locals -size dd ? +size dd ? endl ; 1. Get the pointer to the LED report. ; If there is no LED report, exit from the function. - mov ebx, [device_data] - mov esi, [ebx+keyboard_device_data.led_report] - test esi, esi - jz .nothing + mov ebx, [device_data] + mov esi, [ebx+keyboard_device_data.led_report] + test esi, esi + jz .nothing ; 2. Get report size in bytes. ; report.size is size in bits without possible report ID; ; if an ID is assigned, the size is one byte greater. - mov eax, [esi+report.size] - add eax, 7 - shr eax, 3 - cmp [esi+report.id], 0 - jz @f - inc eax + mov eax, [esi+report.size] + add eax, 7 + shr eax, 3 + cmp [esi+report.id], 0 + jz @f + inc eax @@: - mov [size], eax + mov [size], eax ; 3. Allocate memory for report + 8 bytes for setup packet. ; Dword-align size for subsequent rep stosd and bts. ; If failed, exit from the function. - add eax, 8 + 3 - and eax, not 3 - push eax - call Kmalloc - pop ecx - test eax, eax - jz .nothing + add eax, 8 + 3 + and eax, not 3 + push eax + call Kmalloc + pop ecx + test eax, eax + jz .nothing ; 4. Zero-initialize output report. - push eax - mov edi, eax - shr ecx, 2 - xor eax, eax - rep stosd - pop edi - add edi, 8 + push eax + mov edi, eax + shr ecx, 2 + xor eax, eax + rep stosd + pop edi + add edi, 8 ; 5. Store report ID, if assigned. If not assigned, that would just write zero ; over zeroes. - mov edx, [esi+report.id] - mov [edi], edx + mov edx, [esi+report.id] + mov [edi], edx ; 6. Set report bits corresponding to active indicators. - mov eax, [led_state] - test al, 1 ; PS/2 Scroll Lock - jz @f - mov ecx, [ebx+keyboard_device_data.scrolllock_bit] - test ecx, ecx - js @f - bts [edi], ecx + mov eax, [led_state] + test al, 1 ; PS/2 Scroll Lock + jz @f + mov ecx, [ebx+keyboard_device_data.scrolllock_bit] + test ecx, ecx + js @f + bts [edi], ecx @@: - test al, 2 ; PS/2 Num Lock - jz @f - mov ecx, [ebx+keyboard_device_data.numlock_bit] - test ecx, ecx - js @f - bts [edi], ecx + test al, 2 ; PS/2 Num Lock + jz @f + mov ecx, [ebx+keyboard_device_data.numlock_bit] + test ecx, ecx + js @f + bts [edi], ecx @@: - test al, 4 ; PS/2 Caps Lock - jz @f - mov ecx, [ebx+keyboard_device_data.capslock_bit] - test ecx, ecx - js @f - bts [edi], ecx + test al, 4 ; PS/2 Caps Lock + jz @f + mov ecx, [ebx+keyboard_device_data.capslock_bit] + test ecx, ecx + js @f + bts [edi], ecx @@: ; 7. Fill setup packet. - shl edx, 16 ; move Report ID to byte 2 - or edx, 21h + \ ; Class-specific request to Interface - (9 shl 8) + \ ; SET_REPORT - (2 shl 24) ; Report Type = Output - lea eax, [edi-8] - mov ebx, [ebx+keyboard_device_data.usbdev] - mov dword [eax], edx - mov edx, [size] - shl edx, 16 ; move Size to last word - or edx, [ebx+usb_device_data.interface_number] - mov [eax+4], edx + shl edx, 16 ; move Report ID to byte 2 + or edx, 21h + \ ; Class-specific request to Interface + (9 shl 8) + \ ; SET_REPORT + (2 shl 24) ; Report Type = Output + lea eax, [edi-8] + mov ebx, [ebx+keyboard_device_data.usbdev] + mov dword [eax], edx + mov edx, [size] + shl edx, 16 ; move Size to last word + or edx, [ebx+usb_device_data.interface_number] + mov [eax+4], edx ; 8. Submit output control request. - stdcall USBControlTransferAsync, [ebx+usb_device_data.configpipe], \ - eax, edi, [size], after_set_keyboard_lights, ebx, 0 + stdcall 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. - test eax, eax - jnz .nothing - lea eax, [edi-8] - call Kfree + test eax, eax + jnz .nothing + lea eax, [edi-8] + call Kfree .nothing: - ret + ret endp ; This procedure is called from the USB subsystem when the request initiated by ; SetKeyboardLights is completed, either successfully or unsuccessfully. proc after_set_keyboard_lights virtual at esp - dd ? ; return address -.pipe dd ? -.status dd ? -.buffer dd ? -.length dd ? -.calldata dd ? + dd ? ; return address +.pipe dd ? +.status dd ? +.buffer dd ? +.length dd ? +.calldata dd ? end virtual ; Ignore status, just free the buffer allocated by SetKeyboardLights. - mov eax, [.buffer] - sub eax, 8 - call Kfree - ret 20 + mov eax, [.buffer] + sub eax, 8 + call Kfree + ret 20 endp diff --git a/kernel/trunk/drivers/usbhid/mouse.inc b/kernel/trunk/drivers/usbhid/mouse.inc index 7c1b4c6db2..9f0ee65010 100644 --- a/kernel/trunk/drivers/usbhid/mouse.inc +++ b/kernel/trunk/drivers/usbhid/mouse.inc @@ -7,24 +7,24 @@ macro workers_globals { ; include global constants from previous workers - workers_globals + workers_globals align 4 ; Callbacks for HID layer. mouse_driver: - dd mouse_driver_add_device - dd mouse_driver_disconnect - dd mouse_driver_begin_packet - dd mouse_driver_array_overflow? - dd mouse_driver_input_field - dd mouse_driver_end_packet + dd mouse_driver_add_device + dd mouse_driver_disconnect + dd mouse_driver_begin_packet + dd mouse_driver_array_overflow? + dd mouse_driver_input_field + dd mouse_driver_end_packet } ; Data that are specific for one mouse device. struct mouse_device_data -buttons dd ? ; buttons that are currently pressed -dx dd ? ; current x moving -dy dd ? ; current y moving -wheel dd ? ; current wheel moving +buttons dd ? ; buttons that are currently pressed +dx dd ? ; current x moving +dy dd ? ; current y moving +wheel dd ? ; current wheel moving ends ; This procedure is called when HID layer detects a new mouse. @@ -32,9 +32,9 @@ ends ; out: eax = device-specific data or NULL on error proc mouse_driver_add_device ; Just allocate memory; no initialization needed. - movi eax, sizeof.mouse_device_data - call Kmalloc - ret + movi eax, sizeof.mouse_device_data + call Kmalloc + ret endp ; This procedure is called when HID layer detects disconnect of a previously @@ -42,9 +42,9 @@ endp ; in: edi -> mouse_device_data (pointer returned from mouse_driver_add_device) proc mouse_driver_disconnect ; Free the allocated memory. - mov eax, edi - call Kfree - ret + mov eax, edi + call Kfree + ret endp ; This procedure is called when HID layer starts processing a new input packet @@ -52,11 +52,11 @@ endp ; in: edi -> mouse_device_data (pointer returned from mouse_driver_add_device) proc mouse_driver_begin_packet ; Zero all variables describing the current state. - mov [edi+mouse_device_data.buttons], 0 - mov [edi+mouse_device_data.dx], 0 - mov [edi+mouse_device_data.dy], 0 - mov [edi+mouse_device_data.wheel], 0 - ret + mov [edi+mouse_device_data.buttons], 0 + mov [edi+mouse_device_data.dx], 0 + mov [edi+mouse_device_data.dy], 0 + mov [edi+mouse_device_data.wheel], 0 + ret endp ; This procedure is called when HID layer processes every non-empty array field group. @@ -66,8 +66,8 @@ endp ; out: CF set => array is ok, CF cleared => array should be ignored proc mouse_driver_array_overflow? ; no array fields, no overflows - stc - ret + stc + ret endp ; This procedure is called from HID layer for every field. @@ -77,58 +77,58 @@ proc mouse_driver_input_field ; 1. Determine the handler. We process x/y moving, wheel and up to 32 buttons. ; Pass other fields to the default handler - default_driver_input_field if ; HID_DUMP_UNCLAIMED is enabled, just ignore otherwise. - cmp ecx, USAGE_GD_X - jz .x - cmp ecx, USAGE_GD_Y - jz .y - cmp ecx, USAGE_GD_WHEEL - jz .wheel - sub ecx, USAGE_BUTTON_PAGE + 1 - jb .unclaimed - cmp ecx, 32 - jae .unclaimed + cmp ecx, USAGE_GD_X + jz .x + cmp ecx, USAGE_GD_Y + jz .y + cmp ecx, USAGE_GD_WHEEL + jz .wheel + sub ecx, USAGE_BUTTON_PAGE + 1 + jb .unclaimed + cmp ecx, 32 + jae .unclaimed ; 2. This is a button. ; If a button is pressed, set the corresponding bit in the state. ; If a button is not pressed, do nothing. - test edx, edx - jz @f - bts [edi+mouse_device_data.buttons], ecx + test edx, edx + jz @f + bts [edi+mouse_device_data.buttons], ecx @@: if ~HID_DUMP_UNCLAIMED .unclaimed: end if - ret + ret if HID_DUMP_UNCLAIMED .unclaimed: - add ecx, USAGE_BUTTON_PAGE + 1 - jmp default_driver_input_field + add ecx, USAGE_BUTTON_PAGE + 1 + jmp default_driver_input_field end if .x: ; 3. This is x moving. For relative fields, store the value in the state. ; Pass absolute field to the default handler. - test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE - jz .unclaimed - mov [edi+mouse_device_data.dx], edx - ret + test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE + jz .unclaimed + mov [edi+mouse_device_data.dx], edx + ret .y: ; 4. This is y moving. For relative fields, store the value in the state, ; changing the sign: HID uses "mathematics" scheme with Y axis increasing from ; bottom to top, the kernel expects "programming" PS/2-style with Y axis ; increasing from top to bottom. ; Pass absolute fields to the default handler. - test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE - jz .unclaimed - neg edx - mov [edi+mouse_device_data.dy], edx - ret + test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE + jz .unclaimed + neg edx + mov [edi+mouse_device_data.dy], edx + ret .wheel: ; 5. This is wheel event. For relative fields, store the value in the state, ; changing the sign. Pass absolute fields to the default handler. - test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE - jz .unclaimed - neg edx - mov [edi+mouse_device_data.wheel], edx - ret + test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE + jz .unclaimed + neg edx + mov [edi+mouse_device_data.wheel], edx + ret endp ; This procedure is called when HID layer ends processing a new input packet @@ -136,11 +136,11 @@ endp ; 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, \ - [edi+mouse_device_data.buttons], \ - [edi+mouse_device_data.dx], \ - [edi+mouse_device_data.dy], \ - [edi+mouse_device_data.wheel], \ - 0 - ret + stdcall SetMouseData, \ + [edi+mouse_device_data.buttons], \ + [edi+mouse_device_data.dx], \ + [edi+mouse_device_data.dy], \ + [edi+mouse_device_data.wheel], \ + 0 + ret endp diff --git a/kernel/trunk/drivers/usbhid/report.inc b/kernel/trunk/drivers/usbhid/report.inc index c278429428..aabec02030 100644 --- a/kernel/trunk/drivers/usbhid/report.inc +++ b/kernel/trunk/drivers/usbhid/report.inc @@ -70,40 +70,40 @@ MAX_REPORT_BYTES = 1024 ; This structure describes one range or one individual usage in a large array; ; individual usage is equivalent to a range of length 1. struct usage_range -offset dd ? +offset dd ? ; Sum of range sizes over all previous array items. ; Size of range a equals ; [a + sizeof.usage_range + usage_range.offset] - [a + usage_range.offset]. ; The total sum over all array items immediately follows the array, ; this field must be the first so that the formula above works for the last item. -first_usage dd ? +first_usage dd ? ; Usage code for first item in the range. ends ; This structure describes one group of report fields with identical properties. struct report_field_group -next dd ? +next dd ? ; All field groups in one report are organized in a single-linked list. ; This is the next group in the report or 0 for the last group. -size dd ? +size dd ? ; Size in bits of one field. Cannot be zero or greater than 32. -count dd ? ; field count, cannot be zero -offset dd ? ; offset from report start, in bits +count dd ? ; field count, cannot be zero +offset dd ? ; offset from report start, in bits ; Following fields are decoded from report descriptor, see HID spec for details. -flags dd ? -logical_minimum dd ? -logical_maximum dd ? -physical_minimum dd ? -physical_maximum dd ? -unit_exponent dd ? -unit dd ? +flags dd ? +logical_minimum dd ? +logical_maximum dd ? +physical_minimum dd ? +physical_maximum dd ? +unit_exponent dd ? +unit dd ? ; Following fields are used to speedup extract_field_value. -mask dd ? +mask dd ? ; Bitmask for all data bits except sign bit: ; (1 shl .size) - 1 for unsigned fields, (1 shl (.size-1)) - 1 for signed fields -sign_mask dd ? +sign_mask dd ? ; Zero for unsigned fields. Bitmask with sign bit set for signed fields. -common_sizeof rd 0 +common_sizeof rd 0 ; Variable and Array field groups differ significantly. ; Variable field groups are simple. There are .count fields, each field has ; predefined Usage, the content of a field is its value. Each field is @@ -127,126 +127,126 @@ common_sizeof rd 0 ; an additional dword after array described in usage_range structure; ; * allocated memory for current values of the report; ; * values of the previous report. -num_values_prev dd ? ; number of values in the previous report -num_usage_ranges dd ? ; number of usage_range, always nonzero -usages rd 0 +num_values_prev dd ? ; number of values in the previous report +num_usage_ranges dd ? ; number of usage_range, always nonzero +usages rd 0 ends ; This structure describes one report. ; All reports of one type are organized into a single-linked list. struct report -next dd ? ; pointer to next report of the same type, if any -size dd ? ; total size in bits -first_field dd ? ; pointer to first report_field_group for this report -last_field dd ? +next dd ? ; pointer to next report of the same type, if any +size dd ? ; total size in bits +first_field dd ? ; pointer to first report_field_group for this report +last_field dd ? ; pointer to last report_field_group for this report, if any; ; address of .first_field, if .first_field is 0 -id dd ? +id dd ? ; Report ID, if assigned. Zero otherwise. -top_level_collection dd ? ; top-level collection for this report +top_level_collection dd ? ; top-level collection for this report ends ; This structure describes a set of reports of the same type; ; there are 3 sets (possibly empty), input, output and feature. struct report_set -data dd ? +data dd ? ; If .numbered is zero, this is zero for the empty set and ; a pointer to the (only) report structure otherwise. ; If .numbered is nonzero, this is a pointer to 256-dword array of pointers ; to reports organized by report ID. -first_report dd ? +first_report dd ? ; Pointer to the first report or 0 for the empty set. -numbered db ? +numbered db ? ; If zero, report IDs are not used, there can be at most one report in the set. ; If nonzero, first byte of the report is report ID. - rb 3 ; padding + rb 3 ; padding ends ; This structure describes a range of reports of one type that belong to ; some collection. struct collection_report_set -first_report dd ? -first_field dd ? -last_report dd ? -last_field dd ? +first_report dd ? +first_field dd ? +last_report dd ? +last_field dd ? ends ; This structure defines driver callbacks which are used while ; device is active; i.e. all callbacks except add_device. struct hid_driver_active_callbacks -disconnect dd ? +disconnect dd ? ; Called when an existing HID device is disconnected. ; ; Four following functions are called when a new input packet arrives ; in the following order: .begin_packet, then .input_field several times ; for each input field, interleaved with .array_overflow? for array groups, ; then .end_packet. -begin_packet dd ? +begin_packet dd ? ; edi -> driver data -array_overflow? dd ? +array_overflow? dd ? ; edi -> driver data ; out: CF cleared <=> ignore this array -input_field dd ? +input_field dd ? ; edi -> driver data, ecx = usage, edx = value -end_packet dd ? +end_packet dd ? ; edi -> driver data ends ; This structure describes one collection. struct collection -next dd ? ; pointer to the next collection in the same level - ; must be the first field -parent dd ? ; pointer to nesting collection -first_child dd ? ; pointer to the first nested collection -last_child dd ? ; pointer to the last nested collection - ; or to .first_child, if .first_child is zero -type dd ? ; Application, Physical etc -usage dd ? ; associated Usage code +next dd ? ; pointer to the next collection in the same level + ; must be the first field +parent dd ? ; pointer to nesting collection +first_child dd ? ; pointer to the first nested collection +last_child dd ? ; pointer to the last nested collection + ; or to .first_child, if .first_child is zero +type dd ? ; Application, Physical etc +usage dd ? ; associated Usage code ; Next fields are filled only for top-level collections. -callbacks hid_driver_active_callbacks -driver_data dd ? ; value to be passed as is to driver callbacks -input collection_report_set -output collection_report_set -feature collection_report_set +callbacks hid_driver_active_callbacks +driver_data dd ? ; value to be passed as is to driver callbacks +input collection_report_set +output collection_report_set +feature collection_report_set ends ; This structure keeps all data used by the HID layer for one device. struct hid_data -input report_set -output report_set -feature report_set -first_collection dd ? +input report_set +output report_set +feature report_set +first_collection dd ? ends ; This structure defines callbacks required from the driver. struct hid_driver_callbacks -add_device dd ? +add_device dd ? ; Called when a new HID device is connected. -active hid_driver_active_callbacks +active hid_driver_active_callbacks ends ; Two following structures describe temporary data; ; the corresponding objects cease to exist when HID parser completes ; state of Global items struct global_items -next dd ? -usage_page dd ? -logical_minimum dd ? -logical_maximum dd ? -physical_minimum dd ? -physical_maximum dd ? -unit_exponent dd ? -unit dd ? -report_size dd ? -report_id dd ? -report_count dd ? +next dd ? +usage_page dd ? +logical_minimum dd ? +logical_maximum dd ? +physical_minimum dd ? +physical_maximum dd ? +unit_exponent dd ? +unit dd ? +report_size dd ? +report_id dd ? +report_count dd ? ends ; one range of Usages struct usage_list_item -next dd ? -first_usage dd ? -num_usages dd ? +next dd ? +first_usage dd ? +num_usages dd ? ends ; ============================================================================= @@ -255,79 +255,79 @@ ends macro workers_globals { - workers_globals + workers_globals ; Jump tables for switch'ing in the code. align 4 ; jump table for two lower bits which encode size of item data parse_descr_label.fetch_jumps: - dd parse_descr_label.fetch_none ; x0, x4, x8, xC - dd parse_descr_label.fetch_byte ; x1, x5, x9, xD - dd parse_descr_label.fetch_word ; x2, x6, xA, xE - dd parse_descr_label.fetch_dword ; x3, x7, xB, xF + dd parse_descr_label.fetch_none ; x0, x4, x8, xC + dd parse_descr_label.fetch_byte ; x1, x5, x9, xD + dd parse_descr_label.fetch_word ; x2, x6, xA, xE + dd parse_descr_label.fetch_dword ; x3, x7, xB, xF ; jump table for two next bits which encode item type parse_descr_label.type_jumps: - dd parse_descr_label.parse_main - dd parse_descr_label.parse_global - dd parse_descr_label.parse_local - dd parse_descr_label.parse_reserved + dd parse_descr_label.parse_main + dd parse_descr_label.parse_global + dd parse_descr_label.parse_local + dd parse_descr_label.parse_reserved ; jump table for 4 upper bits in the case of Main item parse_descr_label.main_jumps: - dd parse_descr_label.input ; 80...83 - dd parse_descr_label.output ; 90...93 - dd parse_descr_label.collection ; A0...A3 - dd parse_descr_label.feature ; B0...B3 - dd parse_descr_label.end_collection ; C0...C3 + dd parse_descr_label.input ; 80...83 + dd parse_descr_label.output ; 90...93 + dd parse_descr_label.collection ; A0...A3 + dd parse_descr_label.feature ; B0...B3 + dd parse_descr_label.end_collection ; C0...C3 parse_descr_label.num_main_items = ($ - parse_descr_label.main_jumps) / 4 ; jump table for 4 upper bits in the case of Global item parse_descr_label.global_jumps: - dd parse_descr_label.usage_page ; 04...07 - dd parse_descr_label.logical_minimum ; 14...17 - dd parse_descr_label.logical_maximum ; 24...27 - dd parse_descr_label.physical_minimum ; 34...37 - dd parse_descr_label.physical_maximum ; 44...47 - dd parse_descr_label.unit_exponent ; 54...57 - dd parse_descr_label.unit ; 64...67 - dd parse_descr_label.report_size ; 74...77 - dd parse_descr_label.report_id ; 84...87 - dd parse_descr_label.report_count ; 94...97 - dd parse_descr_label.push ; A4...A7 - dd parse_descr_label.pop ; B4...B7 + dd parse_descr_label.usage_page ; 04...07 + dd parse_descr_label.logical_minimum ; 14...17 + dd parse_descr_label.logical_maximum ; 24...27 + dd parse_descr_label.physical_minimum ; 34...37 + dd parse_descr_label.physical_maximum ; 44...47 + dd parse_descr_label.unit_exponent ; 54...57 + dd parse_descr_label.unit ; 64...67 + dd parse_descr_label.report_size ; 74...77 + dd parse_descr_label.report_id ; 84...87 + dd parse_descr_label.report_count ; 94...97 + dd parse_descr_label.push ; A4...A7 + dd parse_descr_label.pop ; B4...B7 parse_descr_label.num_global_items = ($ - parse_descr_label.global_jumps) / 4 ; jump table for 4 upper bits in the case of Local item parse_descr_label.local_jumps: - dd parse_descr_label.usage ; 08...0B - dd parse_descr_label.usage_minimum ; 18...1B - dd parse_descr_label.usage_maximum ; 28...2B - dd parse_descr_label.item_parsed ; 38...3B = designator item; ignore - dd parse_descr_label.item_parsed ; 48...4B = designator minimum; ignore - dd parse_descr_label.item_parsed ; 58...5B = designator maximum; ignore - dd parse_descr_label.item_parsed ; 68...6B not assigned - dd parse_descr_label.item_parsed ; 78...7B = string index; ignore - dd parse_descr_label.item_parsed ; 88...8B = string minimum; ignore - dd parse_descr_label.item_parsed ; 98...9B = string maximum; ignore - dd parse_descr_label.delimiter ; A8...AB + dd parse_descr_label.usage ; 08...0B + dd parse_descr_label.usage_minimum ; 18...1B + dd parse_descr_label.usage_maximum ; 28...2B + dd parse_descr_label.item_parsed ; 38...3B = designator item; ignore + dd parse_descr_label.item_parsed ; 48...4B = designator minimum; ignore + dd parse_descr_label.item_parsed ; 58...5B = designator maximum; ignore + dd parse_descr_label.item_parsed ; 68...6B not assigned + dd parse_descr_label.item_parsed ; 78...7B = string index; ignore + dd parse_descr_label.item_parsed ; 88...8B = string minimum; ignore + dd parse_descr_label.item_parsed ; 98...9B = string maximum; ignore + dd parse_descr_label.delimiter ; A8...AB parse_descr_label.num_local_items = ($ - parse_descr_label.local_jumps) / 4 } ; Local variables for parse_descr. macro parse_descr_locals { -cur_item_size dd ? ; encoded size of data for current item -report_ok db ? ; 0 on error, 1 if everything is ok -field_type db ? ; 0/1/2 for input/output/feature fields - rb 2 ; alignment -field_data dd ? ; data for current item when it describes a field group -last_reports rd 3 ; pointers to last input/output/feature records -usage_minimum dd ? ; current value of Usage Minimum -usage_list dd ? ; list head of usage_list_item -usage_tail dd ? ; list tail of usage_list_item -num_usage_ranges dd ? ; number of usage ranges, size of usage_list -delimiter_depth dd ? ; normally 0; 1 inside of Delimiter(); - ; nested Delimiter()s are not allowed -usage_variant dd ? ; 0 outside of Delimiter()s and for first Usage inside Delimiter(), - ; incremented with each new Usage inside Delimiter() -cur_collection dd ? ; current collection -last_collection dd ? ; last top-level collection +cur_item_size dd ? ; encoded size of data for current item +report_ok db ? ; 0 on error, 1 if everything is ok +field_type db ? ; 0/1/2 for input/output/feature fields + rb 2 ; alignment +field_data dd ? ; data for current item when it describes a field group +last_reports rd 3 ; pointers to last input/output/feature records +usage_minimum dd ? ; current value of Usage Minimum +usage_list dd ? ; list head of usage_list_item +usage_tail dd ? ; list tail of usage_list_item +num_usage_ranges dd ? ; number of usage ranges, size of usage_list +delimiter_depth dd ? ; normally 0; 1 inside of Delimiter(); + ; nested Delimiter()s are not allowed +usage_variant dd ? ; 0 outside of Delimiter()s and for first Usage inside Delimiter(), + ; incremented with each new Usage inside Delimiter() +cur_collection dd ? ; current collection +last_collection dd ? ; last top-level collection } ; Parse report descriptor. The caller should provide local variables @@ -338,427 +338,427 @@ macro parse_descr parse_descr_label: ; 1. Initialize. ; 1a. Set some variables to initial values. - xor edi, edi - mov dword [report_ok], edi - mov [usage_list], edi - mov [cur_collection], edi - mov eax, [calldata] - add eax, hid_data.input.first_report - mov [last_reports+0*4], eax - add eax, hid_data.output.first_report - hid_data.input.first_report - mov [last_reports+1*4], eax - add eax, hid_data.feature.first_report - hid_data.output.first_report - mov [last_reports+2*4], eax - add eax, hid_data.first_collection - hid_data.feature.first_report - mov [last_collection], eax + xor edi, edi + mov dword [report_ok], edi + mov [usage_list], edi + mov [cur_collection], edi + mov eax, [calldata] + add eax, hid_data.input.first_report + mov [last_reports+0*4], eax + add eax, hid_data.output.first_report - hid_data.input.first_report + mov [last_reports+1*4], eax + add eax, hid_data.feature.first_report - hid_data.output.first_report + mov [last_reports+2*4], eax + add eax, hid_data.first_collection - hid_data.feature.first_report + mov [last_collection], eax ; 1b. Allocate state of global items. - movi eax, sizeof.global_items - call Kmalloc - test eax, eax - jz .memory_error + movi eax, sizeof.global_items + call Kmalloc + test eax, eax + jz .memory_error ; 1c. Zero-initialize it and move pointer to edi. - push eax - xchg eax, edi - movi ecx, sizeof.global_items / 4 - rep stosd - pop edi + push eax + xchg eax, edi + movi ecx, sizeof.global_items / 4 + rep stosd + pop edi ; 1d. Load pointer to data into esi and make [length] point to end of data. - mov esi, [buffer] - add [length], esi + mov esi, [buffer] + add [length], esi ; 2. Clear all local items. ; This is needed in the beginning and after processing any Main item. .zero_local_items: - mov eax, [usage_list] + mov eax, [usage_list] @@: - test eax, eax - jz @f - push [eax+usage_list_item.next] - call Kfree - pop eax - jmp @b + test eax, eax + jz @f + push [eax+usage_list_item.next] + call Kfree + pop eax + jmp @b @@: - lea ecx, [usage_list] - mov [usage_tail], ecx - mov [ecx], eax - mov [delimiter_depth], eax - mov [usage_variant], eax - mov [usage_minimum], eax - mov [num_usage_ranges], eax + lea ecx, [usage_list] + mov [usage_tail], ecx + mov [ecx], eax + mov [delimiter_depth], eax + mov [usage_variant], eax + mov [usage_minimum], eax + mov [num_usage_ranges], eax ; 3. Parse items until end of data found. - cmp esi, [length] - jae .parse_end + cmp esi, [length] + jae .parse_end .fetch_next_item: ; --------------------------------- Parse item -------------------------------- ; 4. Parse one item. ; 4a. Get item data. eax = first item byte = code+type+size (4+2+2 bits), ; ebx = item data interpreted as unsigned, ; ecx = item data interpreted as signed. - movzx eax, byte [esi] - mov ecx, eax - and ecx, 3 - mov [cur_item_size], ecx - jmp dword [.fetch_jumps+ecx*4] + movzx eax, byte [esi] + mov ecx, eax + and ecx, 3 + mov [cur_item_size], ecx + jmp dword [.fetch_jumps+ecx*4] .invalid_report: - mov esi, invalid_report_msg - jmp .end_str + mov esi, invalid_report_msg + jmp .end_str .fetch_none: - xor ebx, ebx - xor ecx, ecx - inc esi - jmp .fetched + xor ebx, ebx + xor ecx, ecx + inc esi + jmp .fetched .fetch_byte: - add esi, 2 - cmp esi, [length] - ja .invalid_report - movzx ebx, byte [esi-1] - movsx ecx, bl - jmp .fetched + add esi, 2 + cmp esi, [length] + ja .invalid_report + movzx ebx, byte [esi-1] + movsx ecx, bl + jmp .fetched .fetch_word: - add esi, 3 - cmp esi, [length] - ja .invalid_report - movzx ebx, word [esi-2] - movsx ecx, bx - jmp .fetched + add esi, 3 + cmp esi, [length] + ja .invalid_report + movzx ebx, word [esi-2] + movsx ecx, bx + jmp .fetched .fetch_dword: - add esi, 5 - cmp esi, [length] - ja .invalid_report - mov ebx, dword [esi-4] - mov ecx, ebx + add esi, 5 + cmp esi, [length] + ja .invalid_report + mov ebx, dword [esi-4] + mov ecx, ebx .fetched: ; 4b. Select the branch according to item type. ; For every type, select the concrete handler and go there. - mov edx, eax - shr edx, 2 - and edx, 3 - shr eax, 4 - jmp dword [.type_jumps+edx*4] + mov edx, eax + shr edx, 2 + and edx, 3 + shr eax, 4 + jmp dword [.type_jumps+edx*4] ; -------------------------------- Main items --------------------------------- .parse_main: - sub eax, 8 - cmp eax, .num_main_items - jae .item_parsed - jmp dword [.main_jumps+eax*4] + sub eax, 8 + cmp eax, .num_main_items + jae .item_parsed + jmp dword [.main_jumps+eax*4] ; There are 5 Main items. ; Input/Output/Feature items create new field groups in the corresponding report; ; Collection item opens a new collection (possibly nested), ; End Collection item closes the most nested collection. .output: - mov [field_type], 1 - jmp .new_field + mov [field_type], 1 + jmp .new_field .feature: - mov [field_type], 2 - jmp .new_field + mov [field_type], 2 + jmp .new_field .input: - mov [field_type], 0 + mov [field_type], 0 .new_field: ; Create a new field group. - mov [field_data], ebx - movzx ebx, [field_type] + mov [field_data], ebx + movzx ebx, [field_type] if sizeof.report_set = 12 - lea ebx, [ebx*3] - shl ebx, 2 + lea ebx, [ebx*3] + shl ebx, 2 else err Change the code end if - add ebx, [calldata] + add ebx, [calldata] ; 5. Sanity checks: field size and fields count must be nonzero, ; field size cannot be more than 32 bits, ; if field count is more than MAX_REPORT_SIZE * 8, the report would be more than ; MAX_REPORT_SIZE bytes, so it is invalid too. ; More precise check for size occurs later; this check only guarantees that ; there will be no overflows during subsequent calculations. - cmp [edi+global_items.report_size], 0 - jz .invalid_report - cmp [edi+global_items.report_size], 32 - ja .invalid_report + cmp [edi+global_items.report_size], 0 + jz .invalid_report + cmp [edi+global_items.report_size], 32 + ja .invalid_report ; There are devices with Report Count(0) + Input(Constant Variable), ; zero-length padding. Thus, do not consider descriptors with Report Count(0) ; as invalid; instead, just ignore fields with Report Count(0). - cmp [edi+global_items.report_count], 0 - jz .zero_local_items - cmp [edi+global_items.report_count], MAX_REPORT_BYTES * 8 - ja .invalid_report + cmp [edi+global_items.report_count], 0 + jz .zero_local_items + cmp [edi+global_items.report_count], MAX_REPORT_BYTES * 8 + ja .invalid_report ; 6. Get the pointer to the place for the corresponding report in ebx. ; 6a. If report ID is not assigned, ebx already points to report_set.data, ; so go to 7. - cmp [edi+global_items.report_id], 0 - jz .report_ptr_found + cmp [edi+global_items.report_id], 0 + jz .report_ptr_found ; 6b. If table for reports was already allocated, ; go to 6d skipping the next substep. - cmp [ebx+report_set.numbered], 0 - jnz .report_set_allocated + cmp [ebx+report_set.numbered], 0 + jnz .report_set_allocated ; 6c. This is the first report with ID; ; allocate and zero-initialize table for reports. ; Note: it is incorrect but theoretically possible that some fields were ; already allocated in report without ID; if so, abort processing with error. - cmp [ebx+report_set.data], 0 - jnz .invalid_report - mov eax, 256*4 - call Kmalloc - test eax, eax - jz .memory_error - mov [ebx+report_set.data], eax - inc [ebx+report_set.numbered] - push edi - mov edi, eax - mov ecx, 256 - xor eax, eax - rep stosd - pop edi + cmp [ebx+report_set.data], 0 + jnz .invalid_report + mov eax, 256*4 + call Kmalloc + test eax, eax + jz .memory_error + mov [ebx+report_set.data], eax + inc [ebx+report_set.numbered] + push edi + mov edi, eax + mov ecx, 256 + xor eax, eax + rep stosd + pop edi ; 6d. Report ID is assigned, report table is allocated, ; get the pointer to the corresponding item in the report table. .report_set_allocated: - mov ebx, [ebx+report_set.data] - mov ecx, [edi+global_items.report_id] - lea ebx, [ebx+ecx*4] + mov ebx, [ebx+report_set.data] + mov ecx, [edi+global_items.report_id] + lea ebx, [ebx+ecx*4] ; 7. If the field group is the first one in the report, ; allocate and initialize report without fields. .report_ptr_found: ; 7a. Check whether the report has been allocated. - cmp dword [ebx], 0 - jnz .report_allocated + cmp dword [ebx], 0 + jnz .report_allocated ; 7b. Allocate. - movi eax, sizeof.report - call Kmalloc - test eax, eax - jz .memory_error + movi eax, sizeof.report + call Kmalloc + test eax, eax + jz .memory_error ; 7c. Initialize. - xor edx, edx - lea ecx, [eax+report.first_field] - mov [ebx], eax - mov [eax+report.next], edx - mov [eax+report.size], edx - mov [ecx], edx - mov [eax+report.last_field], ecx - mov [eax+report.top_level_collection], edx - mov ecx, [edi+global_items.report_id] - mov [eax+report.id], ecx + xor edx, edx + lea ecx, [eax+report.first_field] + mov [ebx], eax + mov [eax+report.next], edx + mov [eax+report.size], edx + mov [ecx], edx + mov [eax+report.last_field], ecx + mov [eax+report.top_level_collection], edx + mov ecx, [edi+global_items.report_id] + mov [eax+report.id], ecx ; 7d. Append to the overall list of reports. - movzx edx, [field_type] - lea edx, [last_reports+edx*4] - mov ecx, [edx] - mov [edx], eax - mov [ecx], eax + movzx edx, [field_type] + lea edx, [last_reports+edx*4] + mov ecx, [edx] + mov [edx], eax + mov [ecx], eax .report_allocated: - mov ebx, [ebx] + mov ebx, [ebx] ; ebx points to an already existing report; add new field. ; 8. Calculate total size of the group and ; check that the new group would not overflow the report. - mov eax, [edi+global_items.report_size] - mul [edi+global_items.report_count] - mov ecx, [ebx+report.size] - add ecx, eax - cmp ecx, MAX_REPORT_BYTES * 8 - ja .invalid_report + mov eax, [edi+global_items.report_size] + mul [edi+global_items.report_count] + mov ecx, [ebx+report.size] + add ecx, eax + cmp ecx, MAX_REPORT_BYTES * 8 + ja .invalid_report ; 9. If there are no usages for this group, this is padding; ; add it's size to total report size and stop processing. - cmp [num_usage_ranges], 0 - jz .padding + cmp [num_usage_ranges], 0 + jz .padding ; 10. Allocate memory for the group: this includes field group structure ; and additional fields depending on field type. ; See comments in report_field_group structure. - push eax - mov edx, [edi+global_items.report_count] - lea eax, [report_field_group.common_sizeof+edx*4] - test byte [field_data], HID_FIELD_VARIABLE - jnz @f - lea eax, [eax+edx*4] - mov edx, [num_usage_ranges] - lea eax, [eax+edx*sizeof.usage_range+4] + push eax + mov edx, [edi+global_items.report_count] + lea eax, [report_field_group.common_sizeof+edx*4] + test byte [field_data], HID_FIELD_VARIABLE + jnz @f + lea eax, [eax+edx*4] + mov edx, [num_usage_ranges] + lea eax, [eax+edx*sizeof.usage_range+4] @@: - call Kmalloc - pop edx - test eax, eax - jz .memory_error + call Kmalloc + pop edx + test eax, eax + jz .memory_error ; 11. Update report data. ; Field offset is the current report size; ; get the current report size and update report size. ; Also store the pointer to new field in the previous last field ; and update the last field. - mov ecx, [ebx+report.last_field] - xadd [ebx+report.size], edx - mov [ebx+report.last_field], eax - mov [ecx], eax + mov ecx, [ebx+report.last_field] + xadd [ebx+report.size], edx + mov [ebx+report.last_field], eax + mov [ecx], eax ; 12. Initialize field data: offset was calculated in the previous step, ; copy other characteristics from global_items data, ; calculate .mask and .sign_mask. - mov [eax+report_field_group.offset], edx - xor edx, edx - mov [eax+report_field_group.next], edx - mov [eax+report_field_group.sign_mask], edx - inc edx - mov ecx, [edi+global_items.report_size] - mov [eax+report_field_group.size], ecx - shl edx, cl - cmp [edi+global_items.logical_minimum], 0 - jge .unsigned - shr edx, 1 - mov [eax+report_field_group.sign_mask], edx + mov [eax+report_field_group.offset], edx + xor edx, edx + mov [eax+report_field_group.next], edx + mov [eax+report_field_group.sign_mask], edx + inc edx + mov ecx, [edi+global_items.report_size] + mov [eax+report_field_group.size], ecx + shl edx, cl + cmp [edi+global_items.logical_minimum], 0 + jge .unsigned + shr edx, 1 + mov [eax+report_field_group.sign_mask], edx .unsigned: - dec edx - mov [eax+report_field_group.mask], edx - mov ecx, [edi+global_items.report_count] - mov [eax+report_field_group.count], ecx - mov ecx, [field_data] - mov [eax+report_field_group.flags], ecx + dec edx + mov [eax+report_field_group.mask], edx + mov ecx, [edi+global_items.report_count] + mov [eax+report_field_group.count], ecx + mov ecx, [field_data] + mov [eax+report_field_group.flags], ecx irps field, logical_minimum logical_maximum physical_minimum physical_maximum unit_exponent unit \{ - mov ecx, [edi+global_items.\#field] - mov [eax+report_field_group.\#field], ecx + mov ecx, [edi+global_items.\#field] + mov [eax+report_field_group.\#field], ecx \} ; 13. Update the current collection; nesting collections will be updated by ; end-of-collection handler. - movzx edx, [field_type] + movzx edx, [field_type] if sizeof.collection_report_set = 16 - shl edx, 4 + shl edx, 4 else err Change the code end if - mov ecx, [cur_collection] - test ecx, ecx - jz .no_collection - lea ecx, [ecx+collection.input+edx] - mov [ecx+collection_report_set.last_report], ebx - mov [ecx+collection_report_set.last_field], eax - cmp [ecx+collection_report_set.first_field], 0 - jnz .no_collection - mov [ecx+collection_report_set.first_report], ebx - mov [ecx+collection_report_set.first_field], eax + mov ecx, [cur_collection] + test ecx, ecx + jz .no_collection + lea ecx, [ecx+collection.input+edx] + mov [ecx+collection_report_set.last_report], ebx + mov [ecx+collection_report_set.last_field], eax + cmp [ecx+collection_report_set.first_field], 0 + jnz .no_collection + mov [ecx+collection_report_set.first_report], ebx + mov [ecx+collection_report_set.first_field], eax .no_collection: ; 14. Transform usage ranges. The target format depends on field type. - test byte [eax+report_field_group.flags], HID_FIELD_VARIABLE - jz .transform_usages_for_array + test byte [eax+report_field_group.flags], HID_FIELD_VARIABLE + jz .transform_usages_for_array ; For Variable field groups, expand all ranges to array with .count Usages. ; If total number of Usages in all ranges is too large, ignore excessive. ; If total number of Usages in all ranges is too small, duplicate the last ; Usage up to .count Usages (e.g. group of several indicators can have one usage ; "Generic Indicator" assigned to all fields). - mov ecx, [eax+report_field_group.count] - mov ebx, [usage_list] + mov ecx, [eax+report_field_group.count] + mov ebx, [usage_list] .next_usage_range_for_variable: - mov edx, [ebx+usage_list_item.first_usage] - push [ebx+usage_list_item.num_usages] + mov edx, [ebx+usage_list_item.first_usage] + push [ebx+usage_list_item.num_usages] .next_usage_for_variable: - mov [eax+report_field_group.common_sizeof], edx - dec ecx - jz @f - add eax, 4 - inc edx - dec dword [esp] - jnz .next_usage_for_variable - dec edx - inc dword [esp] - cmp [ebx+usage_list_item.next], 0 - jz .next_usage_for_variable - pop edx - mov ebx, [ebx+usage_list_item.next] - jmp .next_usage_range_for_variable + mov [eax+report_field_group.common_sizeof], edx + dec ecx + jz @f + add eax, 4 + inc edx + dec dword [esp] + jnz .next_usage_for_variable + dec edx + inc dword [esp] + cmp [ebx+usage_list_item.next], 0 + jz .next_usage_for_variable + pop edx + mov ebx, [ebx+usage_list_item.next] + jmp .next_usage_range_for_variable @@: - pop ebx - jmp .zero_local_items + pop ebx + jmp .zero_local_items .transform_usages_for_array: ; For Array field groups, leave ranges unexpanded, but recode in the form ; more convenient to value lookup, see comments in report_field_group structure. - mov ecx, [num_usage_ranges] - mov [eax+report_field_group.num_usage_ranges], ecx - and [eax+report_field_group.num_values_prev], 0 - mov ecx, [usage_list] - xor ebx, ebx + mov ecx, [num_usage_ranges] + mov [eax+report_field_group.num_usage_ranges], ecx + and [eax+report_field_group.num_values_prev], 0 + mov ecx, [usage_list] + xor ebx, ebx @@: - mov edx, [ecx+usage_list_item.first_usage] - mov [eax+report_field_group.usages+usage_range.offset], ebx - add ebx, [ecx+usage_list_item.num_usages] - jc .invalid_report - mov [eax+report_field_group.usages+usage_range.first_usage], edx - add eax, sizeof.usage_range - mov ecx, [ecx+usage_list_item.next] - test ecx, ecx - jnz @b - mov [eax+report_field_group.usages], ebx + mov edx, [ecx+usage_list_item.first_usage] + mov [eax+report_field_group.usages+usage_range.offset], ebx + add ebx, [ecx+usage_list_item.num_usages] + jc .invalid_report + mov [eax+report_field_group.usages+usage_range.first_usage], edx + add eax, sizeof.usage_range + mov ecx, [ecx+usage_list_item.next] + test ecx, ecx + jnz @b + mov [eax+report_field_group.usages], ebx ; New field is initialized. - jmp .zero_local_items + jmp .zero_local_items .padding: - mov [ebx+report.size], ecx - jmp .zero_local_items + mov [ebx+report.size], ecx + jmp .zero_local_items ; Create a new collection, nested in the current one. .collection: ; Actions are quite straightforward: ; allocate, zero-initialize, update parent, if there is one, ; make it current. - movi eax, sizeof.collection - call Kmalloc - test eax, eax - jz .memory_error - push eax edi - movi ecx, sizeof.collection / 4 - xchg edi, eax - xor eax, eax - rep stosd - pop edi eax - mov edx, [cur_collection] - mov [eax+collection.parent], edx - lea ecx, [last_collection] - test edx, edx - jz .no_parent - lea ecx, [edx+collection.last_child] + movi eax, sizeof.collection + call Kmalloc + test eax, eax + jz .memory_error + push eax edi + movi ecx, sizeof.collection / 4 + xchg edi, eax + xor eax, eax + rep stosd + pop edi eax + mov edx, [cur_collection] + mov [eax+collection.parent], edx + lea ecx, [last_collection] + test edx, edx + jz .no_parent + lea ecx, [edx+collection.last_child] .no_parent: - mov edx, [ecx] - mov [ecx], eax - mov [edx], eax - lea ecx, [eax+collection.first_child] + mov edx, [ecx] + mov [ecx], eax + mov [edx], eax + lea ecx, [eax+collection.first_child] ; In theory, there must be at least one usage. ; In practice, some nested collections don't have any. Use zero in this case. - mov edx, [usage_list] - test edx, edx - jz @f - mov edx, [edx+usage_list_item.first_usage] + mov edx, [usage_list] + test edx, edx + jz @f + mov edx, [edx+usage_list_item.first_usage] @@: - mov [eax+collection.last_child], ecx - mov [eax+collection.type], ebx - mov [eax+collection.usage], edx - mov [cur_collection], eax - jmp .zero_local_items + mov [eax+collection.last_child], ecx + mov [eax+collection.type], ebx + mov [eax+collection.usage], edx + mov [cur_collection], eax + jmp .zero_local_items ; Close the current collection. .end_collection: ; There must be an opened collection. - mov eax, [cur_collection] - test eax, eax - jz .invalid_report + mov eax, [cur_collection] + test eax, eax + jz .invalid_report ; Make parent collection the current one. - mov edx, [eax+collection.parent] - mov [cur_collection], edx + mov edx, [eax+collection.parent] + mov [cur_collection], edx ; Add field range of the closing collection to field range for nesting collection, ; if there is one. - test edx, edx - jz .zero_local_items - push 3 ; for each type: input, output, feature + test edx, edx + jz .zero_local_items + push 3 ; for each type: input, output, feature .update_ranges: - mov ecx, [eax+collection.input.last_report] - test ecx, ecx - jz .no_fields - mov [edx+collection.input.last_report], ecx - mov ecx, [eax+collection.input.last_field] - mov [edx+collection.input.last_field], ecx - cmp [edx+collection.input.first_report], 0 - jnz .no_fields - mov ecx, [eax+collection.input.first_report] - mov [edx+collection.input.first_report], ecx - mov ecx, [eax+collection.input.first_field] - mov [edx+collection.input.first_field], ecx + mov ecx, [eax+collection.input.last_report] + test ecx, ecx + jz .no_fields + mov [edx+collection.input.last_report], ecx + mov ecx, [eax+collection.input.last_field] + mov [edx+collection.input.last_field], ecx + cmp [edx+collection.input.first_report], 0 + jnz .no_fields + mov ecx, [eax+collection.input.first_report] + mov [edx+collection.input.first_report], ecx + mov ecx, [eax+collection.input.first_field] + mov [edx+collection.input.first_field], ecx .no_fields: - add eax, sizeof.collection_report_set - add edx, sizeof.collection_report_set - dec dword [esp] - jnz .update_ranges - pop eax - jmp .zero_local_items + add eax, sizeof.collection_report_set + add edx, sizeof.collection_report_set + dec dword [esp] + jnz .update_ranges + pop eax + jmp .zero_local_items ; ------------------------------- Global items -------------------------------- .parse_global: - cmp eax, .num_global_items - jae .item_parsed - jmp dword [.global_jumps+eax*4] + cmp eax, .num_global_items + jae .item_parsed + jmp dword [.global_jumps+eax*4] ; For most global items, just store the value in the current global_items structure. ; Note 1: Usage Page will be used for upper word of Usage[| Minimum|Maximum], so ; shift it in advance. @@ -770,210 +770,210 @@ end if ; Note 3: zero value for Report ID is forbidden by the HID specification. ; It is quite convenient, we use report_id == 0 for reports without ID. .usage_page: - shl ebx, 16 - mov [edi+global_items.usage_page], ebx - jmp .item_parsed + shl ebx, 16 + mov [edi+global_items.usage_page], ebx + jmp .item_parsed .logical_minimum: - mov [edi+global_items.logical_minimum], ecx - jmp .item_parsed + mov [edi+global_items.logical_minimum], ecx + jmp .item_parsed .logical_maximum: - cmp [edi+global_items.logical_minimum], 0 - jge @f - mov ebx, ecx + cmp [edi+global_items.logical_minimum], 0 + jge @f + mov ebx, ecx @@: - mov [edi+global_items.logical_maximum], ebx - jmp .item_parsed + mov [edi+global_items.logical_maximum], ebx + jmp .item_parsed .physical_minimum: - mov [edi+global_items.physical_minimum], ecx - jmp .item_parsed + mov [edi+global_items.physical_minimum], ecx + jmp .item_parsed .physical_maximum: - cmp [edi+global_items.physical_maximum], 0 - jge @f - mov ebx, ecx + cmp [edi+global_items.physical_maximum], 0 + jge @f + mov ebx, ecx @@: - mov [edi+global_items.physical_maximum], ebx - jmp .item_parsed + mov [edi+global_items.physical_maximum], ebx + jmp .item_parsed .unit_exponent: - mov [edi+global_items.unit_exponent], ecx - jmp .item_parsed + mov [edi+global_items.unit_exponent], ecx + jmp .item_parsed .unit: - mov [edi+global_items.unit], ebx - jmp .item_parsed + mov [edi+global_items.unit], ebx + jmp .item_parsed .report_size: - mov [edi+global_items.report_size], ebx - jmp .item_parsed + mov [edi+global_items.report_size], ebx + jmp .item_parsed .report_id: - test ebx, ebx - jz .invalid_report - cmp ebx, 0x100 - jae .invalid_report - mov [edi+global_items.report_id], ebx - jmp .item_parsed + test ebx, ebx + jz .invalid_report + cmp ebx, 0x100 + jae .invalid_report + mov [edi+global_items.report_id], ebx + jmp .item_parsed .report_count: - mov [edi+global_items.report_count], ebx - jmp .item_parsed + mov [edi+global_items.report_count], ebx + jmp .item_parsed ; Two special global items: Push/Pop. .push: ; For Push, allocate new global_items structure, ; initialize from the current one and make it current. - movi eax, sizeof.global_items - call Kmalloc - test eax, eax - jz .memory_error - push esi eax - movi ecx, sizeof.global_items / 4 - mov esi, edi - xchg eax, edi - rep movsd - pop edi esi - mov [edi+global_items.next], eax - jmp .item_parsed + movi eax, sizeof.global_items + call Kmalloc + test eax, eax + jz .memory_error + push esi eax + movi ecx, sizeof.global_items / 4 + mov esi, edi + xchg eax, edi + rep movsd + pop edi esi + mov [edi+global_items.next], eax + jmp .item_parsed .pop: ; For Pop, restore the last global_items structure and free the current one. - mov eax, [edi+global_items.next] - test eax, eax - jz .invalid_report - push eax - xchg eax, edi - call Kfree - pop edi - jmp .item_parsed + mov eax, [edi+global_items.next] + test eax, eax + jz .invalid_report + push eax + xchg eax, edi + call Kfree + pop edi + jmp .item_parsed ; -------------------------------- Local items -------------------------------- .parse_local: - cmp eax, .num_local_items - jae .item_parsed - jmp dword [.local_jumps+eax*4] + cmp eax, .num_local_items + jae .item_parsed + jmp dword [.local_jumps+eax*4] .usage: ; Usage tag. ; If length is 0, 1, 2 bytes, append the global item Usage Page. - cmp [cur_item_size], 2 - ja @f - or ebx, [edi+global_items.usage_page] + cmp [cur_item_size], 2 + ja @f + or ebx, [edi+global_items.usage_page] @@: ; If inside Delimiter(), ignore everything except the first tag. - cmp [delimiter_depth], 0 - jz .usage.write - inc [usage_variant] - cmp [usage_variant], 1 - jnz .item_parsed + cmp [delimiter_depth], 0 + jz .usage.write + inc [usage_variant] + cmp [usage_variant], 1 + jnz .item_parsed .usage.write: ; Add new range with start = item data and length = 1. - mov [usage_minimum], ebx - push 1 + mov [usage_minimum], ebx + push 1 .new_usage: - movi eax, sizeof.usage_list_item - call Kmalloc - pop edx - test eax, eax - jz .memory_error - inc [num_usage_ranges] - mov ecx, [usage_minimum] - and [eax+usage_list_item.next], 0 - mov [eax+usage_list_item.first_usage], ecx - mov [eax+usage_list_item.num_usages], edx - mov ecx, [usage_tail] - mov [usage_tail], eax - mov [ecx], eax - jmp .item_parsed + movi eax, sizeof.usage_list_item + call Kmalloc + pop edx + test eax, eax + jz .memory_error + inc [num_usage_ranges] + mov ecx, [usage_minimum] + and [eax+usage_list_item.next], 0 + mov [eax+usage_list_item.first_usage], ecx + mov [eax+usage_list_item.num_usages], edx + mov ecx, [usage_tail] + mov [usage_tail], eax + mov [ecx], eax + jmp .item_parsed .usage_minimum: ; Usage Minimum tag. Just store in the local var. ; If length is 0, 1, 2 bytes, append the global item Usage Page. - cmp [cur_item_size], 2 - ja @f - or ebx, [edi+global_items.usage_page] + cmp [cur_item_size], 2 + ja @f + or ebx, [edi+global_items.usage_page] @@: - mov [usage_minimum], ebx - jmp .item_parsed + mov [usage_minimum], ebx + jmp .item_parsed .usage_maximum: ; Usage Maximum tag. ; If length is 0, 1, 2 bytes, append the global item Usage Page. - cmp [cur_item_size], 2 - ja @f - or ebx, [edi+global_items.usage_page] + cmp [cur_item_size], 2 + ja @f + or ebx, [edi+global_items.usage_page] @@: ; Meaningless inside Delimiter(). - cmp [delimiter_depth], 0 - jnz .invalid_report + cmp [delimiter_depth], 0 + jnz .invalid_report ; Add new range with start = saved Usage Minimum and ; length = Usage Maximum - Usage Minimum + 1. - sub ebx, [usage_minimum] - inc ebx - push ebx - jmp .new_usage + sub ebx, [usage_minimum] + inc ebx + push ebx + jmp .new_usage .delimiter: ; Delimiter tag. - test ebx, ebx - jz .delimiter.close + test ebx, ebx + jz .delimiter.close ; Delimiter(Opened). ; Store that we are inside Delimiter(), ; say a warning that only preferred Usage will be used. - cmp [delimiter_depth], 0 - jnz .invalid_report - inc [delimiter_depth] - push esi - mov esi, delimiter_note - call SysMsgBoardStr - pop esi - jmp .item_parsed + cmp [delimiter_depth], 0 + jnz .invalid_report + inc [delimiter_depth] + push esi + mov esi, delimiter_note + call SysMsgBoardStr + pop esi + jmp .item_parsed .delimiter.close: ; Delimiter(Closed). ; Store that we are not inside Delimiter() anymore. - dec [delimiter_depth] - js .invalid_report - and [usage_variant], 0 - jmp .item_parsed + dec [delimiter_depth] + js .invalid_report + and [usage_variant], 0 + jmp .item_parsed .parse_reserved: ; Ignore reserved items, except that tag 0xFE means long item ; with first data byte = length of additional data, ; second data byte = long item tag. No long items are defined yet, ; so just skip them. - cmp eax, 0xF - jnz .item_parsed - cmp [cur_item_size], 2 - jnz .item_parsed - movzx ecx, bl - add esi, ecx - cmp esi, [length] - ja .invalid_report + cmp eax, 0xF + jnz .item_parsed + cmp [cur_item_size], 2 + jnz .item_parsed + movzx ecx, bl + add esi, ecx + cmp esi, [length] + ja .invalid_report .item_parsed: - cmp esi, [length] - jb .fetch_next_item + cmp esi, [length] + jb .fetch_next_item .parse_end: ;-------------------------------- End of parsing ------------------------------ ; If there are opened collections, it is invalid report. - cmp [cur_collection], 0 - jnz .invalid_report + cmp [cur_collection], 0 + jnz .invalid_report ; There must be at least one input field. - mov eax, [calldata] - add eax, hid_data.input.first_report - cmp [last_reports+0*4], eax - jz .invalid_report + mov eax, [calldata] + add eax, hid_data.input.first_report + cmp [last_reports+0*4], eax + jz .invalid_report ; Everything is ok. - inc [report_ok] - jmp .end + inc [report_ok] + jmp .end .memory_error: - mov esi, nomemory_msg + mov esi, nomemory_msg .end_str: - call SysMsgBoardStr + call SysMsgBoardStr .end: ; Free all global_items structures. - test edi, edi - jz @f - push [edi+global_items.next] - xchg eax, edi - call Kfree - pop edi - jmp .end + test edi, edi + jz @f + push [edi+global_items.next] + xchg eax, edi + call Kfree + pop edi + jmp .end @@: ; Free the last Usage list, if any. - mov eax, [usage_list] + mov eax, [usage_list] @@: - test eax, eax - jz @f - push [eax+usage_list_item.next] - call Kfree - pop eax - jmp @b + test eax, eax + jz @f + push [eax+usage_list_item.next] + call Kfree + pop eax + jmp @b @@: } @@ -989,83 +989,83 @@ postprocess_report_label: ; and Usage(GenericDesktop:Keypad) ; 1. Prepare for the loop: get the pointer to the first collection, ; store that no drivers were assigned yet. - mov edi, [ebx+hid_data.first_collection] + mov edi, [ebx+hid_data.first_collection] if ~HID_DUMP_UNCLAIMED - mov [has_driver], 0 + mov [has_driver], 0 end if .next_collection: ; 2. Test whether there is a collection to test; if no, break from the loop. - test edi, edi - jz .postprocess_done + test edi, edi + jz .postprocess_done ; 3. Get pointer to driver callbacks depending on [collection.usage]. ; If [collection.usage] is unknown, use default driver if HID_DUMP_UNCLAIMED ; and do not assign a driver otherwise. - mov esi, mouse_driver - cmp [edi+collection.usage], USAGE_GD_MOUSE - jz .has_driver - mov esi, keyboard_driver - cmp [edi+collection.usage], USAGE_GD_KEYBOARD - jz .has_driver - cmp [edi+collection.usage], USAGE_GD_KEYPAD - jz .has_driver + mov esi, mouse_driver + cmp [edi+collection.usage], USAGE_GD_MOUSE + jz .has_driver + mov esi, keyboard_driver + cmp [edi+collection.usage], USAGE_GD_KEYBOARD + jz .has_driver + cmp [edi+collection.usage], USAGE_GD_KEYPAD + jz .has_driver if HID_DUMP_UNCLAIMED - mov esi, default_driver + mov esi, default_driver else - xor esi, esi + xor esi, esi end if ; 4. If no driver is assigned (possible only if not HID_DUMP_UNCLAIMED), ; go to 7 with driver data = 0; ; other code uses this as a sign that driver callbacks should not be called. .has_driver: - xor eax, eax + xor eax, eax if ~HID_DUMP_UNCLAIMED - test esi, esi - jz .set_driver + test esi, esi + jz .set_driver end if ; 5. Notify the driver about new device. - call [esi+hid_driver_callbacks.add_device] + call [esi+hid_driver_callbacks.add_device] ; 6. If the driver has returned non-zero driver data, ; store that is an assigned driver. ; Otherwise, if HID_DUMP_UNCLAIMED, try to assign the default driver. if HID_DUMP_UNCLAIMED - test eax, eax - jnz .set_driver - mov esi, default_driver - call [esi+hid_driver_callbacks.add_device] + test eax, eax + jnz .set_driver + mov esi, default_driver + call [esi+hid_driver_callbacks.add_device] else - test eax, eax - jz @f - mov [has_driver], 1 - jmp .set_driver + test eax, eax + jz @f + mov [has_driver], 1 + jmp .set_driver @@: - xor esi, esi + xor esi, esi end if .set_driver: ; 7. Store driver data. If a driver is assigned, copy driver callbacks. - mov [edi+collection.driver_data], eax - test esi, esi - jz @f - push edi - lodsd ; skip hid_driver_callbacks.add_device - add edi, collection.callbacks + mov [edi+collection.driver_data], eax + test esi, esi + jz @f + push edi + lodsd ; skip hid_driver_callbacks.add_device + add edi, collection.callbacks repeat sizeof.hid_driver_active_callbacks / 4 - movsd + movsd end repeat - pop edi + pop edi @@: ; 8. Store pointer to the collection in all input reports belonging to it. ; Note that the HID spec requires that reports should not cross top-level collections. - mov eax, [edi+collection.input.first_report] - test eax, eax - jz .reports_processed + mov eax, [edi+collection.input.first_report] + test eax, eax + jz .reports_processed .next_report: - mov [eax+report.top_level_collection], edi - cmp eax, [edi+collection.input.last_report] - mov eax, [eax+report.next] - jnz .next_report + mov [eax+report.top_level_collection], edi + cmp eax, [edi+collection.input.last_report] + mov eax, [eax+report.next] + jnz .next_report .reports_processed: - mov edi, [edi+collection.next] - jmp .next_collection + mov edi, [edi+collection.next] + jmp .next_collection .postprocess_done: } @@ -1077,81 +1077,81 @@ macro hid_cleanup ; 1. Notify all assigned drivers about disconnect. ; Loop over all top-level collections and call callbacks.disconnect, ; if a driver is assigned. - mov esi, [ebx+hid_data.first_collection] + mov esi, [ebx+hid_data.first_collection] .notify_drivers: - test esi, esi - jz .notify_drivers_done - mov edi, [esi+collection.driver_data] - test edi, edi - jz @f - call [esi+collection.callbacks.disconnect] + test esi, esi + jz .notify_drivers_done + mov edi, [esi+collection.driver_data] + test edi, edi + jz @f + call [esi+collection.callbacks.disconnect] @@: - mov esi, [esi+collection.next] - jmp .notify_drivers + mov esi, [esi+collection.next] + jmp .notify_drivers .notify_drivers_done: ; 2. Free all collections. - mov esi, [ebx+hid_data.first_collection] + mov esi, [ebx+hid_data.first_collection] .free_collections: - test esi, esi - jz .collections_done + test esi, esi + jz .collections_done ; If a collection has childen, make it forget about them, ; kill all children; after last child is killed, return to ; the collection as a parent; this time, it will appear ; as childless, so it will be killed after children. - mov eax, [esi+collection.first_child] - test eax, eax - jz .no_children - and [esi+collection.first_child], 0 - xchg esi, eax - jmp .free_collections + mov eax, [esi+collection.first_child] + test eax, eax + jz .no_children + and [esi+collection.first_child], 0 + xchg esi, eax + jmp .free_collections .no_children: ; If a collection has no children (maybe there were no children at all, ; maybe all children were already killed), kill it and proceed either to ; next sibling (if any) or to the parent. - mov eax, [esi+collection.next] - test eax, eax - jnz @f - mov eax, [esi+collection.parent] + mov eax, [esi+collection.next] + test eax, eax + jnz @f + mov eax, [esi+collection.parent] @@: - xchg eax, esi - call Kfree - jmp .free_collections + xchg eax, esi + call Kfree + jmp .free_collections .collections_done: ; 3. Free all three report sets. - push 3 - lea esi, [ebx+hid_data.input] + push 3 + lea esi, [ebx+hid_data.input] ; For every report set, loop over all reports, ; for every report free all field groups, then free report itself. ; When all reports in one set have been freed, free also report list table, ; if there is one (reports are numbered). .report_set_loop: - mov edi, [esi+report_set.first_report] + mov edi, [esi+report_set.first_report] .report_loop: - test edi, edi - jz .report_done - mov eax, [edi+report.first_field] + test edi, edi + jz .report_done + mov eax, [edi+report.first_field] .field_loop: - test eax, eax - jz .field_done - push [eax+report_field_group.next] - call Kfree - pop eax - jmp .field_loop + test eax, eax + jz .field_done + push [eax+report_field_group.next] + call Kfree + pop eax + jmp .field_loop .field_done: - mov eax, [edi+report.next] - xchg eax, edi - call Kfree - jmp .report_loop + mov eax, [edi+report.next] + xchg eax, edi + call Kfree + jmp .report_loop .report_done: - cmp [esi+report_set.numbered], 0 - jz @f - mov eax, [esi+report_set.data] - call Kfree + cmp [esi+report_set.numbered], 0 + jz @f + mov eax, [esi+report_set.data] + call Kfree @@: - add esi, sizeof.report_set - dec dword [esp] - jnz .report_set_loop - pop eax + add esi, sizeof.report_set + dec dword [esp] + jnz .report_set_loop + pop eax } ; Helper for parse_input. Extracts value of one field. @@ -1162,44 +1162,44 @@ macro hid_cleanup ; Note: it can read one dword past report data. macro extract_field_value report { - mov ecx, eax - shr eax, 5 - shl eax, 2 - add eax, report - and ecx, 31 - mov edx, [eax] - mov eax, [eax+4] - shrd edx, eax, cl - mov ecx, [esi+report_field_group.sign_mask] - and ecx, edx - and edx, [esi+report_field_group.mask] - sub edx, ecx + mov ecx, eax + shr eax, 5 + shl eax, 2 + add eax, report + and ecx, 31 + mov edx, [eax] + mov eax, [eax+4] + shrd edx, eax, cl + mov ecx, [esi+report_field_group.sign_mask] + and ecx, edx + and edx, [esi+report_field_group.mask] + sub edx, ecx } ; Local variables for parse_input. macro parse_input_locals { -count_inside_group dd ? +count_inside_group dd ? ; Number of fields left in the current field. -field_offset dd ? +field_offset dd ? ; Offset of the current field from report start, in bits. -field_range_size dd ? +field_range_size dd ? ; Size of range with valid values, Logical Maximum - Logical Minimum + 1. -cur_usage dd ? +cur_usage dd ? ; Pointer to current usage for Variable field groups. -num_values dd ? +num_values dd ? ; Number of values in the current instantiation of Array field group. -values_base dd ? +values_base dd ? ; Pointer to memory allocated for array with current values. -values_prev dd ? +values_prev dd ? ; Pointer to memory allocated for array with previous values. -values_cur_ptr dd ? +values_cur_ptr dd ? ; Pointer to the next value in [values_base] array. -values_end dd ? +values_end dd ? ; End of data in array with current values. -values_prev_ptr dd ? +values_prev_ptr dd ? ; Pointer to the next value in [values_prev_ptr] array. -values_prev_end dd ? +values_prev_end dd ? ; End of data in array with previous values. } @@ -1208,235 +1208,235 @@ values_prev_end dd ? macro parse_input { ; 1. Ignore the report if there is no driver for it. - mov ebx, [esi+report.top_level_collection] - mov edi, [ebx+collection.driver_data] - test edi, edi - jz .done + mov ebx, [esi+report.top_level_collection] + mov edi, [ebx+collection.driver_data] + test edi, edi + jz .done ; 2. Notify the driver that a new packet arrived. - call [ebx+collection.callbacks.begin_packet] + call [ebx+collection.callbacks.begin_packet] ; Loop over all field groups. ; Report without fields is meaningless, but theoretically possible: ; parse_descr does not create reports of zero size, but ; a report can consist of "padding" fields without usages and have ; no real fields. - mov esi, [esi+report.first_field] - test esi, esi - jz .packet_processed + mov esi, [esi+report.first_field] + test esi, esi + jz .packet_processed .field_loop: ; 3. Prepare for group handling: initialize field offset, fields count ; and size of range for valid values. - mov eax, [esi+report_field_group.offset] - mov [field_offset], eax - mov ecx, [esi+report_field_group.count] - mov [count_inside_group], ecx - mov eax, [esi+report_field_group.logical_maximum] - inc eax - sub eax, [esi+report_field_group.logical_minimum] - mov [field_range_size], eax + mov eax, [esi+report_field_group.offset] + mov [field_offset], eax + mov ecx, [esi+report_field_group.count] + mov [count_inside_group], ecx + mov eax, [esi+report_field_group.logical_maximum] + inc eax + sub eax, [esi+report_field_group.logical_minimum] + mov [field_range_size], eax ; 4. Select handler. Variable and Array groups are handled entirely differently; ; for Variable groups, advance to 5, for Array groups, go to 6. - test byte [esi+report_field_group.flags], HID_FIELD_VARIABLE - jz .array_field + test byte [esi+report_field_group.flags], HID_FIELD_VARIABLE + jz .array_field ; 5. Variable groups. They are simple. Loop over all .count fields, ; for every field extract the value and get the next usage, ; if the value is within valid range, call the driver. - lea eax, [esi+report_field_group.common_sizeof] - mov [cur_usage], eax + lea eax, [esi+report_field_group.common_sizeof] + mov [cur_usage], eax .variable_data_loop: - mov eax, [field_offset] - extract_field_value [buffer] ; -> edx - mov ecx, [cur_usage] - mov ecx, [ecx] - call [ebx+collection.callbacks.input_field] - add [cur_usage], 4 - mov eax, [esi+report_field_group.size] - add [field_offset], eax - dec [count_inside_group] - jnz .variable_data_loop + mov eax, [field_offset] + extract_field_value [buffer] ; -> edx + mov ecx, [cur_usage] + mov ecx, [ecx] + call [ebx+collection.callbacks.input_field] + add [cur_usage], 4 + mov eax, [esi+report_field_group.size] + add [field_offset], eax + dec [count_inside_group] + jnz .variable_data_loop ; Variable group is processed; go to 12. - jmp .field_done + jmp .field_done .array_field: ; Array groups. They are complicated. ; 6. Array group: extract all values in one array. ; memory was allocated during group creation, use it ; 6a. Prepare: get data pointer, initialize num_values with zero. - mov eax, [esi+report_field_group.num_usage_ranges] - lea edx, [esi+report_field_group.usages+eax*sizeof.usage_range+4] - mov eax, [esi+report_field_group.count] - mov [values_cur_ptr], edx - mov [values_base], edx - lea edx, [edx+ecx*4] - mov [values_prev], edx - mov [values_prev_ptr], edx - mov [num_values], 0 + mov eax, [esi+report_field_group.num_usage_ranges] + lea edx, [esi+report_field_group.usages+eax*sizeof.usage_range+4] + mov eax, [esi+report_field_group.count] + mov [values_cur_ptr], edx + mov [values_base], edx + lea edx, [edx+ecx*4] + mov [values_prev], edx + mov [values_prev_ptr], edx + mov [num_values], 0 ; 6b. Start loop for every field. Note that there must be at least one field, ; parse_descr does not allow .count == 0. .array_getval_loop: ; 6c. Extract the value of the current field. - mov eax, [field_offset] - extract_field_value [buffer] ; -> edx + mov eax, [field_offset] + extract_field_value [buffer] ; -> edx ; 6d. Transform the value to the usage with binary search in array of ; usage_ranges. started at [esi+report_field_group.usages] ; having [esi+report_field_group.num_usage_ranges] items. ; Ignore items outside of valid range. - sub edx, [esi+report_field_group.logical_minimum] - cmp edx, [field_range_size] - jae .array_skip_item + sub edx, [esi+report_field_group.logical_minimum] + cmp edx, [field_range_size] + jae .array_skip_item ; If there are too few usages, use last of them. - mov ecx, [esi+report_field_group.num_usage_ranges] ; upper bound - xor eax, eax ; lower bound - cmp edx, [esi+report_field_group.usages+ecx*sizeof.usage_range+usage_range.offset] - jae .array_last_usage + mov ecx, [esi+report_field_group.num_usage_ranges] ; upper bound + xor eax, eax ; lower bound + cmp edx, [esi+report_field_group.usages+ecx*sizeof.usage_range+usage_range.offset] + jae .array_last_usage ; loop invariant: usages[eax].offset <= edx < usages[ecx].offset .array_find_usage: - lea edi, [eax+ecx] - shr edi, 1 - cmp edi, eax - jz .array_found_usage_range - cmp edx, [esi+report_field_group.usages+edi*sizeof.usage_range+usage_range.offset] - jae .update_low - mov ecx, edi - jmp .array_find_usage + lea edi, [eax+ecx] + shr edi, 1 + cmp edi, eax + jz .array_found_usage_range + cmp edx, [esi+report_field_group.usages+edi*sizeof.usage_range+usage_range.offset] + jae .update_low + mov ecx, edi + jmp .array_find_usage .update_low: - mov eax, edi - jmp .array_find_usage + mov eax, edi + jmp .array_find_usage .array_last_usage: - lea eax, [ecx-1] - mov edx, [esi+report_field_group.usages+ecx*sizeof.usage_range+usage_range.offset] - dec edx + lea eax, [ecx-1] + mov edx, [esi+report_field_group.usages+ecx*sizeof.usage_range+usage_range.offset] + dec edx .array_found_usage_range: - sub edx, [esi+report_field_group.usages+eax*sizeof.usage_range+usage_range.offset] - add edx, [esi+report_field_group.usages+eax*sizeof.usage_range+usage_range.first_usage] + sub edx, [esi+report_field_group.usages+eax*sizeof.usage_range+usage_range.offset] + add edx, [esi+report_field_group.usages+eax*sizeof.usage_range+usage_range.first_usage] ; 6e. Store the usage, advance data pointer, continue loop started at 6b. - mov eax, [values_cur_ptr] - mov [eax], edx - add [values_cur_ptr], 4 - inc [num_values] + mov eax, [values_cur_ptr] + mov [eax], edx + add [values_cur_ptr], 4 + inc [num_values] .array_skip_item: - mov eax, [esi+report_field_group.size] - add [field_offset], eax - dec [count_inside_group] - jnz .array_getval_loop + mov eax, [esi+report_field_group.size] + add [field_offset], eax + dec [count_inside_group] + jnz .array_getval_loop ; 7. Array group: ask driver about array overflow. ; If driver says that the array is invalid, stop processing this group ; (in particular, do not update previous values). - mov ecx, [num_values] - test ecx, ecx - jz .duplicates_removed - mov edx, [values_base] - mov edi, [ebx+collection.driver_data] - call [ebx+collection.callbacks.array_overflow?] - jnc .field_done + mov ecx, [num_values] + test ecx, ecx + jz .duplicates_removed + mov edx, [values_base] + mov edi, [ebx+collection.driver_data] + call [ebx+collection.callbacks.array_overflow?] + jnc .field_done ; 8. Array group: sort the array with current values. - push esi - mov ecx, [num_values] - mov edx, [values_base] - call sort - pop esi + push esi + mov ecx, [num_values] + mov edx, [values_base] + call sort + pop esi ; 9. Array group: remove duplicates. - cmp [num_values], 1 - jbe .duplicates_removed - mov eax, [values_base] - mov edx, [eax] - add eax, 4 - mov ecx, eax + cmp [num_values], 1 + jbe .duplicates_removed + mov eax, [values_base] + mov edx, [eax] + add eax, 4 + mov ecx, eax .duplicates_loop: - cmp edx, [eax] - jz @f - mov edx, [eax] - mov [ecx], edx - add ecx, 4 + cmp edx, [eax] + jz @f + mov edx, [eax] + mov [ecx], edx + add ecx, 4 @@: - add eax, 4 - cmp eax, [values_cur_ptr] - jb .duplicates_loop - mov [values_cur_ptr], ecx - sub ecx, [values_base] - shr ecx, 2 - mov [num_values], ecx + add eax, 4 + cmp eax, [values_cur_ptr] + jb .duplicates_loop + mov [values_cur_ptr], ecx + sub ecx, [values_base] + shr ecx, 2 + mov [num_values], ecx .duplicates_removed: ; 10. Array group: compare current and previous values, ; call driver for differences. - mov edi, [ebx+collection.driver_data] - mov eax, [values_cur_ptr] - mov [values_end], eax - mov eax, [values_base] - mov [values_cur_ptr], eax - mov eax, [esi+report_field_group.num_values_prev] - shl eax, 2 - add eax, [values_prev] - mov [values_prev_end], eax + mov edi, [ebx+collection.driver_data] + mov eax, [values_cur_ptr] + mov [values_end], eax + mov eax, [values_base] + mov [values_cur_ptr], eax + mov eax, [esi+report_field_group.num_values_prev] + shl eax, 2 + add eax, [values_prev] + mov [values_prev_end], eax .find_common: - mov eax, [values_cur_ptr] - cmp eax, [values_end] - jae .cur_done - mov ecx, [eax] - mov eax, [values_prev_ptr] - cmp eax, [values_prev_end] - jae .prev_done - mov edx, [eax] - cmp ecx, edx - jb .advance_cur - ja .advance_prev + mov eax, [values_cur_ptr] + cmp eax, [values_end] + jae .cur_done + mov ecx, [eax] + mov eax, [values_prev_ptr] + cmp eax, [values_prev_end] + jae .prev_done + mov edx, [eax] + cmp ecx, edx + jb .advance_cur + ja .advance_prev ; common item in both arrays; ignore - add [values_cur_ptr], 4 - add [values_prev_ptr], 4 - jmp .find_common + add [values_cur_ptr], 4 + add [values_prev_ptr], 4 + jmp .find_common .advance_cur: ; item is present in current array but not in previous; ; call the driver with value = 1 - add [values_cur_ptr], 4 - mov edx, 1 - call [ebx+collection.callbacks.input_field] - jmp .find_common + add [values_cur_ptr], 4 + mov edx, 1 + call [ebx+collection.callbacks.input_field] + jmp .find_common .advance_prev: ; item is present in previous array but not in current; ; call the driver with value = 0 - add [values_prev_ptr], 4 - mov ecx, edx - xor edx, edx - call [ebx+collection.callbacks.input_field] - jmp .find_common + add [values_prev_ptr], 4 + mov ecx, edx + xor edx, edx + call [ebx+collection.callbacks.input_field] + jmp .find_common .prev_done: ; for all items which are left in current array ; call the driver with value = 1 - mov eax, [values_cur_ptr] + mov eax, [values_cur_ptr] @@: - add [values_cur_ptr], 4 - mov ecx, [eax] - mov edx, 1 - call [ebx+collection.callbacks.input_field] - mov eax, [values_cur_ptr] - cmp eax, [values_end] - jb @b - jmp .copy_array + add [values_cur_ptr], 4 + mov ecx, [eax] + mov edx, 1 + call [ebx+collection.callbacks.input_field] + mov eax, [values_cur_ptr] + cmp eax, [values_end] + jb @b + jmp .copy_array .cur_done: ; for all items which are left in previous array ; call the driver with value = 0 - mov eax, [values_prev_ptr] - add [values_prev_ptr], 4 - cmp eax, [values_prev_end] - jae @f - mov ecx, [eax] - xor edx, edx - call [ebx+collection.callbacks.input_field] - jmp .cur_done + mov eax, [values_prev_ptr] + add [values_prev_ptr], 4 + cmp eax, [values_prev_end] + jae @f + mov ecx, [eax] + xor edx, edx + call [ebx+collection.callbacks.input_field] + jmp .cur_done @@: .copy_array: ; 11. Array group: copy current values to previous values. - push esi edi - mov ecx, [num_values] - mov [esi+report_field_group.num_values_prev], ecx - mov esi, [values_base] - mov edi, [values_prev] - rep movsd - pop edi esi + push esi edi + mov ecx, [num_values] + mov [esi+report_field_group.num_values_prev], ecx + mov esi, [values_base] + mov edi, [values_prev] + rep movsd + pop edi esi ; 12. Field group is processed. Repeat with the next group, if any. .field_done: - mov esi, [esi+report_field_group.next] - test esi, esi - jnz .field_loop + mov esi, [esi+report_field_group.next] + test esi, esi + jnz .field_loop .packet_processed: ; 13. Packet is processed, notify the driver. - call [ebx+collection.callbacks.end_packet] + call [ebx+collection.callbacks.end_packet] } diff --git a/kernel/trunk/drivers/usbhid/sort.inc b/kernel/trunk/drivers/usbhid/sort.inc index 3112e01954..07fcbb3ea3 100644 --- a/kernel/trunk/drivers/usbhid/sort.inc +++ b/kernel/trunk/drivers/usbhid/sort.inc @@ -2,8 +2,8 @@ ; ecx = array size, edx = array pointer. ; Destroys eax, ecx, esi, edi. sort: - test ecx, ecx - jz .done + test ecx, ecx + jz .done mov eax, ecx @@: push eax @@ -38,18 +38,18 @@ sort: cmp esi, ecx ja .doner mov edi, [edx+eax*4-4] - cmp [edx+esi*4-4], edi + cmp [edx+esi*4-4], edi ja .need_xchg cmp esi, ecx jae .doner mov edi, [edx+eax*4-4] - cmp [edx+esi*4], edi + cmp [edx+esi*4], edi jbe .doner .need_xchg: cmp esi, ecx jz .do_xchg mov edi, [edx+esi*4-4] - cmp [edx+esi*4], edi + cmp [edx+esi*4], edi sbb esi, -1 .do_xchg: mov edi, eax diff --git a/kernel/trunk/drivers/usbhid/unclaimed.inc b/kernel/trunk/drivers/usbhid/unclaimed.inc index 6f69e9c2f5..f89d4e4953 100644 --- a/kernel/trunk/drivers/usbhid/unclaimed.inc +++ b/kernel/trunk/drivers/usbhid/unclaimed.inc @@ -11,25 +11,25 @@ if HID_DUMP_UNCLAIMED macro workers_globals { ; include global constants from previous workers - workers_globals + workers_globals align 4 ; Callbacks for HID layer. default_driver: - dd default_driver_add_device - dd default_driver_disconnect - dd default_driver_begin_packet - dd default_driver_array_overflow? - dd default_driver_input_field - dd default_driver_end_packet + dd default_driver_add_device + dd default_driver_disconnect + dd default_driver_begin_packet + dd default_driver_array_overflow? + dd default_driver_input_field + dd default_driver_end_packet } ; This procedure is called when HID layer detects a new driverless device. ; in: ebx -> usb_device_data, edi -> collection ; out: eax = device-specific data or NULL on error default_driver_add_device: ; just return something nonzero, no matter what - xor eax, eax - inc eax - ret + xor eax, eax + inc eax + ret ; This procedure is called when HID layer processes every non-empty array field group. ; in: edi -> keyboard_device_data (pointer returned from keyboard_driver_add_device) ; in: ecx = fields count (always nonzero), edx = pointer to fields values @@ -37,24 +37,24 @@ default_driver_add_device: ; out: CF set => group is ok, CF cleared => group should be ignored default_driver_array_overflow?: ; parse everything - stc - ret + stc + ret ; This procedure is called from HID layer for every field. ; in: ecx = field usage, edx = value, esi -> report_field_group default_driver_input_field: ; Do not dump zero values in Variable fields, ; they are present even if the corresponding control is inactive. - test edx, edx - jnz @f - test byte [esi+report_field_group.flags], HID_FIELD_VARIABLE - jnz .nodump + test edx, edx + jnz @f + test byte [esi+report_field_group.flags], HID_FIELD_VARIABLE + jnz .nodump @@: - DEBUGF 1,'K : unclaimed HID input: usage=%x, value=%x\n',ecx,edx + DEBUGF 1,'K : unclaimed HID input: usage=%x, value=%x\n',ecx,edx .nodump: ; pass through ; Three nothing-to-do procedures. default_driver_disconnect: default_driver_begin_packet: default_driver_end_packet: - ret + ret end if diff --git a/kernel/trunk/fs/ext2.inc b/kernel/trunk/fs/ext2.inc index 3649e3453f..bced74315c 100644 --- a/kernel/trunk/fs/ext2.inc +++ b/kernel/trunk/fs/ext2.inc @@ -41,8 +41,8 @@ EXT4_FEATURE_INCOMPAT_FLEX_BG = 0x0200 ;RUS: гибкие группы блок ;RUS: реализованные ext[234] features ;ENG: implemented ext[234] features EXT4_FEATURE_INCOMPAT_SUPP = EXT2_FEATURE_INCOMPAT_FILETYPE \ - or EXT4_FEATURE_INCOMPAT_EXTENTS \ - or EXT4_FEATURE_INCOMPAT_FLEX_BG + or EXT4_FEATURE_INCOMPAT_EXTENTS \ + or EXT4_FEATURE_INCOMPAT_FLEX_BG ;RUS: флаги, указываемые для inode в i_flags ;ENG: flags specified for inode in i_flags EXT2_EXTENTS_FL = 0x00080000 @@ -500,7 +500,7 @@ ext2_get_inode: mov ebx, [ext2_data.ext2_temp_block] call ext2_get_block test eax, eax - jnz .fail + jnz .fail add ebx, edx ;RUS: локальный номер в блоке ;ENG: local number inside block mov eax, [ebx + EXT2_BLOCK_GROUP_DESC.inode_table] ;RUS: номер блока - в терминах ext2 @@ -1004,7 +1004,7 @@ ext2_HdRead: test eax, eax jnz .error_at_finish_block - mov ecx, edx + mov ecx, edx mov esi, ebx rep movsb ;кусок last блока jmp @F @@ -1031,7 +1031,7 @@ ext2_HdRead: .error_at_first_block: pop edx .error_at_read_cycle: - pop ebx + pop ebx .error_at_finish_block: pop ecx edx or ebx, -1 diff --git a/kernel/trunk/fs/fs_lfn.inc b/kernel/trunk/fs/fs_lfn.inc index 7f071fe929..ea90b0e3e2 100644 --- a/kernel/trunk/fs/fs_lfn.inc +++ b/kernel/trunk/fs/fs_lfn.inc @@ -525,29 +525,29 @@ fs_NumFloppyServices = ($ - fs_FloppyServices)/4 fs_OnHd0: call reserve_hd1 - mov eax,[hd_address_table] - mov [hdbase], eax ;0x1F0 + mov eax, [hd_address_table] + mov [hdbase], eax ;0x1F0 mov [hdid], 0 push 1 jmp fs_OnHd fs_OnHd1: call reserve_hd1 - mov eax,[hd_address_table] - mov [hdbase], eax ;0x1F0 + mov eax, [hd_address_table] + mov [hdbase], eax ;0x1F0 mov [hdid], 0x10 push 2 jmp fs_OnHd fs_OnHd2: call reserve_hd1 - mov eax,[hd_address_table+16] - mov [hdbase], eax ;0x170 + mov eax, [hd_address_table+16] + mov [hdbase], eax ;0x170 mov [hdid], 0 push 3 jmp fs_OnHd fs_OnHd3: call reserve_hd1 - mov eax,[hd_address_table+16] - mov [hdbase], eax ;0x170 + mov eax, [hd_address_table+16] + mov [hdbase], eax ;0x170 mov [hdid], 0x10 push 4 fs_OnHd: @@ -948,7 +948,7 @@ process_replace_file_name: mov ebp, [full_file_name_table] xor edi, edi .loop: - cmp edi,[full_file_name_table.size] + cmp edi, [full_file_name_table.size] jae .notfound push esi edi shl edi, 7 ; edi*128 @@ -1021,17 +1021,17 @@ sys_current_directory: mov edi, sysdir_name1 ; copying fake directory name mov ecx, 63 - pushfd - cli + pushfd + cli cld - rep movsb + rep movsb ; terminator of name, in case if we get the inlet trash inc esi xor eax, eax stosb ; copying real directory path for mounting mov ecx, 63 - rep movsb + rep movsb ; terminator of name, in case if we get the inlet trash xor eax, eax stosb @@ -1040,7 +1040,7 @@ sys_current_directory: ; block the ability to call f.30.3 because for one session is necessary ; for us only once mov [lock_flag_for_f30_3], 1 - popfd + popfd @@: ret diff --git a/kernel/trunk/gui/skincode.inc b/kernel/trunk/gui/skincode.inc index e6fe5d652c..6c3c1587ee 100644 --- a/kernel/trunk/gui/skincode.inc +++ b/kernel/trunk/gui/skincode.inc @@ -23,7 +23,7 @@ read_skin_file: xchg eax, [skin_data] test eax, eax - jz @f + jz @f stdcall kernel_free, eax @@: diff --git a/kernel/trunk/network/ARP.inc b/kernel/trunk/network/ARP.inc index 211134258d..6b126f3093 100644 --- a/kernel/trunk/network/ARP.inc +++ b/kernel/trunk/network/ARP.inc @@ -82,7 +82,7 @@ macro ARP_init { xor eax, eax mov edi, ARP_entries_num mov ecx, 4*NET_DEVICES_MAX - rep stosd + rep stosd } @@ -408,7 +408,7 @@ ARP_add_entry: .add: push ecx mov ecx, sizeof.ARP_entry/2 - rep movsw + rep movsw pop ecx lea esi, [edi - sizeof.ARP_entry] pop edi @@ -450,12 +450,12 @@ ARP_del_entry: ; move all trailing entries, sizeof.ARP_entry bytes to left. mov edi, esi add esi, sizeof.ARP_entry - rep movsw + rep movsw ; now add an empty entry to the end (erasing previous one) xor eax, eax mov ecx, sizeof.ARP_entry/2 - rep stosw + rep stosw pop edi dec [ARP_entries_num + 4*edi] @@ -646,7 +646,7 @@ ARP_api: imul ecx, sizeof.ARP_entry lea esi, [eax + ecx] mov ecx, sizeof.ARP_entry/2 - rep movsw + rep movsw xor eax, eax ret diff --git a/kernel/trunk/network/IPv4.inc b/kernel/trunk/network/IPv4.inc index f1f357d180..b827ad29cc 100644 --- a/kernel/trunk/network/IPv4.inc +++ b/kernel/trunk/network/IPv4.inc @@ -85,7 +85,7 @@ macro IPv4_init { xor eax, eax mov edi, IP_LIST mov ecx, 7*NET_DEVICES_MAX + (sizeof.FRAGMENT_slot*MAX_FRAGMENTS)/4 - rep stosd + rep stosd } @@ -476,10 +476,10 @@ IPv4_input: ; TODO: add IPv4 push cx ; First copy dword-wise, then byte-wise shr cx, 2 ; - rep movsd ; + rep movsd ; pop cx ; and cx, 3 ; - rep movsb ; + rep movsb ; push eax push edx ; Push pointer to fragment onto stack @@ -696,7 +696,7 @@ IPv4_output_raw: ;; todo: check socket options if we should add header, or just compute checksum push edi ecx - rep movsb + rep movsb pop ecx edi ; [edi + IPv4_header.VersionAndIHL] ; IPv4, normal length (no Optional header) @@ -786,7 +786,7 @@ IPv4_fragment: ; copy header mov esi, [esp + 2*4] mov ecx, 5 ; 5 dwords: TODO: use IHL field of the header! - rep movsd + rep movsd ; copy data mov esi, [esp + 2*4] @@ -795,7 +795,7 @@ IPv4_fragment: mov ecx, [esp + 1*4] DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_fragment: copying %u bytes\n", ecx - rep movsb + rep movsb ; now, correct header mov ecx, [esp + 1*4] @@ -823,7 +823,7 @@ IPv4_fragment: call [ebx + NET_DEVICE.transmit] ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - mov ecx, [esp+4] + mov ecx, [esp+4] add [esp], ecx mov ecx, [esp+3*4+6+4] ; ptr to begin of buff diff --git a/kernel/trunk/network/IPv6.inc b/kernel/trunk/network/IPv6.inc index 6eedd10a4f..0e22dffe98 100644 --- a/kernel/trunk/network/IPv6.inc +++ b/kernel/trunk/network/IPv6.inc @@ -57,7 +57,7 @@ macro IPv6_init { xor eax, eax mov edi, IPv6 mov ecx, (4*4*4+2*4)MAX_IP - rep stosd + rep stosd } diff --git a/kernel/trunk/network/PPPoE.inc b/kernel/trunk/network/PPPoE.inc index 4b00890936..a552e03b3e 100644 --- a/kernel/trunk/network/PPPoE.inc +++ b/kernel/trunk/network/PPPoE.inc @@ -152,7 +152,7 @@ PPPoE_discovery_output: mov edx, ecx mov edi, eax - rep movsb + rep movsb cmp edx, 60 ; Min ETH size ja @f diff --git a/kernel/trunk/network/icmp.inc b/kernel/trunk/network/icmp.inc index 06eb5a75d1..a9080903a1 100644 --- a/kernel/trunk/network/icmp.inc +++ b/kernel/trunk/network/icmp.inc @@ -118,7 +118,7 @@ macro ICMP_init { xor eax, eax mov edi, ICMP_PACKETS_TX mov ecx, 2*NET_DEVICES_MAX - rep stosd + rep stosd } @@ -355,10 +355,10 @@ ICMP_output: add edi, sizeof.ICMP_header push cx shr cx, 2 - rep movsd + rep movsd pop cx and cx, 3 - rep movsb + rep movsb sub edi, edx ;;; TODO: find a better way to remember start of packet push edx edi @@ -406,7 +406,7 @@ ICMP_output_raw: push edi ecx DEBUGF DEBUG_NETWORK_VERBOSE, "copying %u bytes from %x to %x\n", ecx, esi, edi - rep movsb + rep movsb pop ecx edi mov [edi + ICMP_header.Checksum], 0 diff --git a/kernel/trunk/network/loopback.inc b/kernel/trunk/network/loopback.inc index 6c788ff972..9de8934af5 100644 --- a/kernel/trunk/network/loopback.inc +++ b/kernel/trunk/network/loopback.inc @@ -40,7 +40,7 @@ LOOPBACK_DEVICE: .namestr db 'loopback', 0 .dummy_fn: - ret + ret endg diff --git a/kernel/trunk/network/queue.inc b/kernel/trunk/network/queue.inc index 41ce1a3b23..d8b79ea544 100644 --- a/kernel/trunk/network/queue.inc +++ b/kernel/trunk/network/queue.inc @@ -66,7 +66,7 @@ local .ok, .no_wrap mov edi, [ptr + queue.w_ptr] ; Current write pointer (FIFO!) mov ecx, entry_size/4 ; Write the queue entry - rep movsd ; + rep movsd ; lea ecx, [size*entry_size+ptr+sizeof.queue] cmp edi, ecx ; entry size diff --git a/kernel/trunk/network/socket.inc b/kernel/trunk/network/socket.inc index 7be377f6e0..abfc9a78f3 100644 --- a/kernel/trunk/network/socket.inc +++ b/kernel/trunk/network/socket.inc @@ -215,7 +215,7 @@ macro SOCKET_init { xor eax, eax mov edi, net_sockets mov ecx, 5 - rep stosd + rep stosd @@: pseudo_random eax @@ -923,7 +923,7 @@ SOCKET_receive_dgram: .nw: test ecx, ecx jz .nd - rep movsd + rep movsd .nd: call kernel_free ; free kernel buffer @@ -1371,7 +1371,7 @@ SOCKET_debug: mov esi, eax mov ecx, SOCKETBUFFSIZE/4 - rep movsd + rep movsd mov dword[esp+32], 0 ret @@ -1662,7 +1662,7 @@ SOCKET_ring_write: .nw: test ecx, ecx jz .nd - rep movsd + rep movsd .nd: pop ecx @@ -1728,7 +1728,7 @@ SOCKET_ring_read: .nw: test ecx, ecx jz .nd - rep movsd + rep movsd .nd: pop ecx ret @@ -1957,7 +1957,7 @@ SOCKET_alloc: mov edi, eax mov ecx, SOCKETBUFFSIZE / 4 xor eax, eax - rep stosd + rep stosd pop eax ; set send-and receive procedures to return -1 @@ -2153,7 +2153,7 @@ SOCKET_fork: lea esi, [ebx + SOCKET.PID] lea edi, [eax + SOCKET.PID] mov ecx, (SOCKET_QUEUE_LOCATION - SOCKET.PID + 3)/4 - rep movsd + rep movsd and [eax + SOCKET.options], not SO_ACCEPTCON @@ -2300,7 +2300,7 @@ SOCKET_check_owner: mov ebx, [TASK_BASE] mov ebx, [ebx + TASKDATA.pid] cmp [eax + SOCKET.PID], ebx - pop ebx + pop ebx ret diff --git a/kernel/trunk/network/stack.inc b/kernel/trunk/network/stack.inc index 0b2a203ba3..fd26d60cfb 100644 --- a/kernel/trunk/network/stack.inc +++ b/kernel/trunk/network/stack.inc @@ -246,7 +246,7 @@ stack_init: xor eax, eax mov edi, NET_RUNNING mov ecx, (NET_DEVICES_MAX + 2) - rep stosd + rep stosd PPPoE_init @@ -271,8 +271,8 @@ stack_init: ; Wakeup every tick. proc stack_handler_has_work? - mov eax, [timer_ticks] - cmp eax, [net_10ms] + mov eax, [timer_ticks] + cmp eax, [net_10ms] ret endp @@ -366,7 +366,7 @@ NET_add_device: mov ecx, NET_DEVICES_MAX ; We need to check whole list because a device may be removed without re-organizing list mov edi, NET_DRV_LIST - repne scasd ; See if device is already in the list + repne scasd ; See if device is already in the list jz .error ;---------------------------- @@ -375,7 +375,7 @@ NET_add_device: mov ecx, NET_DEVICES_MAX mov edi, NET_DRV_LIST - repne scasd + repne scasd jnz .error sub edi, 4 @@ -426,7 +426,7 @@ NET_remove_device: mov ecx, NET_DEVICES_MAX mov edi, NET_DRV_LIST - repne scasd + repne scasd jnz .error ;------------------------ @@ -663,7 +663,7 @@ sys_network: mov edi, ecx mov ecx, 64/4 ; max length - rep movsd + rep movsd xor eax, eax mov [esp+32], eax diff --git a/kernel/trunk/network/tcp.inc b/kernel/trunk/network/tcp.inc index 9e9f6f3f63..55028a652f 100644 --- a/kernel/trunk/network/tcp.inc +++ b/kernel/trunk/network/tcp.inc @@ -154,7 +154,7 @@ macro TCP_init { xor eax, eax mov edi, TCP_segments_tx mov ecx, (6*NET_DEVICES_MAX) - rep stosd + rep stosd pseudo_random eax mov [TCP_sequence_num], eax diff --git a/kernel/trunk/network/tcp_input.inc b/kernel/trunk/network/tcp_input.inc index 1272dfc69c..8ff26c2aeb 100644 --- a/kernel/trunk/network/tcp_input.inc +++ b/kernel/trunk/network/tcp_input.inc @@ -916,7 +916,7 @@ TCP_process_input: mov ecx, [esp] add ecx, SOCKET.mutex call mutex_lock - pop ebx + pop ebx ; Continue processing xor edx, edx diff --git a/kernel/trunk/network/tcp_output.inc b/kernel/trunk/network/tcp_output.inc index fe616d81aa..862b71e0cd 100644 --- a/kernel/trunk/network/tcp_output.inc +++ b/kernel/trunk/network/tcp_output.inc @@ -452,7 +452,7 @@ TCP_send: mov ecx, [esp + 4] lea esi, [esp + 8] shr ecx, 2 ; count is in bytes, we will work with dwords - rep movsd + rep movsd pop ecx ; full TCP packet size pop esi ; headersize diff --git a/kernel/trunk/network/udp.inc b/kernel/trunk/network/udp.inc index 8f967f7cb6..47d6faf424 100644 --- a/kernel/trunk/network/udp.inc +++ b/kernel/trunk/network/udp.inc @@ -48,7 +48,7 @@ macro UDP_init { xor eax, eax mov edi, UDP_PACKETS_TX mov ecx, 2*NET_DEVICES_MAX - rep stosd + rep stosd } @@ -281,10 +281,10 @@ UDP_output: sub ecx, sizeof.UDP_header add edi, sizeof.UDP_header shr ecx, 2 - rep movsd + rep movsd mov ecx, [esp] and ecx, 3 - rep movsb + rep movsb pop ecx edi pop dword [edi + UDP_header.SourcePort]