From 4e1ac7b0d6d420771a521f6aa23231ad38093c8e Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Tue, 16 Aug 2011 11:34:07 +0000 Subject: [PATCH] new irq handling git-svn-id: svn://kolibrios.org@2050 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/Kolibri-acpi/core/apic.inc | 16 --- kernel/branches/Kolibri-acpi/core/dll.inc | 111 ++++++++---------- kernel/branches/Kolibri-acpi/core/exports.inc | 2 +- kernel/branches/Kolibri-acpi/core/peload.inc | 2 +- kernel/branches/Kolibri-acpi/data32.inc | 33 +++--- kernel/branches/Kolibri-acpi/kernel.asm | 32 +---- 6 files changed, 72 insertions(+), 124 deletions(-) diff --git a/kernel/branches/Kolibri-acpi/core/apic.inc b/kernel/branches/Kolibri-acpi/core/apic.inc index c3c056153b..72f80ba26e 100644 --- a/kernel/branches/Kolibri-acpi/core/apic.inc +++ b/kernel/branches/Kolibri-acpi/core/apic.inc @@ -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 - diff --git a/kernel/branches/Kolibri-acpi/core/dll.inc b/kernel/branches/Kolibri-acpi/core/dll.inc index 9b04c2fcd3..332ddd81dc 100644 --- a/kernel/branches/Kolibri-acpi/core/dll.inc +++ b/kernel/branches/Kolibri-acpi/core/dll.inc @@ -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 diff --git a/kernel/branches/Kolibri-acpi/core/exports.inc b/kernel/branches/Kolibri-acpi/core/exports.inc index ebcd6ca845..a2fa450e7e 100644 --- a/kernel/branches/Kolibri-acpi/core/exports.inc +++ b/kernel/branches/Kolibri-acpi/core/exports.inc @@ -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 diff --git a/kernel/branches/Kolibri-acpi/core/peload.inc b/kernel/branches/Kolibri-acpi/core/peload.inc index 809926d93f..28e8af7488 100644 --- a/kernel/branches/Kolibri-acpi/core/peload.inc +++ b/kernel/branches/Kolibri-acpi/core/peload.inc @@ -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 diff --git a/kernel/branches/Kolibri-acpi/data32.inc b/kernel/branches/Kolibri-acpi/data32.inc index 8db3689016..558ddfb067 100644 --- a/kernel/branches/Kolibri-acpi/data32.inc +++ b/kernel/branches/Kolibri-acpi/data32.inc @@ -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 diff --git a/kernel/branches/Kolibri-acpi/kernel.asm b/kernel/branches/Kolibri-acpi/kernel.asm index 2bd52bbfa7..bf3102d14b 100644 --- a/kernel/branches/Kolibri-acpi/kernel.asm +++ b/kernel/branches/Kolibri-acpi/kernel.asm @@ -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