new irq handling

git-svn-id: svn://kolibrios.org@2050 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2011-08-16 11:34:07 +00:00
parent 416dc8b600
commit 4e1ac7b0d6
6 changed files with 72 additions and 124 deletions

View File

@ -575,17 +575,6 @@ proc attach_int_handler_ex stdcall, irq:dword, handler:dword, user_data:dword
mov [ecx+IRQH.handler], edx
mov [ecx+IRQH.data], eax
mov eax, [irqh_set]
bt [pci_irq_set], ebx ;check irq type
jc .pci_irq
.isa_irq:
bts eax, ebx ;check for installed handler
jc .fail
.set_handler:
mov [irqh_set], eax
lea edx, [irqh_tab+ebx*8]
list_add_tail ecx, edx ;clobber eax
@ -598,9 +587,4 @@ proc attach_int_handler_ex stdcall, irq:dword, handler:dword, user_data:dword
mov eax, [.irqh]
ret
.pci_irq:
bts ecx, ebx ;check for installed handler
jmp .set_handler
endp

View File

@ -14,49 +14,6 @@ DRV_CURRENT equ 5 ;current drivers model version
DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT
PID_KERNEL equ 1 ;os_idle thread
align 4
proc attach_int_handler stdcall, irq:dword, handler:dword, access_rights:dword
pushfd
cli
push ebx
mov ebx, [irq] ;irq num
test ebx, ebx
jz .err
cmp ebx, [IRQ_COUNT] ; hidnplayr says: we only have 16 IRQ's
; Ghost says: we can have more...
jae .err
mov eax, [handler]
test eax, eax
jz .err
cmp [irq_owner + 4 * ebx], 0
je @f
mov ecx, [irq_rights + 4 * ebx] ; Rights : 0 - full access, 1 - read only, 2 - forbidden
test ecx, ecx
jnz .err
@@:
mov [irq_tab+ebx*4], eax
mov eax, [access_rights]
mov [irq_rights + 4 * ebx], eax
mov [irq_owner + 4 * ebx], PID_KERNEL ; all handlers belong to a kernel
stdcall enable_irq, [irq]
pop ebx
mov eax, 1
popfd
ret
.err:
pop ebx
xor eax, eax
popfd
ret
endp
uglobal
@ -95,8 +52,8 @@ irq_serv:
; .irq_1:
; push 1
; jmp .main
; etc...
; etc...
macro irq_serv_h [num] {
forward
align 4
@ -115,43 +72,71 @@ end if
align 16
.main:
save_ring3_context
mov eax, [esp + 32]
mov ebp, [esp + 32]
mov bx, app_data ;os_data
mov ds, bx
mov es, bx
cmp [v86_irqhooks+eax*8], 0
cmp [v86_irqhooks+ebp*8], 0
jnz v86_irq
cmp al, 6
cmp bp, 6
jnz @f
push eax
push ebp
call [fdc_irq_func]
pop eax
pop ebp
@@:
cmp al, 14
cmp bp, 14
jnz @f
push eax
push ebp
call [irq14_func]
pop eax
pop ebp
@@:
cmp al, 15
cmp bp, 15
jnz @f
push eax
push ebp
call [irq15_func]
pop eax
pop ebp
@@:
bts [pending_irq_set], ebp
mov ebx, [irq_tab+eax*4]
test ebx, ebx
jz .exit
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
call ebx
mov [check_idle_semaphore],5
push ebx ; FIX THIS
push edi
push esi
.exit: mov eax, [esp + 32]
call IRQ_EOI
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

View File

@ -91,7 +91,7 @@ kernel_export:
dd szRegService , reg_service
dd szGetService , get_service
dd szServiceHandler , srv_handler
dd szAttachIntHandler, attach_int_handler
dd szAttachIntHandler, attach_int_handler_ex
dd szGetIntHandler , get_int_handler
dd szFpuSave , fpu_save
dd szFpuRestore , fpu_restore

View File

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

View File

@ -262,25 +262,29 @@ endofcode:
gdte:
align 16
cur_saved_data rb 4096
fpu_data: rb 512
cur_saved_data rb 4096
fpu_data: rb 512
; device irq owners
irq_owner rd IRQ_RESERVE ; process id
irq_owner rd IRQ_RESERVE ; process id
; on irq read ports
irq00read rd 16 * IRQ_RESERVE
irq_tab rd IRQ_RESERVE
irq00read rd 16 * IRQ_RESERVE
irq_tab rd IRQ_RESERVE
irqh_tab rd LHEAD.sizeof * IRQ_RESERVE / 4
irqh_tab rd LHEAD.sizeof * IRQ_RESERVE / 4
irqh_array rd IRQH.sizeof *48 /4
next_irqh rd 1
irqh_array rd IRQH.sizeof *48 /4
bogus_irq rd IRQ_RESERVE
next_irqh rd 1
pending_irq_set rd 1
mem_block_map rb 512
mem_block_list rd 64
large_block_list rd 31
mem_block_mask rd 2
large_block_mask rd 1
align 16
mem_block_map rb 512
mem_block_list rd 64
large_block_list rd 31
mem_block_mask rd 2
large_block_mask rd 1
mem_used.fd rd 1
mem_used.bk rd 1
@ -306,9 +310,6 @@ os_stack_seg rd 1
srv.fd rd 1
srv.bk rd 1
irqh_set rd 1
pci_irq_set rd 1
align 16
_display display_t

View File

@ -992,33 +992,11 @@ if preboot_blogesc
jne .bll1
end if
; UNMASK ALL IRQ'S
; mov esi,boot_allirqs
; call boot_log
;
; cli ;guarantee forbidance of interrupts.
; mov al,0 ; unmask all irq's
; out 0xA1,al
; out 0x21,al
;
; mov ecx,32
;
; ready_for_irqs:
;
; mov al,0x20 ; ready for irqs
; out 0x20,al
; out 0xa0,al
;
; loop ready_for_irqs ; flush the queue
cli ;guarantee forbidance of interrupts.
stdcall enable_irq, 2 ; @#$%! PIC
stdcall enable_irq, 6 ; FDD
stdcall enable_irq, 13 ; co-processor
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
; mov [dma_hdd],1
cmp [IDEContrRegsBaseAddr], 0
setnz [dma_hdd]
mov [timer_ticks_enable],1 ; for cd driver
@ -3789,7 +3767,7 @@ reserve_free_irq:
mov ebx, [f_irqs + 4 * eax]
stdcall attach_int_handler, eax, ebx, dword 0
stdcall attach_int_handler_ex, eax, ebx, dword 0
mov [ecx], edi