From 000b6ce1cb8848b429527d2d5e9eda32b85559ed Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Wed, 24 Aug 2011 11:01:37 +0000 Subject: [PATCH] shared irq's git-svn-id: svn://kolibrios.org@2112 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/core/dll.inc | 250 +--------------------------------- kernel/trunk/core/exports.inc | 4 +- kernel/trunk/core/sys32.inc | 9 +- kernel/trunk/core/v86.inc | 2 +- kernel/trunk/data32.inc | 6 +- kernel/trunk/kernel.asm | 19 +-- kernel/trunk/kernel32.inc | 2 + 7 files changed, 20 insertions(+), 272 deletions(-) diff --git a/kernel/trunk/core/dll.inc b/kernel/trunk/core/dll.inc index c766cf1a91..3623cdd7e3 100644 --- a/kernel/trunk/core/dll.inc +++ b/kernel/trunk/core/dll.inc @@ -14,189 +14,7 @@ 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 -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, 15 ; hidnplayr says: we only have 16 IRQ's - ja .err - mov eax, [handler] - test eax, eax - jz .err - - mov [irq_tab+ebx*4], eax - stdcall enable_irq, [irq] - pop ebx - mov eax, 1 - popfd - ret -.err: - pop ebx - xor eax, eax - popfd - ret -endp - -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 - -align 4 -proc detach_int_handler - - ret -endp - -align 4 -proc enable_irq stdcall, irq_line:dword - mov ebx, [irq_line] - mov edx, 0x21 - cmp ebx, 8 - jb @F - mov edx, 0xA1 - sub ebx,8 -@@: - in al,dx - btr eax, ebx - out dx, al - ret -endp - -align 16 -;; proc irq_serv - -irq_serv: - -.irq_1: - push 1 - jmp .main -align 4 -.irq_2: - push 2 - jmp .main -align 4 -.irq_3: - push 3 - jmp .main -align 4 -.irq_4: - push 4 - jmp .main -align 4 -.irq_5: - push 5 - jmp .main -align 4 -.irq_6: - push 6 - jmp .main -align 4 -.irq_7: - push 7 - jmp .main -align 4 -.irq_8: - push 8 - jmp .main -align 4 -.irq_9: - push 9 - jmp .main -align 4 -.irq_10: - push 10 - jmp .main -align 4 -.irq_11: - push 11 - jmp .main -align 4 -.irq_12: - push 12 - jmp .main -; align 4 -; .irq_13: -; push 13 -; jmp .main -align 4 -.irq_14: - push 14 - jmp .main -align 4 -.irq_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 - - cmp [v86_irqhooks+eax*8], 0 - jnz v86_irq - - cmp al, 6 - jnz @f - push eax - call [fdc_irq_func] - mov [check_idle_semaphore],5 - pop eax -@@: - - cmp al, 14 - jnz @f - push eax - call [irq14_func] - mov [check_idle_semaphore],5 - pop eax -@@: - cmp al, 15 - jnz @f - push eax - call [irq15_func] - mov [check_idle_semaphore],5 - pop eax -@@: - - mov ebx, [irq_tab+eax*4] - test ebx, ebx - jz .exit - - call ebx - mov [check_idle_semaphore],5 - -.exit: - - cmp dword [esp + 32], 8 - mov al, 0x20 - jb @f - out 0xa0, al -@@: - out 0x20, al - - restore_ring3_context - add esp, 4 - - iret align 4 proc get_notify stdcall, p_ev:dword @@ -803,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 @@ -1626,70 +1445,3 @@ destroy_kernel_object: call free ;release object memory ret - - - -if 0 - -irq: - -.irq0: - pusfd - pushad - push IRQ_0 - jmp .master -.irq_1: - pusfd - pushad - push IRQ_1 - jmp .master - -.master: - mov ax, app_data - mov ds, eax - mov es, eax - mov ebx, [esp+4] ;IRQ_xx - mov eax, [irq_handlers+ebx+4] - call intr_handler - mov ecx, [esp+4] - cmp [irq_actids+ecx*4], 0 - je @F - in al, 0x21 - bts eax, ecx - out 0x21, al - mov al, 0x20 - out 0x20, al - jmp .restart - -.slave: - mov ax, app_data - mov ds, eax - mov es, eax - mov ebx, [esp+4] ;IRQ_xx - mov eax, [irq_handlers+ebx+4] - call intr_handler - mov ecx, [esp+4] - sub ecx, 8 - cmp [irq_actids+ecx*4], 0 - je @F - in al, 0xA1 - bts eax, ecx - out 0xA1, al - mov al, 0x20 - out 0xA0, al - out 0x20, al -.restart: - mov ebx, [next_slot] - test ebx, ebx - jz @F - mov [next_task],0 - mov esi, [prev_slot] - call do_change_task - add esp, 4 - iretd - -end if - - - - diff --git a/kernel/trunk/core/exports.inc b/kernel/trunk/core/exports.inc index ebcd6ca845..278e36565b 100644 --- a/kernel/trunk/core/exports.inc +++ b/kernel/trunk/core/exports.inc @@ -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 @@ -92,7 +92,7 @@ kernel_export: dd szGetService , get_service dd szServiceHandler , srv_handler dd szAttachIntHandler, attach_int_handler - dd szGetIntHandler , get_int_handler +; dd szGetIntHandler , get_int_handler dd szFpuSave , fpu_save dd szFpuRestore , fpu_restore dd szReservePortArea , r_f_port_area diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index 2fa370f009..6b043d2aef 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -39,17 +39,15 @@ iglobal times 12 dd unknown_interrupt ;int_20..int_31 ;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 - times 16 dd unknown_interrupt ;int_0x30..int_0x3F + + times 32 - IRQ_RESERVED dd unknown_interrupt ;int_0x40 gate trap (for directly copied) dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16 @@ -186,6 +184,7 @@ IRetToUserHook: stosd mov [edi], ebx restore_ring3_context +; simply return control to interrupted process unknown_interrupt: iretd diff --git a/kernel/trunk/core/v86.inc b/kernel/trunk/core/v86.inc index d4be975cae..1712da13ca 100644 --- a/kernel/trunk/core/v86.inc +++ b/kernel/trunk/core/v86.inc @@ -328,7 +328,7 @@ v86_start: cmp edx, -1 jz .noirqhook uglobal -v86_irqhooks rd 16*2 +v86_irqhooks rd IRQ_RESERVED * 2 endg cmp [v86_irqhooks+edx*8], 0 jz @f diff --git a/kernel/trunk/data32.inc b/kernel/trunk/data32.inc index ed939c7574..0b177fd35c 100644 --- a/kernel/trunk/data32.inc +++ b/kernel/trunk/data32.inc @@ -98,6 +98,9 @@ if preboot_blogesc end if end if + boot_APIC_found db 'APIC enabled', 0 + boot_APIC_nfound db 'APIC not found', 0 + ;new_process_loading db 'K : New Process - loading',13,10,0 ;new_process_running db 'K : New Process - done',13,10,0 start_not_enough_memory db 'K : New Process - not enough memory',13,10,0 @@ -294,9 +297,6 @@ align 16 cur_saved_data rb 4096 fpu_data: rb 512 -; on irq read ports -irq_tab rd 16 - mem_block_map rb 512 mem_block_list rd 64 large_block_list rd 31 diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 27d7281c65..ddaa0eba07 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -561,11 +561,6 @@ high_code: mov [srv.fd], eax mov [srv.bk], eax - mov edi, irq_tab - xor eax, eax - mov ecx, 16 - rep stosd - ;Set base of graphic segment to linear address of LFB mov eax,[LFBAddress] ; set for gs mov [graph_data_l+2],ax @@ -602,6 +597,7 @@ high_code: ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f + call init_irqs call rerouteirqs ; Initialize system V86 machine @@ -724,12 +720,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 @@ -987,6 +977,7 @@ end if ; START MULTITASKING +; A 'All set - press ESC to start' messages if need if preboot_blogesc mov esi, boot_tasking call boot_log @@ -2302,10 +2293,14 @@ window_minimize db 0 sound_flag db 0 endg +UID_NONE=0 +UID_MENUETOS=1 ;official +UID_KOLIBRI=2 ;russian + iglobal version_inf: db 0,7,7,0 ; version 0.7.7.0 - db 0 ;reserved + db UID_KOLIBRI dd __REV__ version_end: endg diff --git a/kernel/trunk/kernel32.inc b/kernel/trunk/kernel32.inc index 2360d97a2e..6f1bcd8d2e 100644 --- a/kernel/trunk/kernel32.inc +++ b/kernel/trunk/kernel32.inc @@ -221,6 +221,8 @@ include "core/peload.inc" ; 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"