move irq functions into separate file

git-svn-id: svn://kolibrios.org@2106 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2011-08-23 12:25:29 +00:00
parent 20ffb9aae0
commit e711a754bc
17 changed files with 314 additions and 886 deletions

View File

@ -114,9 +114,9 @@ APIC_init:
stosd
loop @B
mov ecx, 48
mov eax, irqh_array+IRQH.sizeof
mov [next_irqh], irqh_array
mov ecx, 47
mov eax, irqh_pool+IRQH.sizeof
mov [next_irqh], irqh_pool
@@:
mov [eax-IRQH.sizeof], eax
@ -515,76 +515,6 @@ endp
; endp
macro __list_add new, prev, next
{
mov [next+LHEAD.prev], new
mov [new+LHEAD.next], next
mov [new+LHEAD.prev], prev
mov [prev+LHEAD.next], new
}
macro list_add new, head
{
mov eax, [head+LHEAD.next]
__list_add new, head, eax
}
macro list_add_tail new, head
{
mov eax, [head+LHEAD.prev]
__list_add new, eax, head
}
align 4
proc attach_int_handler_ex stdcall, irq:dword, handler:dword, user_data:dword
locals
.irqh dd ?
endl
and [.irqh], 0
push ebx
mov ebx, [irq] ;irq num
test ebx, ebx
jz .err
cmp ebx, IRQ_RESERVE
jae .err
mov edx, [handler]
test edx, edx
jz .err
pushfd
cli
;allocate handler
mov ecx, [next_irqh]
test ecx, ecx
jz .fail
mov eax, [ecx]
mov [next_irqh], eax
mov [.irqh], ecx
mov eax, [user_data]
mov [ecx+IRQH.handler], edx
mov [ecx+IRQH.data], eax
lea edx, [irqh_tab+ebx*8]
list_add_tail ecx, edx ;clobber eax
stdcall enable_irq, [irq]
.fail:
popfd
.err:
pop ebx
mov eax, [.irqh]
ret
endp

View File

