shared irq's

git-svn-id: svn://kolibrios.org@2112 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2011-08-24 11:01:37 +00:00
parent c6e0494463
commit 000b6ce1cb
7 changed files with 20 additions and 272 deletions

View File

@ -14,189 +14,7 @@ DRV_CURRENT equ 6 ;current drivers model version
DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT
PID_KERNEL equ 1 ;os_idle thread 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 align 4
proc get_notify stdcall, p_ev:dword proc get_notify stdcall, p_ev:dword
@ -803,6 +621,7 @@ proc fix_coff_relocs stdcall uses ebx esi, coff:dword, sym:dword, \
ret ret
endp endp
align 4
proc rebase_coff stdcall uses ebx esi, coff:dword, sym:dword, \ proc rebase_coff stdcall uses ebx esi, coff:dword, sym:dword, \
delta:dword delta:dword
locals locals
@ -1626,70 +1445,3 @@ destroy_kernel_object:
call free ;release object memory call free ;release object memory
ret 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

View File

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

View File

@ -39,17 +39,15 @@ iglobal
times 12 dd unknown_interrupt ;int_20..int_31 times 12 dd unknown_interrupt ;int_20..int_31
;interrupt handlers addresses (for interrupt gate construction) ;interrupt handlers addresses (for interrupt gate construction)
; 0x20 .. 0x2F - IRQ handlers
dd irq0, irq_serv.irq_1, irq_serv.irq_2 dd irq0, irq_serv.irq_1, irq_serv.irq_2
; if USE_COM_IRQ
dd irq_serv.irq_3, irq_serv.irq_4 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_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_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 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) ;int_0x40 gate trap (for directly copied)
dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16 dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16
@ -186,6 +184,7 @@ IRetToUserHook:
stosd stosd
mov [edi], ebx mov [edi], ebx
restore_ring3_context restore_ring3_context
; simply return control to interrupted process
unknown_interrupt: unknown_interrupt:
iretd iretd

View File

@ -328,7 +328,7 @@ v86_start:
cmp edx, -1 cmp edx, -1
jz .noirqhook jz .noirqhook
uglobal uglobal
v86_irqhooks rd 16*2 v86_irqhooks rd IRQ_RESERVED * 2
endg endg
cmp [v86_irqhooks+edx*8], 0 cmp [v86_irqhooks+edx*8], 0
jz @f jz @f

View File

@ -98,6 +98,9 @@ if preboot_blogesc
end if end if
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_loading db 'K : New Process - loading',13,10,0
;new_process_running db 'K : New Process - done',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 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 cur_saved_data rb 4096
fpu_data: rb 512 fpu_data: rb 512
; on irq read ports
irq_tab rd 16
mem_block_map rb 512 mem_block_map rb 512
mem_block_list rd 64 mem_block_list rd 64
large_block_list rd 31 large_block_list rd 31

View File

@ -561,11 +561,6 @@ high_code:
mov [srv.fd], eax mov [srv.fd], eax
mov [srv.bk], 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 ;Set base of graphic segment to linear address of LFB
mov eax,[LFBAddress] ; set for gs mov eax,[LFBAddress] ; set for gs
mov [graph_data_l+2],ax mov [graph_data_l+2],ax
@ -602,6 +597,7 @@ high_code:
; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f
call init_irqs
call rerouteirqs call rerouteirqs
; Initialize system V86 machine ; Initialize system V86 machine
@ -724,12 +720,6 @@ end if
call boot_log call boot_log
call reserve_irqs_ports call reserve_irqs_ports
; SET PORTS FOR IRQ HANDLERS
;mov esi,boot_setrports
;call boot_log
;call setirqreadports
; SET UP OS TASK ; SET UP OS TASK
mov esi,boot_setostask mov esi,boot_setostask
@ -987,6 +977,7 @@ end if
; START MULTITASKING ; START MULTITASKING
; A 'All set - press ESC to start' messages if need
if preboot_blogesc if preboot_blogesc
mov esi, boot_tasking mov esi, boot_tasking
call boot_log call boot_log
@ -2302,10 +2293,14 @@ window_minimize db 0
sound_flag db 0 sound_flag db 0
endg endg
UID_NONE=0
UID_MENUETOS=1 ;official
UID_KOLIBRI=2 ;russian
iglobal iglobal
version_inf: version_inf:
db 0,7,7,0 ; version 0.7.7.0 db 0,7,7,0 ; version 0.7.7.0
db 0 ;reserved db UID_KOLIBRI
dd __REV__ dd __REV__
version_end: version_end:
endg endg

View File

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