forked from KolibriOS/kolibrios
92f657f440
git-svn-id: svn://kolibrios.org@593 a494cfbc-eb01-0410-851d-a64ba20cac60
136 lines
4.1 KiB
PHP
136 lines
4.1 KiB
PHP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; ;;
|
|
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
;; ;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
$Revision$
|
|
|
|
|
|
;**************************************************
|
|
;* ÏÎÈÑÊ ÌÛØÈ ÏÎ ÏÎÑËÅÄÎÂÀÒÅËÜÍÛÌ ÏÎÐÒÀÌ *
|
|
;* Ïðîöåäóðà ïîäãîòàâëèâàåò ãëîáàëüíûå ïåðåìåííûå *
|
|
;* COMPortNum è COMPortBaseAddr äëÿ ïîäïðîãðàììû *
|
|
;* óñòàíîâêè îáðàáîò÷èêà ïðåðûâàíèÿ *
|
|
;**************************************************
|
|
; Àâòîð èñõîäíîãî òåêñòà Êóëàêîâ Âëàäèìèð Ãåííàäüåâè÷.
|
|
; Àäàïòàöèÿ è äîðàáîòêà Mario79
|
|
|
|
Detect_COM_Mouse:
|
|
pusha
|
|
call MSMouseSearch
|
|
cmp AL,'M'
|
|
jne @f
|
|
mov [com1_mouse_detected],1
|
|
mov [irq_owner+4*4], 1 ; IRQ4 owner is System
|
|
mov eax, [RESERVED_PORTS]
|
|
inc eax
|
|
mov [RESERVED_PORTS], eax
|
|
shl eax, 4
|
|
mov [RESERVED_PORTS+eax+0], dword 1
|
|
mov [RESERVED_PORTS+eax+4], dword 0x3F8
|
|
mov [RESERVED_PORTS+eax+8], dword 0x3FF
|
|
mov esi,boot_setmouse_type+22
|
|
call boot_log
|
|
@@:
|
|
sub [COMPortBaseAddr],100h
|
|
call MSMouseSearch
|
|
cmp AL,'M'
|
|
jne @f
|
|
mov [com2_mouse_detected],1
|
|
mov [irq_owner+3*4], 1 ; IRQ3 owner is System
|
|
mov eax, [RESERVED_PORTS]
|
|
inc eax
|
|
mov [RESERVED_PORTS], eax
|
|
shl eax, 4
|
|
mov [RESERVED_PORTS+eax+0], dword 1
|
|
mov [RESERVED_PORTS+eax+4], dword 0x2F8
|
|
mov [RESERVED_PORTS+eax+8], dword 0x2FF
|
|
mov esi,boot_setmouse_type+44
|
|
call boot_log
|
|
@@:
|
|
popa
|
|
jmp end_detecting_mouse
|
|
|
|
MSMouseSearch:
|
|
; ÏÎÈÑÊ ÌÛØÈ ×ÅÐÅÇ COM-ÏÎÐÒÛ
|
|
MouseSearch:
|
|
; Óñòàíàâëèâàåì ñêîðîñòü
|
|
; ïðèåìà/ïåðåäà÷è 1200 áîä
|
|
mov DX,[COMPortBaseAddr]
|
|
add DX,3
|
|
in AL,DX
|
|
or AL,80h ;óñòàíîâèòü áèò DLAB
|
|
out DX,AL
|
|
mov DX,[COMPortBaseAddr]
|
|
mov AL,60h ;1200 áîä
|
|
out DX,AL
|
|
inc DX
|
|
mov AL,0
|
|
out DX,AL
|
|
; Óñòàíîâèòü äëèíó ñëîâà 7 áèò, 1 ñòîïîâûé áèò,
|
|
; ÷åòíîñòü íå êîíòðîëèðîâàòü
|
|
mov DX,[COMPortBaseAddr]
|
|
add DX,3
|
|
mov AL,00000010b
|
|
out DX,AL
|
|
; Çàïðåòèòü âñå ïðåðûâàíè
|
|
mov DX,[COMPortBaseAddr]
|
|
inc DX
|
|
mov AL,0
|
|
out DX,AL
|
|
; Ïðîâåðèòü, ÷òî óñòðîéñòâî ïîäêëþ÷åíî è ÿâëÿåòñ
|
|
; ìûøüþ òèïà MSMouse
|
|
; Îòêëþ÷èòü ïèòàíèå ìûøè è ïðåðûâàíè
|
|
mov DX,[COMPortBaseAddr]
|
|
add EDX,4 ;ðåãèñòð óïðàâëåíèÿ ìîäåìîì
|
|
mov AL,0 ;ñáðîñèòü DTR, RTS è OUT2
|
|
out DX,AL
|
|
; Îæèäàòü 5 "òèêîâ" (0,2 ñ)
|
|
mov ecx, 0xFFFF
|
|
loop $
|
|
; Âêëþ÷èòü ïèòàíèå ìûøè
|
|
mov al, 1
|
|
out dx, al
|
|
mov ecx, 0xFFFF
|
|
loop $
|
|
; Î÷èñòèòü ðåãèñòð äàííûõ
|
|
sub edx, 4
|
|
in AL,DX
|
|
add edx, 4
|
|
mov AL,11b ;óñòàíîâèòü DTR è RTS
|
|
out DX,AL
|
|
mov ecx, 0x1FFFF
|
|
; Öèêë îïðîñà ïîðòà
|
|
WaitData:
|
|
; Îæèäàòü åùå 10 "òèêîâ"
|
|
dec ecx
|
|
cmp ecx,0
|
|
je NoMouse
|
|
; Ïðîâåðèòü íàëè÷èå èäåíòèôèêàöèîííîãî áàéòà
|
|
mov DX,[COMPortBaseAddr]
|
|
add DX,5
|
|
in AL,DX
|
|
test AL,1 ;Äàííûå ãîòîâû?
|
|
jz WaitData
|
|
; Ââåñòè äàííûå
|
|
mov DX,[COMPortBaseAddr]
|
|
in AL,DX
|
|
NoMouse:
|
|
ret
|
|
|
|
iglobal
|
|
COMPortBaseAddr dw 3F8h
|
|
;COMPortNum dw 0
|
|
endg
|
|
|
|
iglobal
|
|
boot_setmouse_type db 'Detected - PS2 mouse',0
|
|
db 'Detected - COM1 mouse',0
|
|
db 'Detected - COM2 mouse',0
|
|
endg
|
|
|
|
end_detecting_mouse:
|
|
|