@ -9,138 +9,12 @@ $Revision$
DRV_COMPAT equ 5 ;minimal required drivers version
DRV_CURRENT equ 5 ;current drivers model version
DRV_CURRENT equ 6 ;current drivers model version
DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT
PID_KERNEL equ 1 ;os_idle thread
uglobal
irq_rights rd IRQ_RESERVE
endg
proc get_int_handler stdcall, irq:dword
mov eax, [irq]
cmp [irq_rights + 4 * eax], dword 1
ja .err
mov eax, [irq_tab + 4 * eax]
ret
.err:
xor eax, eax
ret
endp
align 4
proc detach_int_handler
ret
endp
align 16
;; proc irq_serv
irq_serv:
; .irq_1:
; push 1
; jmp .main
; etc...
macro irq_serv_h [num] {
forward
align 4
.irq_#num :
push num
jmp .main
}
irq_serv_h 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15
; I don`t known how to use IRQ_RESERVE
if IRQ_RESERVE > 16
irq_serv_h 16, 17, 18, 19, 20, 21, 22, 23
end if
align 16
.main:
save_ring3_context
mov ebp, [esp + 32]
mov bx, app_data ;os_data
mov ds, bx
mov es, bx
cmp [v86_irqhooks+ebp*8], 0
jnz v86_irq
cmp bp, 6
jnz @f
push ebp
call [fdc_irq_func]
pop ebp
@@:
cmp bp, 14
jnz @f
push ebp
call [irq14_func]
pop ebp
@@:
cmp bp, 15
jnz @f
push ebp
call [irq15_func]
pop ebp
@@:
bts [pending_irq_set], ebp
lea esi, [irqh_tab+ebp*8] ; esi= list head
mov ebx, esi
.next:
mov ebx, [ebx+IRQH.list.next] ; ebx= irqh pointer
cmp ebx, esi
je .done
push ebx ; FIX THIS
push edi
push esi
push [ebx+IRQH.data]
call [ebx+IRQH.handler]
add esp, 4
pop esi
pop edi
pop ebx
test eax, eax
jz .next
btr [pending_irq_set], ebp
jmp .next
.done:
btr [pending_irq_set], ebp
jnc .exit
inc [bogus_irq+ebp*4]
.exit:
mov [check_idle_semaphore],5
mov eax, ebp
call IRQ_EOI
restore_ring3_context
add esp, 4
iret
align 4
proc get_notify stdcall, p_ev:dword
@ -747,6 +621,7 @@ proc fix_coff_relocs stdcall uses ebx esi, coff:dword, sym:dword, \
ret
endp
align 4
proc rebase_coff stdcall uses ebx esi, coff:dword, sym:dword, \
delta:dword
locals

View File

@ -16,7 +16,7 @@ iglobal
szGetService db 'GetService',0
szServiceHandler db 'ServiceHandler',0
szAttachIntHandler db 'AttachIntHandler',0
szGetIntHandler db 'GetIntHandler', 0
; szGetIntHandler db 'GetIntHandler', 0
szFpuSave db 'FpuSave',0
szFpuRestore db 'FpuRestore',0
szReservePortArea db 'ReservePortArea',0
@ -91,8 +91,8 @@ kernel_export:
dd szRegService , reg_service
dd szGetService , get_service
dd szServiceHandler , srv_handler
dd szAttachIntHandler, attach_int_handler_ex
dd szGetIntHandler , get_int_handler
dd szAttachIntHandler, attach_int_handler
; dd szGetIntHandler , get_int_handler
dd szFpuSave , fpu_save
dd szFpuRestore , fpu_restore
dd szReservePortArea , r_f_port_area

View File

@ -0,0 +1,215 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
macro __list_add new, prev, next
{
mov [next+LHEAD.prev], new
mov [new+LHEAD.next], next
mov [new+LHEAD.prev], prev
mov [prev+LHEAD.next], new
}
macro list_add new, head
{
mov eax, [head+LHEAD.next]
__list_add new, head, eax
}
macro list_add_tail new, head
{
mov eax, [head+LHEAD.prev]
__list_add new, eax, head
}
uglobal
align 16
irqh_tab rd LHEAD.sizeof * IRQ_RESERVE / 4
irqh_pool rd IRQH.sizeof *48 /4
next_irqh rd 1
irq_active_set rd 1
irq_failed rd IRQ_RESERVE
endg
align 4
proc attach_int_handler stdcall, irq:dword, handler:dword, user_data:dword
locals
.irqh dd ?
endl
xchg bx, bx
and [.irqh], 0
push ebx
mov ebx, [irq] ;irq num
test ebx, ebx
jz .err
cmp ebx, IRQ_RESERVE
jae .err
mov edx, [handler]
test edx, edx
jz .err
pushfd
cli
;allocate handler
mov ecx, [next_irqh]
test ecx, ecx
jz .fail
mov eax, [ecx]
mov [next_irqh], eax
mov [.irqh], ecx
mov eax, [user_data]
mov [ecx+IRQH.handler], edx
mov [ecx+IRQH.data], eax
lea edx, [irqh_tab+ebx*8]
list_add_tail ecx, edx ;clobber eax
stdcall enable_irq, [irq]
.fail:
popfd
.err:
pop ebx
mov eax, [.irqh]
ret
endp
if 0
align 4
proc get_int_handler stdcall, irq:dword
mov eax, [irq]
cmp eax, 15
ja .fail
mov eax, [irq_tab + 4 * eax]
ret
.fail:
xor eax, eax
ret
endp
end if
align 4
proc detach_int_handler
ret
endp
macro irq_serv_h [num] {
forward
align 4
.irq_#num :
push num
jmp .main
}
align 16
irq_serv:
; .irq_1:
; push 1
; jmp .main
; etc...
irq_serv_h 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15
irq_serv_h 16, 17, 18, 19, 20, 21, 22, 23
purge irq_serv_h
align 16
.main:
save_ring3_context
xchg bx, bx
mov ebp, [esp + 32]
mov bx, app_data ;os_data
mov ds, bx
mov es, bx
cmp [v86_irqhooks+ebp*8], 0
jnz v86_irq
cmp bp, 6
jnz @f
push ebp
call [fdc_irq_func]
pop ebp
@@:
cmp bp, 14
jnz @f
push ebp
call [irq14_func]
pop ebp
@@:
cmp bp, 15
jnz @f
push ebp
call [irq15_func]
pop ebp
@@:
bts [irq_active_set], ebp
lea esi, [irqh_tab+ebp*8] ; esi= list head
mov ebx, esi
.next:
mov ebx, [ebx+IRQH.list.next] ; ebx= irqh pointer
cmp ebx, esi
je .done
push ebx ; FIX THIS
push edi
push esi
push [ebx+IRQH.data]
call [ebx+IRQH.handler]
add esp, 4
pop esi
pop edi
pop ebx
test eax, eax
jz .next
btr [irq_active_set], ebp
jmp .next
.done:
btr [irq_active_set], ebp
jnc .exit
inc [irq_failed+ebp*4]
.exit:
mov [check_idle_semaphore],5
mov eax, ebp
call IRQ_EOI
restore_ring3_context
add esp, 4
iret

View File

@ -316,7 +316,7 @@ __exports:
\
get_service, 'GetService', \ ;
reg_service, 'RegService', \ ; stdcall
attach_int_handler_ex, 'AttachIntHandler', \ ; stdcall
attach_int_handler, 'AttachIntHandler', \ ; stdcall
user_alloc, 'UserAlloc', \ ; stdcall
user_free, 'UserFree', \ ; stdcall
unmap_pages, 'UnmapPages', \ ; eax, ecx

View File

@ -41,16 +41,10 @@ iglobal
;interrupt handlers addresses (for interrupt gate construction)
; 0x20 .. 0x2F - IRQ handlers
dd irq0, irq_serv.irq_1, irq_serv.irq_2
if USE_COM_IRQ
dd irq_serv.irq_3, irq_serv.irq_4
else
dd p_irq3, p_irq4 ;??? íåñòûêîâêà
end if
dd irq_serv.irq_5, irq_serv.irq_6, irq_serv.irq_7
dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10
dd irq_serv.irq_11, irq_serv.irq_12, irqD, irq_serv.irq_14, irq_serv.irq_15
; I don`t known how to use IRQ_RESERVE
if IRQ_RESERVE > 16
dd irq_serv.irq_16
dd irq_serv.irq_17
dd irq_serv.irq_18
@ -59,7 +53,6 @@ if IRQ_RESERVE > 16
dd irq_serv.irq_21
dd irq_serv.irq_22
dd irq_serv.irq_23
end if
times 32 - IRQ_RESERVE dd unknown_interrupt
;int_0x40 gate trap (for directly copied)
@ -251,101 +244,8 @@ show_error_parameters:
restore reg_esi
restore reg_edi
; IRQ runtime
; irq1 -> hid/keyboard.inc
macro irqh [num] {
p_irq#num :
mov edi, num
jmp irqhandler
}
irqh 2,3,4,5,7,8,9,10,11
; I don`t known how to use IRQ_RESERVE
if IRQ_RESERVE > 16
irqh 16, 17, 18, 19, 20, 21, 22, 23
end if
p_irq6: ; FDC
save_ring3_context
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
mov edi, 6
cmp [v86_irqhooks+edi*8], 0
jnz v86_irq2
call fdc_irq
mov [check_idle_semaphore], 5
mov al, 6
call IRQ_EOI
restore_ring3_context
iret
irq13: ; Math coprocessor
save_ring3_context
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
mov dx, 0xf0
mov al, 0
out dx, al
mov al, 13
call IRQ_EOI
restore_ring3_context
iret
p_irq14: ; HDD
save_ring3_context
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
mov edi, 14
cmp [v86_irqhooks+edi*8], 0
jnz v86_irq2
; mov byte [BOOT_VAR + 0x48E], 0xFF
call [irq14_func]
mov [check_idle_semaphore], 5
mov al, 14
call IRQ_EOI
restore_ring3_context
iret
p_irq15: ; HDD2
save_ring3_context
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
mov edi, 15
cmp [v86_irqhooks+edi*8], 0
jnz v86_irq2
; mov byte [BOOT_VAR + 0x48E], 0xFF
call [irq15_func]
mov [check_idle_semaphore], 5
mov al, 15
call IRQ_EOI
restore_ring3_context
iret
ready_for_next_irq:
mov eax,5
mov [check_idle_semaphore],eax
; mov al, 0x20
add eax,(0x20-0x5)
out 0x20, al
ret
;destroy eax
ready_for_next_irq_1:
mov eax,5
mov [check_idle_semaphore],eax
; mov al, 0x20
add eax,(0x20-0x5)
out 0xa0,al
out 0x20, al
ret
align 4
irqD:
push eax
xor eax,eax
@ -358,74 +258,6 @@ irqD:
align 4
irqhandler:
mov esi,edi ; 1
shl esi,6 ; 1
add esi,irq00read ; 1
shl edi,12 ; 1
add edi,IRQ_SAVE
mov ecx,16
irqnewread:
dec ecx
js irqover
movzx edx, word [esi] ; 2+
test edx, edx ; 1
jz irqover
mov ebx, [edi] ; address of begin of buffer in edi ; + 0x0 dword - data size
mov eax, 4000 ; + 0x4 dword - data begin offset
cmp ebx, eax
je irqfull
add ebx, [edi + 0x4] ; add data size to data begin offset
cmp ebx, eax ; if end of buffer, begin cycle again
jb @f
xor ebx, ebx
@@:
add ebx, edi
movzx eax, byte[esi + 3] ; get type of data being received 1 - byte, 2 - word
dec eax
jz irqbyte
dec eax
jnz noirqword
in ax,dx
cmp ebx, 3999 ; check for address odd in the end of buffer
jne .odd
mov [ebx + 0x10], ax
jmp .add_size
.odd:
mov [ebx + 0x10], al ; I could make mistake here :)
mov [edi + 0x10], ah
.add_size:
add dword [edi], 2
jmp nextport
irqbyte:
in al,dx
mov [ebx + 0x10],al
inc dword [edi]
nextport:
add esi,4
jmp irqnewread
noirqword:
irqfull:
irqover:
ret
set_application_table_status:
push eax
@ -440,7 +272,7 @@ set_application_table_status:
ret
align 4
clear_application_table_status:
push eax
@ -466,6 +298,7 @@ clear_application_table_status:
; * eax = 0 - óñïåøíî
; * eax = 1 - íåäîñòàòî÷íî ïàìÿòè
align 4
sys_resize_app_memory:
; ebx = 1 - resize
; ecx = new amount of memory
@ -487,6 +320,7 @@ endg
; param
; esi= slot
align 4
terminate: ; terminate application
.slot equ esp ;locals
@ -758,25 +592,6 @@ term9:
and [bgrlock], 0
@@:
pusha ; remove all irq reservations
mov eax,esi
shl eax, 5
mov eax,[eax+CURRENT_TASK+TASKDATA.pid]
mov edi,irq_owner
xor ebx, ebx
xor edx, edx
newirqfree:
cmp [edi + 4 * ebx], eax
jne nofreeirq
mov [edi + 4 * ebx], edx ; remove irq reservation
mov [irq_tab + 4 * ebx], edx ; remove irq handler
mov [irq_rights + 4 * ebx], edx ; set access rights to full access
nofreeirq:
inc ebx
cmp ebx, 16
jb newirqfree
popa
pusha ; remove all port reservations
mov edx,esi
shl edx, 5

View File

@ -161,11 +161,11 @@ iglobal
dd syscall_drawline ; 38-DrawLine
dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,.
dd set_app_param ; 40-WantEvents
dd syscall_getirqowner ; 41-GetIrqOwner
dd get_irq_data ; 42-ReadIrqData
dd undefined_syscall ; 41- deprecated GetIrqOwner
dd undefined_syscall ; 42- deprecated ReadIrqData
dd sys_outport ; 43-SendDeviceData
dd sys_programirq ; 44-ProgramIrqs
dd reserve_free_irq ; 45-ReserveIrq and FreeIrq
dd undefined_syscall ; 44- deprecated ProgramIrqs
dd undefined_syscall ; 45- deprecated ReserveIrq and FreeIrq
dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
dd display_number ; 47-WriteNum
dd syscall_display_settings ; 48-SetRedrawType and SetButtonType

View File

@ -49,6 +49,8 @@ keymap_alt:
boot_memdetect db 'Determining amount of memory',0
boot_fonts db 'Fonts loaded',0
boot_tss db 'Setting TSSs',0
boot_cpuid db 'Reading CPUIDs',0
boot_devices db 'Detecting devices',0
boot_setmouse db 'Setting mouse',0
boot_windefs db 'Setting window defaults',0
@ -265,21 +267,6 @@ align 16
cur_saved_data rb 4096
fpu_data: rb 512
; device irq owners
irq_owner rd IRQ_RESERVE ; process id
; on irq read ports
irq00read rd 16 * IRQ_RESERVE
irq_tab rd IRQ_RESERVE
irqh_tab rd LHEAD.sizeof * IRQ_RESERVE / 4
irqh_array rd IRQH.sizeof *48 /4
bogus_irq rd IRQ_RESERVE
next_irqh rd 1
pending_irq_set rd 1
align 16
mem_block_map rb 512
mem_block_list rd 64
large_block_list rd 31
@ -310,6 +297,7 @@ os_stack_seg rd 1
srv.fd rd 1
srv.bk rd 1
align 16
_display display_t

View File

@ -28,3 +28,10 @@ wait_cmos:
jnz wait_cmos
in al,0x71
mov [DRIVE_DATA],al
test al,al
jz @f
in al,0x21
and al,10111111b ; Enable IRQ6
out 0x21,al
@@:

View File

@ -1901,52 +1901,6 @@ dd 1675
* ”㭪樨 à ¡®âë á ᮡëâ¨ï¬¨ ãç¨â뢠îâ ¬ áªã ­  ¬®¬¥­â
¢ë§®¢  ä㭪樨,   ­¥ ­  ¬®¬¥­â ¯®áâ㯫¥­¨ï á®®¡é¥­¨ï.
======================================================================
================= ”ã­ªæ¨ï 41 - 㧭 âì ¢« ¤¥«ìæ  IRQ. =================
======================================================================
<EFBFBD> à ¬¥âàë:
* eax = 41 - ­®¬¥à ä㭪樨
* ebx = ­®¬¥à IRQ, 0..15
‚®§¢à é ¥¬®¥ §­ ç¥­¨¥:
* eax = PID ¢« ¤¥«ìæ 
* eax = 0, ¥á«¨ ¢« ¤¥«ìæ  ­¥â
* eax = -1 ¤«ï ­¥ª®à४⭮£® ebx
======================================================================
========= ”ã­ªæ¨ï 42 - à ¡®â  á ¤ ­­ë¬¨, ¯®«ã祭­ë¬¨ ¯® IRQ. =========
======================================================================
<EFBFBD>ਠ¢®§­¨ª­®¢¥­¨¨ IRQ á¨á⥬  ¬®¦¥â áç¨â뢠âì ¤ ­­ë¥ ¨§ 㪠§ ­­ëå
à ­¥¥ ä㭪樥© 44 ¯®à⮢ ¨ § ¯¨á뢠âì í⨠¤ ­­ë¥ ¢ ¡ãä¥à.
-------------------- <20>®¤äã­ªæ¨ï 0 - ç⥭¨¥ ¤ ­­ëå --------------------
<EFBFBD> à ¬¥âàë:
* eax = 42 - ­®¬¥à ä㭪樨
* bl = ­®¬¥à IRQ, 0..15
* bh = 0 - ­®¬¥à ¯®¤ä㭪樨
* ®áâ «ì­ ï ç áâì ॣ¨áâà  ebx ¤®«¦­  ¡ëâì ®¡­ã«¥­ 
* ecx = 㪠§ â¥«ì ­  ¡ãä¥à à §¬¥à®¬ ­¥ ¬¥­¥¥ 4000 ¡ ©â
‚®§¢à é ¥¬®¥ §­ ç¥­¨¥: (á¨âã æ¨î ¬®¦­® à §«¨ç¨âì ¯® §­ ç¥­¨î eax)
* ¥á«¨ ¯®â®ª ­¥ ï¥âáï ¢« ¤¥«ì楬 IRQ
(¨«¨ ­®¬¥à IRQ § ¤ ­ ­¥¢¥à­®): eax = -1
* ¥á«¨ ¤ ­­ëå ­¥â: eax = 0
* ¥á«¨ ¢áñ ¢ ¯®à浪¥ ¨ ¤ ­­ë¥ ¡ë«¨:
eax = à §¬¥à ¤ ­­ëå, ¯à®ç¨â ­­ëå ¨§ ¡ãä¥à  (¢ ¡ ©â å)
------------ <20>®¤äã­ªæ¨ï 1 - 㧭 âì à §¬¥à ¤ ­­ëå ¢ ¡ãä¥à¥ ------------
<EFBFBD> à ¬¥âàë:
* eax = 42 - ­®¬¥à ä㭪樨
* bl = ­®¬¥à IRQ, 0..15
* bh = 1 - ­®¬¥à ¯®¤ä㭪樨
* ®áâ «ì­ ï ç áâì ॣ¨áâà  ebx ¤®«¦­  ¡ëâì ®¡­ã«¥­ 
‚®§¢à é ¥¬®¥ §­ ç¥­¨¥:
* ¥á«¨ ¯®â®ª ­¥ ï¥âáï ¢« ¤¥«ì楬 IRQ
(¨«¨ ­®¬¥à IRQ § ¤ ­ ­¥¢¥à­®): eax = -1
* ¨­ ç¥ eax = à §¬¥à ¤ ­­ëå ¢ ¡ãä¥à¥
‡ ¬¥ç ­¨ï:
* <20>।¢ à¨â¥«ì­® ¯®â®ª ¤®«¦¥­ § à¥§¥à¢¨à®¢ âì ¤«ï ᥡï 㪠§ ­­ë© IRQ
ä㭪樥© 45.
* <20> §¬¥à ¡ãä¥à  ¤«ï ¤ ­­ëå - 4000 ¡ ©â, ¯à¨ ¯¥à¥¯®«­¥­¨¨
"ᢥ¦¨¥" ¤ ­­ë¥ ¯¥à¥áâ îâ § ¯¨á뢠âìáï ¢ ¡ãä¥à.
======================================================================
=================== ”ã­ªæ¨ï 43 - ¢¢®¤/¢ë¢®¤ ¢ ¯®àâ. ==================
@ -1977,48 +1931,6 @@ dd 1675
¡ëáâ॥ ¨ ­¥áª®«ìª® ª®à®ç¥ ¨ ¯à®é¥. ˆ§ ­¥§ à¥§¥à¢¨à®¢ ­­ëå
¯®à⮢ ç¨â âì ¢áñ à ¢­® ­¥«ì§ï.
======================================================================
======== ”ã­ªæ¨ï 44 - ®¯à¥¤¥«¨âì ¤¥©áâ¢¨ï ¯à¨ ¯®áâ㯫¥­¨¨ IRQ. =======
======================================================================
<EFBFBD>ਠ¢®§­¨ª­®¢¥­¨¨ IRQ á¨á⥬  ¬®¦¥â áç¨â뢠âì ¤ ­­ë¥ ¨§ 㪠§ ­­ëå í⮩
ä㭪樥© ¯®à⮢ ¨ § ¯¨á뢠âì í⨠¤ ­­ë¥ ¢ ¡ãä¥à, ®âªã¤  ¨å ¬®¦­®
¯à®ç¨â âì ä㭪樥© 42.
<EFBFBD> à ¬¥âàë:
* eax = 44 - ­®¬¥à ä㭪樨
* ebx = 㪠§ â¥«ì ­  ¬ áᨢ áâàãªâãà, ®¯¨á뢠îé¨å ¯® ®¤­®¬ã ¯®àâã:
* +0: word: 0 ®§­ ç ¥â ª®­¥æ ¬ áᨢ , ¨­ ç¥ ­®¬¥à ¯®àâ 
* +2: byte: § à¥§¥à¢¨à®¢ ­® (¨£­®à¨àã¥âáï)
* +3: byte: 1=áç¨â뢠âì ¡ ©â ¨§ í⮣® ¯®àâ , 2=áç¨â뢠âì á«®¢®
* ecx = ­®¬¥à IRQ, 0..15
‚®§¢à é ¥¬®¥ §­ ç¥­¨¥:
* eax = 0 - ãᯥ譮
* eax = 1 - ¯®â®ª ­¥ ï¥âáï ¢« ¤¥«ì楬 㪠§ ­­®£® IRQ
‡ ¬¥ç ­¨ï:
* <20>।¢ à¨â¥«ì­® ¯®â®ª ¤®«¦¥­ § à¥§¥à¢¨à®¢ âì §  ᮡ®©
㪠§ë¢ ¥¬ë© IRQ ä㭪樥© 45.
* <20>ਭ¨¬ îâáï ¢® ¢­¨¬ ­¨¥ ⮫쪮 ¯¥à¢ë¥ 16 ¯®à⮢.
* ’¥ªãé ï ॠ«¨§ æ¨ï à áᬠâਢ ¥â ­¥¯à ¢¨«ì­®¥ §­ ç¥­¨¥ ¯®«ï +3
ª ª ᨣ­ « ¯à¥ªà é¥­¨ï ®¡à ¡®âª¨ IRQ.
======================================================================
============ ”ã­ªæ¨ï 45 - § à¥§¥à¢¨à®¢ âì/®á¢®¡®¤¨âì IRQ. ============
======================================================================
<EFBFBD> à ¬¥âàë:
* eax = 45 - ­®¬¥à ä㭪樨
* ebx = 0 - § à¥§¥à¢¨à®¢ âì, 1 = ®á¢®¡®¤¨âì
* ecx = ­®¬¥à IRQ, 0..15
‚®§¢à é ¥¬®¥ §­ ç¥­¨¥:
* eax = 0 - ãᯥ譮
* eax = 1 - ®è¨¡ª  (­¥¢¥à­ë© ­®¬¥à IRQ ¨«¨
¯®¯ë⪠ § à¥§¥à¢¨à®¢ âì ­¥á¢®¡®¤­ë© IRQ ¨«¨ ®á¢®¡®¤¨âì IRQ, ­¥
§ à¥§¥à¢¨à®¢ ­­ë© ⥪ã騬 ¯®â®ª®¬)
‡ ¬¥ç ­¨ï:
* <20>¥§¥à¢¨à®¢ ­¨¥ IRQ ­ã¦­® ¤«ï à ¡®âë ä㭪権 42 ¨ 44.
* ’®«ìª® ®¤¨­ ¯®â®ª ¬®¦¥â § à¥§¥à¢¨à®¢ âì ª®­ªà¥â­ë© IRQ.
* IRQ, ®¡à ¡ â뢠¥¬ë¥ á¨á⥬®© á ¬®áâ®ï⥫쭮, १¥à¢¨àãîâáï
á¨á⥬®© (¯®â®ª®¬ 1) ¯à¨ § £à㧪¥.
* <20>ਠ§ ¢¥à襭¨¨ ¯®â®ª   ¢â®¬ â¨ç¥áª¨ ®á¢®¡®¦¤ îâáï
¢á¥ § à¥§¥à¢¨à®¢ ­­ë¥ ¨¬ IRQ.
======================================================================
= ”ã­ªæ¨ï 46 - § à¥§¥à¢¨à®¢ âì/®á¢®¡®¤¨âì £à㯯㠯®à⮢ ¢¢®¤ /¢ë¢®¤ .

View File

@ -1877,53 +1877,6 @@ Remarks:
* Event functions take into account the mask on moment of
function call, not on moment of event arrival.
======================================================================
==================== Function 41 - get IRQ owner. ====================
======================================================================
Parameters:
* eax = 41 - function number
* ebx = IRQ number, 0..15
Returned value:
* eax = owner PID
* eax = 0, if there is no owner
* eax = -1 for incorrect ebx
======================================================================
================== Function 42 - work with IRQ data. =================
======================================================================
When an IRQ occurs, the system reads data from ports indicated
earlier by function 44 and writes this data to
internal buffer. This function reads out data from that buffer.
--------------------- Subfunction 0 - read data ----------------------
Parameters:
* eax = 42 - function number
* bl = IRQ number, 0..15
* bh = 0 - subfunction number
* rest of ebx must be zeroed
* ecx = pointer to a buffer with size not less than 4000 bytes
Returned value: (use value of eax to distinguish)
* if the thread is not IRQ owner
(or IRQ number is incorrect): eax = -1
* if there is no data: eax = 0
* if all is ok:
eax = size of data read (in bytes)
------------- Subfunction 1 - get size of data in buffer -------------
Parameters:
* eax = 42 - function number
* bl = IRQ number, 0..15
* bh = 0 - subfunction number
* rest of ebx must be zeroed
Returned value:
* if the thread is not IRQ owner
(or IRQ number is incorrect): eax = -1
* otherwise eax = size of data in buffer
Remarks:
* Previously the thread must reserve indicated IRQ for itself
by function 45.
* The size of data buffer is 4000 bytes, on overflow
"fresh" data cease to be written in the buffer.
======================================================================
================ Function 43 - input/output to a port. ===============
@ -1953,48 +1906,6 @@ Remarks:
processor instructions in/out - this is much
faster and a bit shorter and easier.
======================================================================
=========== Function 44 - define operations at IRQ arrival. ==========
======================================================================
At IRQ arrival the system can read the data from ports defined
by this function and write these data to internal buffer, whence
they can be read by ôóíêöèåé 42.
Parameters:
* eax = 44 - function number
* ebx = pointer to the array of structures each describing one port:
* +0: word: 0 means end of array, otherwise port number
* +2: byte: reserved (ignored)
* +3: byte: 1=read byte from this port, 2=read word
* ecx = IRQ number, 0..15
Returned value:
* eax = 0 - success
* eax = 1 - the thread is not owner of selected IRQ
Remarks:
* Previously the thread must reserve for itself selected IRQ
by function 45.
* First 16 ports are considered only.
* The current implementation considers incorrect value of field +3
as a signal to terminate IRQ processing.
======================================================================
=================== Function 45 - reserve/free IRQ. ==================
======================================================================
Parameters:
* eax = 45 - function number
* ebx = 0 - reserve, 1 = free
* ecx = IRQ number, 0..15
Returned value:
* eax = 0 - success
* eax = 1 - error (invalid IRQ number
or attempt to reserve not free IRQ
or to free IRQ, not reserved by this thread)
Remarks:
* IRQ reservation is required for functions 42 and 44.
* Only one thread can reserve the specific IRQ.
* IRQs, handled by the system itself, are reserved by the system
(thread 1) at booting.
* When a thread terminates, all reserved by it IRQs
are freed automatically.
======================================================================
====== Function 46 - reserve/free a group of input/output ports. =====

View File

@ -490,19 +490,24 @@ proc ac97_irq
mov edx, CTRL_STAT
call [ctrl.ctrl_read32]
push eax
cmp eax, 0xffffffff
je .exit
test eax, 0x40
jnz .do_intr
test eax, eax
jz .done
jz .exit
mov edx, CTRL_STAT
call [ctrl.ctrl_write32]
jmp .done
.exit:
xor eax, eax
ret
.do_intr:
push eax
mov edx, PCM_OUT_CR_REG
mov al, 0x10; 0x10
call [ctrl.ctrl_write8]
@ -541,16 +546,16 @@ proc ac97_irq
stdcall [ctrl.user_callback], ebx
.done:
pop eax
; and eax, 0x40
and eax, 0x40
mov edx, CTRL_STAT
call [ctrl.ctrl_write32]
or eax, 1
ret
.skip:
mov edx, PCM_OUT_CR_REG
mov ax, 0x11 ;0x1D
call [ctrl.ctrl_write8]
jmp .done
endp
align 4

View File

@ -2787,7 +2787,7 @@ fs_HdSetFileInfo:
fs_HdDelete:
cmp [fs_type], 1
jz ntfs_HdDelete
cmp [fs_type], 1
cmp [fs_type], 2
jz ext2_HdDelete
cmp [fs_type], 16
jz @f

View File

@ -54,12 +54,14 @@ reserve_cd_channel:
je .reserve_ok_2
sti
call change_task
jmp .IDE_Channel_1
jmp .IDE_Channel_2
.reserve_ok_1:
mov [IDE_Channel_1],1
sti
ret
.reserve_ok_2:
mov [IDE_Channel_2],1
sti
ret
free_cd_channel:

View File

@ -435,10 +435,8 @@ get_event_for_app: ;; used from f10,f11,f23
jz .no_events ; èñ÷åðïàëè âñå áèòû ìàñêè, íî íè÷åãî íå íàøëè ???
btr ecx,eax ; ñáðàñûâàåì ïðîâåðÿåìûé áèò ìàñêè
; ïåðåõîäèì íà îáðàáîò÷èê ýòîãî (eax) áèòà
cmp eax,16
jae .IRQ ; eax=[16..31]=retvals, events irq0..irq15
cmp eax,9
jae .loop ; eax=[9..15], ignored
jae .loop ; eax=[9..31], ignored
cmp eax,3
je .loop ; eax=3, ignored
ja .FlagAutoReset ; eax=[4..8], retvals=eax+1
@ -451,16 +449,7 @@ get_event_for_app: ;; used from f10,f11,f23
.no_events:
xor eax,eax
ret
.IRQ:
;TODO: ñäåëàòü òàê æå, êàê è äëÿ FlagAutoReset (BgrRedraw,Mouse,IPC,Stack,Debug)
mov edx,[irq_owner+eax*4-64] ; eax==16+irq
cmp edx,[edi+TASKDATA.pid]
jne .loop
mov edx,eax
shl edx,12
cmp dword[IRQ_SAVE+edx-0x10000],0 ; edx==(16+irq)*0x1000
je .loop ; empty ???
ret ; retval = eax
.FlagAutoReset: ; retvals: BgrRedraw=5, Mouse=6, IPC=7, Stack=8, Debug=9
cmp eax,5 ; Mouse 5+1=6
jne @f

View File

@ -561,11 +561,6 @@ high_code:
mov [srv.fd], eax
mov [srv.bk], eax
mov edi, irq_tab
xor eax, eax
mov ecx, IRQ_RESERVE
rep stosd
;Set base of graphic segment to linear address of LFB
mov eax,[LFBAddress] ; set for gs
mov [graph_data_l+2],ax
@ -615,11 +610,43 @@ high_code:
call pci_irq_fixup
call unmask_timer
; SET KEYBOARD PARAMETERS
mov al, 0xf6 ; reset keyboard, scan enabled
call kb_write
; wait until 8042 is ready
xor ecx,ecx
@@:
in al,64h
and al,00000010b
loopnz @b
; mov al, 0xED ; Keyboard LEDs - only for testing!
; call kb_write
; call kb_read
; mov al, 111b
; call kb_write
; call kb_read
mov al, 0xF3 ; set repeat rate & delay
call kb_write
; call kb_read
mov al, 0 ; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500
call kb_write
; call kb_read
;// mike.dld [
call set_lights
stdcall attach_int_handler, 1, irq1, 0
;// mike.dld ]
; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15)
; they are used: when partitions are scanned, hd_read relies on timer
call unmask_timer
stdcall enable_irq, 12
stdcall enable_irq, 1
stdcall enable_irq, 6 ; FDD
stdcall enable_irq, 14
stdcall enable_irq, 15
@ -725,12 +752,6 @@ end if
call boot_log
call reserve_irqs_ports
; SET PORTS FOR IRQ HANDLERS
;mov esi,boot_setrports
;call boot_log
;call setirqreadports
; SET UP OS TASK
mov esi,boot_setostask
@ -911,34 +932,6 @@ first_app_found:
push 1
pop dword [CURRENT_TASK] ; set OS task fisrt
; SET KEYBOARD PARAMETERS
mov al, 0xf6 ; reset keyboard, scan enabled
call kb_write
; wait until 8042 is ready
xor ecx,ecx
@@:
in al,64h
and al,00000010b
loopnz @b
; mov al, 0xED ; Keyboard LEDs - only for testing!
; call kb_write
; call kb_read
; mov al, 111b
; call kb_write
; call kb_read
mov al, 0xF3 ; set repeat rate & delay
call kb_write
; call kb_read
mov al, 0 ; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500
call kb_write
; call kb_read
;// mike.dld [
call set_lights
;// mike.dld ]
; Setup serial output console (if enabled)
@ -994,9 +987,7 @@ end if
cli ;guarantee forbidance of interrupts.
stdcall enable_irq, 2 ; @#$%! PIC
stdcall enable_irq, 6 ; FDD
stdcall enable_irq, 13 ; co-processor
stdcall attach_int_handler_ex, 1, irq1, 0
cmp [IDEContrRegsBaseAddr], 0
setnz [dma_hdd]
mov [timer_ticks_enable],1 ; for cd driver
@ -1105,58 +1096,31 @@ include "kernel32.inc"
reserve_irqs_ports:
push eax
xor eax,eax
inc eax
mov byte [irq_owner+4*0],al ;1 ; timer
;mov [irq_owner+4*1], 1 ; keyboard
mov byte [irq_owner+4*6],al ;1 ; floppy diskette
mov byte [irq_owner+4*13],al ;1 ; math co-pros
mov byte [irq_owner+4*14],al ;1 ; ide I
mov byte [irq_owner+4*15],al ;1 ; ide II
pop eax
; RESERVE PORTS
push 4
pop dword [RESERVED_PORTS] ;,edi
mov eax, RESERVED_PORTS
mov ecx, 1
push 1
pop dword [RESERVED_PORTS+16+0] ;,dword 1
and dword [RESERVED_PORTS+16+4],0 ;,dword 0x0
mov dword [RESERVED_PORTS+16+8],0x2d ;,dword 0x2d
mov [eax], dword 4
push 1
pop dword [RESERVED_PORTS+32+0] ;,dword 1
push 0x30
pop dword [RESERVED_PORTS+32+4] ;,dword 0x30
push 0x4d
pop dword [RESERVED_PORTS+32+8] ;,dword 0x4d
mov [eax+16], ecx
mov [eax+16+4], dword 0
mov [eax+16+4], dword 0x2D
push 1
pop dword [RESERVED_PORTS+48+0] ;,dword 1
push 0x50
pop dword [RESERVED_PORTS+48+4] ;,dword 0x50
mov dword [RESERVED_PORTS+48+8],0xdf ;,dword 0xdf
mov [eax+32], ecx
mov [eax+32+4], dword 0x30
mov [eax+32+8], dword 0x4D
push 1
pop dword [RESERVED_PORTS+64+0] ;,dword 1
mov [eax+48], ecx
mov [eax+48+4], dword 0x50
mov [eax+28+8], dword 0xDF
mov dword [RESERVED_PORTS+64+4],0xe5 ;,dword 0xe5
mov dword [RESERVED_PORTS+64+8],0xff ;,dword 0xff
mov [eax+64], ecx
mov [eax+64+4], dword 0xE5
mov [eax+64+8], dword 0xFF
ret
setirqreadports:
mov [irq00read+12*4*16],dword 0x60 + 0x01000000 ; read port 0x60 , byte
and dword [irq00read+12*4*16],0 ; end of port list
; 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
ret
iglobal
process_number dd 0x1
@ -3468,103 +3432,6 @@ memmove: ; memory move in bytes
align 4
sys_programirq:
mov eax, [TASK_BASE]
add ebx, [eax + TASKDATA.mem_start]
cmp ecx, 16
jae .not_owner
mov edi, [eax + TASKDATA.pid]
cmp edi, [irq_owner + 4 * ecx]
je .spril1
.not_owner:
xor ecx, ecx
inc ecx
jmp .end
.spril1:
shl ecx, 6
mov esi, ebx
lea edi, [irq00read + ecx]
push 16
pop ecx
cld
rep movsd
.end:
mov [esp+32], ecx
ret
align 4
get_irq_data:
movzx esi, bh ; save number of subfunction, if bh = 1, return data size, otherwise, read data
xor bh, bh
cmp ebx, 16
jae .not_owner
mov edx, [4 * ebx + irq_owner] ; check for irq owner
mov eax,[TASK_BASE]
cmp edx,[eax+TASKDATA.pid]
je gidril1
.not_owner:
xor edx, edx
dec edx
jmp gid1
gidril1:
shl ebx, 12
lea eax, [ebx + IRQ_SAVE] ; calculate address of the beginning of buffer + 0x0 - data size
mov edx, [eax] ; + 0x4 - data offset
dec esi
jz gid1
test edx, edx ; check if buffer is empty
jz gid1
mov ebx, [eax + 0x4]
mov edi, ecx
mov ecx, 4000 ; buffer size, used frequently
cmp ebx, ecx ; check for the end of buffer, if end of buffer, begin cycle again
jb @f
xor ebx, ebx
@@:
lea esi, [ebx + edx] ; calculate data size and offset
cld
cmp esi, ecx ; if greater than the buffer size, begin cycle again
jbe @f
sub ecx, ebx
sub edx, ecx
lea esi, [eax + ebx + 0x10]
rep movsb
xor ebx, ebx
@@:
lea esi, [eax + ebx + 0x10]
mov ecx, edx
add ebx, edx
rep movsb
mov edx, [eax]
mov [eax], ecx ; set data size to zero
mov [eax + 0x4], ebx ; set data offset
gid1:
mov [esp+32], edx ; eax
ret
set_io_access_rights:
push edi eax
mov edi, tss._io_map_0
@ -3576,13 +3443,13 @@ set_io_access_rights:
; shl ebx,cl
test ebp,ebp
; cmp ebp,0 ; enable access - ebp = 0
jnz siar1
jnz .siar1
; not ebx
; and [edi],byte bl
btr [edi], eax
pop eax edi
ret
siar1:
.siar1:
bts [edi], eax
; or [edi],byte bl ; disable access - ebp = 1
pop eax edi
@ -3737,78 +3604,7 @@ no_mask_io:
ret
reserve_free_irq:
xor esi, esi
inc esi
cmp ecx, 16
jae ril1
push ecx
lea ecx, [irq_owner + 4 * ecx]
mov edx, [ecx] ; IRQ owner PID
mov eax, [TASK_BASE]
mov edi, [eax + TASKDATA.pid] ; current task PID
pop eax
dec ebx
jnz reserve_irq
; free irq
cmp edx, edi ; check owner
jne ril1
dec esi
mov [ecx], esi ; esi = 0
jmp ril1 ; return successful
reserve_irq:
cmp dword [ecx], 0
jne ril1
mov ebx, [f_irqs + 4 * eax]
stdcall attach_int_handler_ex, eax, ebx, dword 0
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
; I don`t known how to use IRQ_RESERVE
if IRQ_RESERVE > 16
dd p_irq16
dd p_irq17
dd p_irq18
dd p_irq19
dd p_irq20
dd p_irq21
dd p_irq22
dd p_irq23
end if
endg
align 4
drawbackground:
inc [mouse_pause]
cmp [SCR_MODE],word 0x12
@ -4836,26 +4632,9 @@ syscall_drawline: ; DrawLine
mov ecx, edx
jmp [draw_line]
align 4
syscall_getirqowner: ; GetIrqOwner
cmp ebx,16
jae .err
cmp [irq_rights + 4 * ebx], dword 2
je .err
mov eax,[4 * ebx + irq_owner]
mov [esp+32],eax
ret
.err:
or dword [esp+32], -1
ret
align 4
syscall_reserveportarea: ; ReservePortArea and FreePortArea
call r_f_port_area
@ -4863,7 +4642,6 @@ syscall_reserveportarea: ; ReservePortArea and FreePortArea
ret
align 4
syscall_threads: ; CreateThreads
; eax=1 create thread
;

View File

@ -222,6 +222,7 @@ include "core/exports.inc"
include "core/string.inc"
include "core/v86.inc" ; virtual-8086 manager
include "core/apic.inc" ; Interrupt Controller functions
include "core/irq.inc" ; irq handling functions
; GUI stuff
include "gui/window.inc"