drivers/ps2mouse4d: Post-SVN tidy #248

Open
ace-dent wants to merge 1 commits from ace-dent/kolibrios-gitea:PR-TidySVN-Drivers into main
5 changed files with 280 additions and 277 deletions

View File

@@ -570,7 +570,7 @@ tup.append_table(img_files, {
{"DRIVERS/USBSTOR.SYS", VAR_DRVS .. "/usb/usbstor.sys"}, {"DRIVERS/USBSTOR.SYS", VAR_DRVS .. "/usb/usbstor.sys"},
{"DRIVERS/RDC.SYS", VAR_DRVS .. "/video/rdc.sys"}, {"DRIVERS/RDC.SYS", VAR_DRVS .. "/video/rdc.sys"},
{"DRIVERS/COMMOUSE.SYS", VAR_DRVS .. "/mouse/commouse.sys"}, {"DRIVERS/COMMOUSE.SYS", VAR_DRVS .. "/mouse/commouse.sys"},
{"DRIVERS/PS2MOUSE.SYS", VAR_DRVS .. "/mouse/ps2mouse4d/trunk/ps2mouse.sys"}, {"DRIVERS/PS2MOUSE.SYS", VAR_DRVS .. "/mouse/ps2mouse4d/ps2mouse.sys"},
{"DRIVERS/TMPDISK.SYS", VAR_DRVS .. "/disk/tmpdisk.sys"}, {"DRIVERS/TMPDISK.SYS", VAR_DRVS .. "/disk/tmpdisk.sys"},
{"DRIVERS/HDAUDIO.SYS", VAR_DRVS .. "/audio/intel_hda/hdaudio.sys"}, {"DRIVERS/HDAUDIO.SYS", VAR_DRVS .. "/audio/intel_hda/hdaudio.sys"},
{"DRIVERS/SB16.SYS", VAR_DRVS .. "/audio/sb16/sb16.sys"}, {"DRIVERS/SB16.SYS", VAR_DRVS .. "/audio/sb16/sb16.sys"},

View File

@@ -1,276 +1,279 @@
; standard driver stuff; version of driver model = 5 ; SPDX-License-Identifier: NOASSERTION
format PE DLL native 0.05 ;
DEBUG equ 1 ; standard driver stuff; version of driver model = 5
format PE DLL native 0.05
MT_3B equ 0
MT_3BScroll equ 3 DEBUG equ 1
MT_5BScroll equ 4
MT_3B equ 0
PS2_DRV_VER equ 1 MT_3BScroll equ 3
MT_5BScroll equ 4
section '.flat' code readable writable executable
data fixups PS2_DRV_VER equ 1
end data
include '../../../struct.inc' section '.flat' code readable writable executable
include '../../../macros.inc' data fixups
include '../../../proc32.inc' end data
include '../../../peimport.inc' include '../../struct.inc'
include '../../macros.inc'
include '../../proc32.inc'
entry START include '../../peimport.inc'
proc START c, state:dword, cmdline:dword
cmp [state], DRV_ENTRY entry START
je .init proc START c, state:dword, cmdline:dword
cmp [state], DRV_EXIT
je .fini cmp [state], DRV_ENTRY
jmp .nothing je .init
.init: cmp [state], DRV_EXIT
; disable keyboard and mouse interrupts je .fini
; keyboard IRQ handler can interfere badly otherwise jmp .nothing
pushf .init:
cli ; disable keyboard and mouse interrupts
mov bl, 0x20 ; read command byte ; keyboard IRQ handler can interfere badly otherwise
call kbd_cmd pushf
test ah,ah cli
jnz .fin mov bl, 0x20 ; read command byte
call kbd_read call kbd_cmd
test ah,ah test ah,ah
jnz .fin jnz .fin
popf call kbd_read
and al, 0xFC ; disable interrupts test ah,ah
or al, 0x10 ; disable keyboard jnz .fin
push eax popf
mov bl, 0x60 ; write command byte and al, 0xFC ; disable interrupts
call kbd_cmd or al, 0x10 ; disable keyboard
pop eax push eax
call kbd_write mov bl, 0x60 ; write command byte
call kbd_cmd
call detect_mouse pop eax
test eax,eax call kbd_write
jnz .exit
call detect_mouse
mov [MouseType],MT_3B test eax,eax
jnz .exit
call try_mode_ID3
test eax,eax mov [MouseType],MT_3B
jnz .stop_try
mov [MouseType],MT_3BScroll call try_mode_ID3
test eax,eax
call try_mode_ID4 jnz .stop_try
test eax,eax mov [MouseType],MT_3BScroll
jnz .stop_try
mov [MouseType],MT_5BScroll call try_mode_ID4
test eax,eax
.stop_try: jnz .stop_try
mov [MouseType],MT_5BScroll
mov al, 0xF4 ; enable data reporting
call mouse_cmd .stop_try:
; enable keyboard and mouse interrupts mov al, 0xF4 ; enable data reporting
mov bl, 0x20 ; read command byte call mouse_cmd
call kbd_cmd
call kbd_read ; enable keyboard and mouse interrupts
or al, 3 ; enable interrupts mov bl, 0x20 ; read command byte
and al, not 0x10 ; enable keyboard call kbd_cmd
push eax call kbd_read
mov bl, 0x60 ; write command byte or al, 3 ; enable interrupts
call kbd_cmd and al, not 0x10 ; enable keyboard
pop eax push eax
call kbd_write mov bl, 0x60 ; write command byte
call kbd_cmd
invoke AttachIntHandler, 12, irq_handler, 0 pop eax
invoke RegService, my_service, service_proc call kbd_write
ret
invoke AttachIntHandler, 12, irq_handler, 0
.fin: invoke RegService, my_service, service_proc
popf ret
;invoke DetachIntHandler, 12, irq_handler
mov bl, 0xA7 ; disable mouse interface .fin:
call kbd_cmd popf
.nothing: ;invoke DetachIntHandler, 12, irq_handler
xor eax, eax mov bl, 0xA7 ; disable mouse interface
ret call kbd_cmd
.fini: .nothing:
mov al, 0xF5 xor eax, eax
call mouse_cmd ret
ret .fini:
mov al, 0xF5
.exit: call mouse_cmd
mov bl, 0xA7 ; disable mouse interface ret
call kbd_cmd
.exit:
; enable keyboard interrupt, leave mouse interrupt disabled mov bl, 0xA7 ; disable mouse interface
mov bl, 0x20 ; read command byte call kbd_cmd
call kbd_cmd
call kbd_read ; enable keyboard interrupt, leave mouse interrupt disabled
or al, 1 ; enable keyboard interrupt mov bl, 0x20 ; read command byte
and al, not 0x10 ; enable keyboard call kbd_cmd
push eax call kbd_read
mov bl, 0x60 ; write command byte or al, 1 ; enable keyboard interrupt
call kbd_cmd and al, not 0x10 ; enable keyboard
pop eax push eax
call kbd_write mov bl, 0x60 ; write command byte
call kbd_cmd
xor eax, eax pop eax
ret call kbd_write
endp
xor eax, eax
proc service_proc stdcall, ioctl:dword ret
mov edi, [ioctl] endp
mov eax, [edi+IOCTL.io_code]
test eax, eax proc service_proc stdcall, ioctl:dword
jz .getversion mov edi, [ioctl]
cmp eax,1 mov eax, [edi+IOCTL.io_code]
jz .gettype test eax, eax
jz .getversion
.err: cmp eax,1
or eax, -1 jz .gettype
ret
.err:
.ok: or eax, -1
xor eax, eax ret
ret
.ok:
.getversion: xor eax, eax
cmp [edi+IOCTL.out_size], 4 ret
jb .err
mov edi, [edi+IOCTL.output] .getversion:
mov dword [edi], PS2_DRV_VER ; version of driver cmp [edi+IOCTL.out_size], 4
jmp .ok jb .err
.gettype: mov edi, [edi+IOCTL.output]
cmp [edi+IOCTL.out_size], 4 mov dword [edi], PS2_DRV_VER ; version of driver
jb .err jmp .ok
mov edi, [edi+IOCTL.output] .gettype:
mov eax,[MouseType] cmp [edi+IOCTL.out_size], 4
mov dword [edi], eax ; mouse type jb .err
jmp .ok mov edi, [edi+IOCTL.output]
endp mov eax,[MouseType]
mov dword [edi], eax ; mouse type
detect_mouse: jmp .ok
endp
mov bl, 0xA8 ; enable mouse interface
call kbd_cmd detect_mouse:
cmp ah,1
je .fail mov bl, 0xA8 ; enable mouse interface
call kbd_cmd
mov al, 0xFF ; reset cmp ah,1
call mouse_cmd je .fail
jc .fail
mov al, 0xFF ; reset
call mouse_read call mouse_cmd
jc .fail jc .fail
cmp al, 0xAA
jne .fail ; dead mouse call mouse_read
jc .fail
; get device ID cmp al, 0xAA
call mouse_read jne .fail ; dead mouse
jc .fail
cmp al, 0x00 ; get device ID
jne .fail ; unknown device call mouse_read
jc .fail
xor eax,eax cmp al, 0x00
ret jne .fail ; unknown device
.fail: xor eax,eax
or eax,-1 ret
ret
.fail:
try_mode_ID3: or eax,-1
mov al, 0xF3 ;Set Sample Rate ret
call mouse_cmd
jc .fail try_mode_ID3:
mov al, 0xC8 ;200d mov al, 0xF3 ;Set Sample Rate
call mouse_cmd call mouse_cmd
jc .fail jc .fail
mov al, 0xF3 ;Set Sample Rate mov al, 0xC8 ;200d
call mouse_cmd call mouse_cmd
jc .fail jc .fail
mov al, 0x64 ;100d mov al, 0xF3 ;Set Sample Rate
call mouse_cmd call mouse_cmd
jc .fail jc .fail
mov al, 0xF3 ;Set Sample Rate mov al, 0x64 ;100d
call mouse_cmd call mouse_cmd
jc .fail jc .fail
mov al, 0x50 ;80d mov al, 0xF3 ;Set Sample Rate
call mouse_cmd call mouse_cmd
jc .fail jc .fail
mov al, 0x50 ;80d
mov al, 0xF2 ;Get device id call mouse_cmd
call mouse_cmd jc .fail
jc .fail
mov al, 0xF2 ;Get device id
call mouse_read call mouse_cmd
jc .fail jc .fail
cmp al, 0x03
jne .fail call mouse_read
jc .fail
xor eax,eax cmp al, 0x03
ret jne .fail
.fail:
or eax,-1 xor eax,eax
ret ret
.fail:
try_mode_ID4: or eax,-1
mov al, 0xF3 ;Set Sample Rate ret
call mouse_cmd
jc .fail try_mode_ID4:
mov al, 0xC8 ;200d mov al, 0xF3 ;Set Sample Rate
call mouse_cmd call mouse_cmd
jc .fail jc .fail
mov al, 0xF3 ;Set Sample Rate mov al, 0xC8 ;200d
call mouse_cmd call mouse_cmd
jc .fail jc .fail
mov al, 0xC8 ;100d mov al, 0xF3 ;Set Sample Rate
call mouse_cmd call mouse_cmd
jc .fail jc .fail
mov al, 0xF3 ;Set Sample Rate mov al, 0xC8 ;100d
call mouse_cmd call mouse_cmd
jc .fail jc .fail
mov al, 0x50 ;80d mov al, 0xF3 ;Set Sample Rate
call mouse_cmd call mouse_cmd
jc .fail jc .fail
mov al, 0x50 ;80d
mov al, 0xF2 ;Get device id call mouse_cmd
call mouse_cmd jc .fail
jc .fail
mov al, 0xF2 ;Get device id
call mouse_read call mouse_cmd
jc .fail jc .fail
cmp al, 0x04
jne .fail call mouse_read
jc .fail
xor eax,eax cmp al, 0x04
ret jne .fail
.fail: xor eax,eax
or eax,-1 ret
ret
.fail:
include 'ps2m_iofuncs.inc' or eax,-1
include 'ps2m_irqh.inc' ret
my_service db 'ps2mouse',0 include 'ps2m_iofuncs.inc'
include 'ps2m_irqh.inc'
;iofuncs data
mouse_cmd_byte db 0 my_service db 'ps2mouse',0
mouse_nr_tries db 0
mouse_nr_resends db 0 ;iofuncs data
mouse_cmd_byte db 0
;hid data mouse_nr_tries db 0
mouse_byte dd 0 mouse_nr_resends db 0
first_byte db 0 ;hid data
second_byte db 0 mouse_byte dd 0
third_byte db 0
fourth_byte db 0 first_byte db 0
second_byte db 0
;main data third_byte db 0
MouseType dd 0 fourth_byte db 0
XMoving dd 0 ;main data
YMoving dd 0 MouseType dd 0
ZMoving dd 0
ButtonState dd 0 XMoving dd 0
;timerTicks dd 0 YMoving dd 0
ZMoving dd 0
ButtonState dd 0
;timerTicks dd 0