/kernel/trunk/build.bat |
---|
1,7 → 1,7 |
@echo off |
set languages=en ru ge et |
set drivers=sound sis infinity ensoniq ps2mouse uart ati2d vmode |
set drivers=sound sis infinity ensoniq ps2mouse com_mouse uart ati2d vmode |
set targets=all kernel drivers skins clean |
call :Check_Target %1 |
/kernel/trunk/core/dll.inc |
---|
24,7 → 24,16 |
mov eax, [handler] |
test eax, eax |
jz .err |
cmp [irq_owner + 4 * ebx], 0 |
jne .err |
mov [irq_tab+ebx*4], eax |
;push eax |
;mov eax, [TASK_BASE] |
;mov eax, [eax + TASKDATA.pid] |
mov [irq_owner + 4 * ebx], 1 |
;pop eax |
stdcall enable_irq, [irq] |
ret |
.err: |
59,83 → 68,69 |
irq_serv: |
.irq_1: |
push eax |
mov eax, 1 |
push 1 |
jmp .main |
align 4 |
.irq_2: |
push eax |
mov eax, 2 |
push 2 |
jmp .main |
align 4 |
.irq_3: |
push eax |
mov eax, 3 |
push 3 |
jmp .main |
align 4 |
.irq_4: |
push eax |
mov eax, 4 |
push 4 |
jmp .main |
align 4 |
.irq_5: |
push eax |
mov eax, 5 |
push 5 |
jmp .main |
align 4 |
.irq_6: |
push eax |
mov eax, 6 |
push 6 |
jmp .main |
align 4 |
.irq_7: |
push eax |
mov eax, 7 |
push 7 |
jmp .main |
align 4 |
.irq_8: |
push eax |
mov eax, 8 |
push 8 |
jmp .main |
align 4 |
.irq_9: |
push eax |
mov eax, 9 |
push 9 |
jmp .main |
align 4 |
.irq_10: |
push eax |
mov eax, 10 |
push 10 |
jmp .main |
align 4 |
.irq_11: |
push eax |
mov eax, 11 |
push 11 |
jmp .main |
align 4 |
.irq_12: |
push eax |
mov eax, 12 |
push 12 |
jmp .main |
align 4 |
.irq_13: |
push eax |
mov eax, 13 |
push 13 |
jmp .main |
align 4 |
.irq_14: |
push eax |
mov eax, 14 |
push 14 |
jmp .main |
align 4 |
.irq_15: |
push eax |
mov eax, 15 |
push 15 |
jmp .main |
align 16 |
.main: |
save_ring3_context |
mov eax, [esp + 32] |
mov bx, app_data ;os_data |
mov ds, bx |
mov es, bx |
151,9 → 146,8 |
mov [check_idle_semaphore],5 |
.exit: |
restore_ring3_context |
cmp eax, 8 |
cmp dword [esp + 32], 8 |
mov al, 0x20 |
jb @f |
out 0xa0, al |
160,7 → 154,9 |
@@: |
out 0x20, al |
pop eax |
restore_ring3_context |
add esp, 4 |
iret |
align 4 |
/kernel/trunk/core/exports.inc |
---|
18,6 → 18,8 |
szAttachIntHandler db 'AttachIntHandler',0 |
szFpuSave db 'FpuSave',0 |
szFpuRestore db 'FpuRestore',0 |
szReservePortArea db 'ReservePortArea',0 |
szBoot_Log db 'Boot_Log',0 |
szPciApi db 'PciApi', 0 |
szPciRead32 db 'PciRead32', 0 |
88,6 → 90,8 |
dd szAttachIntHandler, attach_int_handler |
dd szFpuSave , fpu_save |
dd szFpuRestore , fpu_restore |
dd szReservePortArea , r_f_port_area |
dd szBoot_Log , boot_log |
dd szPciApi , pci_api |
dd szPciRead32 , pci_read32 |
/kernel/trunk/core/sys32.inc |
---|
183,20 → 183,12 |
{ |
forward |
p_irq#num : |
save_ring3_context |
mov edi, num |
jmp irq_c |
jmp irqhandler |
} |
irqh 2,5,7,8,9,10,11 |
irqh 2,3,4,5,7,8,9,10,11 |
irq_c: |
mov ax, app_data ;os_data |
mov ds, ax |
mov es, ax |
call irqhandler |
restore_ring3_context |
iret |
p_irq6: |
save_ring3_context |
208,42 → 200,7 |
restore_ring3_context |
iret |
p_irq3: |
save_ring3_context |
mov ax, app_data ;os_data |
mov ds, ax |
mov es, ax |
cmp [com2_mouse_detected],0 |
je old_irq3_handler |
mov esi, com2_mouse |
mov dx, 2F8h ;[COMPortBaseAddr] |
call check_mouse_data_com |
jmp p_irq3_1 |
old_irq3_handler: |
mov edi,3 |
call irqhandler |
p_irq3_1: |
restore_ring3_context |
iret |
p_irq4: |
save_ring3_context |
mov ax, app_data ;os_data |
mov ds, ax |
mov es, ax |
cmp [com1_mouse_detected],0 |
je old_irq4_handler |
mov esi, com1_mouse |
mov dx, 3F8h ;[COMPortBaseAddr] |
call check_mouse_data_com |
jmp p_irq4_1 |
old_irq4_handler: |
mov edi,4 |
call irqhandler |
p_irq4_1: |
restore_ring3_context |
iret |
p_irq14: |
save_ring3_context |
mov ax, app_data ;os_data |
303,7 → 260,6 |
cmp [v86_irqhooks+edi*8], 0 |
jnz v86_irq2 |
push edi |
mov esi,edi ; 1 |
shl esi,6 ; 1 |
312,8 → 268,6 |
add edi,IRQ_SAVE |
mov ecx,16 |
mov [check_idle_semaphore],5 |
irqnewread: |
dec ecx |
js irqover |
368,15 → 322,6 |
irqfull: |
irqover: |
mov al,0x20 ; ready for next irq |
out 0x20,al |
pop ebx |
cmp ebx,7 |
jbe noa0 |
out 0xa0,al |
noa0: |
ret |
/kernel/trunk/data32.inc |
---|
88,6 → 88,7 |
;szInfinity db 'INFINITY',0 |
szHwMouse db 'ATI2D',0 |
szPS2MDriver db 'PS2MOUSE',0 |
szCOM_MDriver db 'COM_MOUSE',0 |
szUSB db 'USB',0 |
szSTART db 'START',0 |
385,8 → 386,7 |
mouse_active rd 1 |
mouse_pause rd 1 |
MouseTickCounter rd 1 |
com1_mouse_detected rb 1 |
com2_mouse_detected rb 1 |
;* end code - Mario79 |
img_background rd 1 |
/kernel/trunk/detect/commouse.inc |
---|
File deleted |
Property changes: |
Deleted: svn:keywords |
-Rev |
\ No newline at end of property |
/kernel/trunk/drivers/com_mouse.asm |
---|
0,0 → 1,375 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;driver sceletone |
format MS COFF |
API_VERSION equ 5 ;debug |
include 'proc32.inc' |
include 'imports.inc' |
OS_BASE equ 0x80000000; |
new_app_base equ 0x0 |
PROC_BASE equ OS_BASE+0x0080000 |
struc IOCTL |
{ .handle dd ? |
.io_code dd ? |
.input dd ? |
.inp_size dd ? |
.output dd ? |
.out_size dd ? |
} |
virtual at 0 |
IOCTL IOCTL |
end virtual |
public START |
public version |
DEBUG equ 0 |
DRV_ENTRY equ 1 |
DRV_EXIT equ -1 |
STRIDE equ 4 ;size of row in devices table |
SRV_GETVERSION equ 0 |
section '.flat' code readable align 16 |
proc START stdcall, state:dword |
cmp [state], 1 |
jne .exit |
.entry: |
;Detect_COM_Mouse: |
if DEBUG |
mov esi, msgInit |
call Boot_Log |
end if |
mov bx, 0x3f8 |
call MSMouseSearch |
cmp AL,'M' |
jne @f |
;mov [com1_mouse_detected],1 |
;mov [irq_owner+4*4], 1 ; IRQ4 owner is System |
mov dx, bx |
inc dx ; 0x3f8 + 1 |
mov al, 1 |
out dx, al |
stdcall AttachIntHandler, 4, irq4_handler |
if DEBUG |
cmp eax, 0 |
jne .label1 |
mov esi, msg_error_attach_int_handler |
call Boot_Log |
end if |
.label1: |
mov eax, 0 |
mov ebx, 0x3F8 |
mov ecx, 0x3FF |
call ReservePortArea |
if DEBUG |
cmp eax, 1 |
jne .go |
mov esi, msg_error_reserve_ports |
call Boot_Log |
.go: |
mov esi,boot_setmouse_type |
call Boot_Log |
end if |
@@: |
mov bx, 0x2f8 |
call MSMouseSearch |
cmp AL,'M' |
jne .resume |
;mov [com2_mouse_detected],1 |
;mov [irq_owner+3*4], 1 ; IRQ3 owner is System |
stdcall AttachIntHandler, 3, irq3_handler |
mov eax, 0 |
mov ebx, 0x2F8 |
mov ecx, 0x3F8 |
call ReservePortArea |
if DEBUG |
cmp eax, 1 |
jne @f |
mov esi, msg_error_reserve_ports |
call Boot_Log |
@@: |
mov esi,boot_setmouse_type + 22 |
call Boot_Log |
end if |
.resume: |
stdcall RegService, my_service, service_proc |
if DEBUG |
cmp eax, 0 |
jne @f |
mov esi, msg_exit |
call Boot_Log |
end if |
@@: |
ret |
.fail: |
.exit: |
if DEBUG |
mov esi, msg_exit |
call Boot_Log |
end if |
xor eax, eax |
ret |
endp |
handle equ IOCTL.handle |
io_code equ IOCTL.io_code |
input equ IOCTL.input |
inp_size equ IOCTL.inp_size |
output equ IOCTL.output |
out_size equ IOCTL.out_size |
align 4 |
proc service_proc stdcall, ioctl:dword |
mov ebx, [ioctl] |
mov eax, [ebx+io_code] |
cmp eax, SRV_GETVERSION |
jne @F |
mov eax, [ebx+output] |
cmp [ebx+out_size], 4 |
jne .fail |
mov [eax], dword API_VERSION |
xor eax, eax |
ret |
@@: |
.fail: |
or eax, -1 |
ret |
endp |
align 4 |
MSMouseSearch: |
; ÏÎÈÑÊ ÌÛØÈ ×ÅÐÅÇ COM-ÏÎÐÒÛ |
MouseSearch: |
; Óñòàíàâëèâàåì ñêîðîñòü |
; ïðèåìà/ïåðåäà÷è 1200 áîä |
; in bx COM Port Base Address |
mov DX, bx |
add DX,3 |
in AL,DX |
or AL,80h ;óñòàíîâèòü áèò DLAB |
out DX,AL |
mov DX, bx |
mov AL,60h ;1200 áîä |
out DX,AL |
inc DX |
mov AL,0 |
out DX,AL |
; Óñòàíîâèòü äëèíó ñëîâà 7 áèò, 1 ñòîïîâûé áèò, |
; ÷åòíîñòü íå êîíòðîëèðîâàòü |
mov DX, bx |
add DX,3 |
mov AL,00000010b |
out DX,AL |
; Çàïðåòèòü âñå ïðåðûâàíè |
mov dx, bx |
inc dx |
mov AL,0 |
out DX,AL |
; Ïðîâåðèòü, ÷òî óñòðîéñòâî ïîäêëþ÷åíî è ÿâëÿåòñ |
; ìûøüþ òèïà MSMouse |
; Îòêëþ÷èòü ïèòàíèå ìûøè è ïðåðûâàíè |
mov DX, bx |
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 $ |
; Î÷èñòèòü ðåãèñòð äàííûõ |
mov dx, bx |
in AL,DX |
add edx, 4 |
mov AL, 1011b ;óñòàíîâèòü DTR è RTS è OUT2 |
out DX,AL |
mov ecx, 0x1FFFF |
; Öèêë îïðîñà ïîðòà |
WaitData: |
; Îæèäàòü åùå 10 "òèêîâ" |
dec ecx |
cmp ecx,0 |
je NoMouse |
; Ïðîâåðèòü íàëè÷èå èäåíòèôèêàöèîííîãî áàéòà |
mov DX, bx |
add DX,5 |
in AL,DX |
test AL,1 ;Äàííûå ãîòîâû? |
jz WaitData |
; Ââåñòè äàííûå |
mov DX, bx |
in AL,DX |
NoMouse: |
ret |
align 4 |
irq3_handler: |
mov dx, 0x2f8 |
mov esi, com2_mouse |
jmp irq_handler |
align 4 |
irq4_handler: |
mov dx, 0x3f8 |
mov esi, com1_mouse |
irq_handler: |
; in: esi -> COM_MOUSE_DATA struc, dx = base port (xF8h) |
add edx, 5 ; xFDh |
in al, dx |
test al, 1 ; Äàííûå ãîòîâû? |
jz .Error |
; Ââåñòè äàííûå |
sub edx, 5 |
in al, dx |
; Ñáðîñèòü ñòàðøèé íåçíà÷àùèé áèò |
and al, 01111111b |
; Îïðåäåëèòü ïîðÿäêîâûé íîìåð ïðèíèìàåìîãî áàéòà |
cmp [esi+COM_MOUSE_DATA.MouseByteNumber], 2 |
ja .Error |
jz .ThirdByte |
jp .SecondByte |
; Ñîõðàíèòü ïåðâûé áàéò äàííûõ |
.FirstByte: |
test al, 1000000b ; Ïåðâûé áàéò ïîñûëêè? |
jz .Error |
mov [esi+COM_MOUSE_DATA.FirstByte], al |
inc [esi+COM_MOUSE_DATA.MouseByteNumber] |
jmp .EndMouseInterrupt |
; Ñîõðàíèòü âòîðîé áàéò äàííûõ |
.SecondByte: |
test al, 1000000b |
jnz .Error |
mov [esi+COM_MOUSE_DATA.SecondByte], al |
inc [esi+COM_MOUSE_DATA.MouseByteNumber] |
jmp .EndMouseInterrupt |
; Ñîõðàíèòü òðåòèé áàéò äàííûõ |
.ThirdByte: |
test al, 1000000b |
jnz .Error |
mov [esi+COM_MOUSE_DATA.ThirdByte], al |
mov [esi+COM_MOUSE_DATA.MouseByteNumber], 0 |
; (Ïàêåò äàííûõ îò ìûøè ïðèíÿò ïîëíîñòüþ). |
; Çàïèñàòü íîâîå çíà÷åíèå ñîñòîÿíèÿ êíîïîê ìûøè |
mov al, [esi+COM_MOUSE_DATA.FirstByte] |
mov ah, al |
shr al, 3 |
and al, 2 |
shr ah, 5 |
and ah, 1 |
add al, ah |
movzx eax, al |
mov [BTN_DOWN], eax |
; Ïðèáàâèòü ïåðåìåùåíèå ïî X ê êîîðäèíàòå X |
mov al, [esi+COM_MOUSE_DATA.FirstByte] |
shl al, 6 |
or al, [esi+COM_MOUSE_DATA.SecondByte] |
cbw |
movzx eax, ax |
mov [MOUSE_X], eax |
; Ïðèáàâèòü ïåðåìåùåíèå ïî Y ê êîîðäèíàòå Y |
mov al, [esi+COM_MOUSE_DATA.FirstByte] |
and al, 00001100b |
shl al, 4 |
or al, [esi+COM_MOUSE_DATA.ThirdByte] |
cbw |
movzx eax, ax |
neg eax |
mov [MOUSE_Y], eax |
stdcall SetMouseData, [BTN_DOWN], [MOUSE_X], [MOUSE_Y], 0, 0 |
jmp .EndMouseInterrupt |
.Error: |
; Ïðîèçîøåë ñáîé â ïîðÿäêå ïåðåäà÷è èíôîðìàöèè îò |
; ìûøè, îáíóëèòü ñ÷åò÷èê áàéòîâ ïàêåòà äàííûõ |
mov [esi+COM_MOUSE_DATA.MouseByteNumber],0 |
.EndMouseInterrupt: |
ret |
;all initialized data place here |
align 4 |
struc COM_MOUSE_DATA { |
; Íîìåð ïðèíèìàåìîãî îò ìûøè áàéòà |
.MouseByteNumber db ? |
; Òðåõáàéòîâàÿ ñòðóêòóðà äàííûõ, ïåðåäàâàåìàÿ ìûøüþ |
.FirstByte db ? |
.SecondByte db ? |
.ThirdByte db ? |
;.timer_ticks_com dd ? |
} |
virtual at 0 |
COM_MOUSE_DATA COM_MOUSE_DATA |
end virtual |
com1_mouse COM_MOUSE_DATA |
com2_mouse COM_MOUSE_DATA |
MOUSE_X dd 0 |
MOUSE_Y dd 0 |
BTN_DOWN dd 0 |
COMPortBaseAddr dw 3F8h |
version dd (5 shl 16) or (API_VERSION and 0xFFFF) |
my_service db 'MY_SERVICE',0 ;max 16 chars include zero |
if DEBUG |
msgInit db 'Preved bugoga!',13,10,0 |
boot_setmouse_type db 'Detected - COM1 mouse',13,10,0 |
db 'Detected - COM2 mouse',13,10,0 |
msg_error_reserve_ports db 'Error reserving ports!',13,10,0 |
msg_error_attach_int_handler db 'Error attach interrupt handler!',13,10,0 |
msg_exit db 'Exit!',13,10,0 |
end if |
section '.data' data readable writable align 16 |
;all uninitialized data place here |
/kernel/trunk/drivers/imports.inc |
---|
21,6 → 21,8 |
AttachIntHandler,\ |
FpuSave,\ |
FpuRestore,\ |
ReservePortArea,\ |
Boot_Log,\ |
\ |
PciApi,\ |
PciRead32,\ |
/kernel/trunk/hid/m_com.inc |
---|
File deleted |
Property changes: |
Deleted: svn:keywords |
-Rev |
\ No newline at end of property |
/kernel/trunk/hid/mousedrv.inc |
---|
32,7 → 32,7 |
mouse_timer_ticks dd 0 |
endg |
include 'm_com.inc' |
;include 'm_com.inc' |
;test_mario79: |
/kernel/trunk/kernel.asm |
---|
58,7 → 58,7 |
$Revision$ |
USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices |
USE_COM_IRQ equ 1 ;make irq 3 and irq 4 available for PCI devices |
include "proc32.inc" |
include "kglobals.inc" |
638,8 → 638,9 |
mov [pci_access_enabled],1 |
call detect_devices |
;call detect_devices |
stdcall load_driver, szPS2MDriver |
stdcall load_driver, szCOM_MDriver |
; SET MOUSE |
671,7 → 672,7 |
mov esi,boot_setrports |
call boot_log |
call setirqreadports |
;call setirqreadports |
; SET UP OS TASK |
1029,7 → 1030,7 |
pushad |
mov [irq_owner+4*0], 1 ; timer |
mov [irq_owner+4*1], 1 ; keyboard |
;mov [irq_owner+4*1], 1 ; keyboard |
mov [irq_owner+4*5], 1 ; sound blaster |
mov [irq_owner+4*6], 1 ; floppy diskette |
mov [irq_owner+4*13], 1 ; math co-pros |
1068,20 → 1069,14 |
popad |
ret |
iglobal |
mouseirqtable db 12 ; ps2 |
db 4 ; com1 |
db 3 ; com2 |
endg |
setirqreadports: |
mov [irq12read+0],dword 0x60 + 0x01000000 ; read port 0x60 , byte |
mov [irq12read+4],dword 0 ; end of port list |
mov [irq04read+0],dword 0x3f8 + 0x01000000 ; read port 0x3f8 , byte |
mov [irq04read+4],dword 0 ; end of port list |
mov [irq03read+0],dword 0x2f8 + 0x01000000 ; read port 0x2f8 , byte |
mov [irq03read+4],dword 0 ; end of port list |
;mov [irq04read+0],dword 0x3f8 + 0x01000000 ; read port 0x3f8 , byte |
;mov [irq04read+4],dword 0 ; end of port list |
;mov [irq03read+0],dword 0x2f8 + 0x01000000 ; read port 0x2f8 , byte |
;mov [irq03read+4],dword 0 ; end of port list |
ret |
1998,7 → 1993,7 |
detect_devices: |
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
include 'detect/commouse.inc' |
;include 'detect/commouse.inc' |
;include 'detect/ps2mouse.inc' |
;include 'detect/dev_fd.inc' |
;include 'detect/dev_hdcd.inc' |
4187,10 → 4182,12 |
cmp ecx, 16 |
jae ril1 |
push ecx |
lea ecx, [irq_owner + 4 * ecx] |
mov edx, [ecx] |
mov eax, [TASK_BASE] |
mov edi, [eax + TASKDATA.pid] |
pop eax |
dec ebx |
jnz reserve_irq |
4206,12 → 4203,38 |
cmp dword [ecx], 0 |
jne ril1 |
mov ebx, [f_irqs + 4 * eax] |
stdcall attach_int_handler, eax, ebx |
mov [ecx], edi |
dec esi |
ril1: |
mov [esp+32], esi ; return in eax |
ret |
iglobal |
f_irqs: |
dd 0x0 |
dd 0x0 |
dd p_irq2 |
dd p_irq3 |
dd p_irq4 |
dd p_irq5 |
dd p_irq6 |
dd p_irq7 |
dd p_irq8 |
dd p_irq9 |
dd p_irq10 |
dd p_irq11 |
dd 0x0 |
dd 0x0 |
dd p_irq14 |
dd p_irq15 |
endg |
drawbackground: |
inc [mouse_pause] |
cmp [SCR_MODE],word 0x12 |
4494,93 → 4517,7 |
mov [MOUSE_PICTURE],dword mousepointer |
cli |
; mov bl,0xa8 ; enable mouse cmd |
; call kb_cmd |
; call kb_read ; read status |
; mov bl,0x20 ; get command byte |
; call kb_cmd |
; call kb_read |
; or al,3 ; enable interrupt |
; mov bl,0x60 ; write command |
; push eax |
; call kb_cmd |
; pop eax |
; call kb_write |
; mov bl,0xd4 ; for mouse |
; call kb_cmd |
; mov al,0xf4 ; enable mouse device |
; call kb_write |
; call kb_read ; read status return |
; com1 mouse enable |
mov bx,0x3f8 ; combase |
mov dx,bx |
add dx,3 |
mov al,0x80 |
out dx,al |
mov dx,bx |
add dx,1 |
mov al,0 |
out dx,al |
mov dx,bx |
add dx,0 |
mov al,0x30*2 ; 0x30 / 4 |
out dx,al |
mov dx,bx |
add dx,3 |
mov al,2 ; 3 |
out dx,al |
mov dx,bx |
add dx,4 |
mov al,0xb |
out dx,al |
mov dx,bx |
add dx,1 |
mov al,1 |
out dx,al |
; com2 mouse enable |
mov bx,0x2f8 ; combase |
mov dx,bx |
add dx,3 |
mov al,0x80 |
out dx,al |
mov dx,bx |
add dx,1 |
mov al,0 |
out dx,al |
mov dx,bx |
add dx,0 |
mov al,0x30*2 |
out dx,al |
mov dx,bx |
add dx,3 |
mov al,2 |
out dx,al |
mov dx,bx |
add dx,4 |
mov al,0xb |
out dx,al |
mov dx,bx |
add dx,1 |
mov al,1 |
out dx,al |
ret |