mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-26 00:26:52 +03:00
IRQH code
git-svn-id: svn://kolibrios.org@2049 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
50431b95fb
commit
416dc8b600
@ -771,3 +771,27 @@ end virtual
|
||||
virtual at 0
|
||||
CSYM COFF_SYM
|
||||
end virtual
|
||||
|
||||
struc LHEAD
|
||||
{
|
||||
.next dd ? ;next object in list
|
||||
.prev dd ? ;prev object in list
|
||||
.sizeof:
|
||||
}
|
||||
|
||||
virtual at 0
|
||||
LHEAD LHEAD
|
||||
end virtual
|
||||
|
||||
struc IRQH
|
||||
{
|
||||
.list LHEAD
|
||||
.handler dd ? ;handler roututine
|
||||
.data dd ? ;user-specific data
|
||||
.sizeof:
|
||||
}
|
||||
|
||||
virtual at 0
|
||||
IRQH IRQH
|
||||
end virtual
|
||||
|
||||
|
@ -103,6 +103,28 @@ APIC_init:
|
||||
out 0x23, al
|
||||
|
||||
; mov dword[irq_type_to_set], IRQ_TYPE_APIC
|
||||
|
||||
;init handlers table
|
||||
|
||||
mov ecx, IRQ_RESERVE
|
||||
mov edi, irqh_tab
|
||||
@@:
|
||||
mov eax, edi
|
||||
stosd
|
||||
stosd
|
||||
loop @B
|
||||
|
||||
mov ecx, 48
|
||||
mov eax, irqh_array+IRQH.sizeof
|
||||
mov [next_irqh], irqh_array
|
||||
|
||||
@@:
|
||||
mov [eax-IRQH.sizeof], eax
|
||||
add eax, IRQH.sizeof
|
||||
loop @B
|
||||
|
||||
mov [eax-IRQH.sizeof], dword 0
|
||||
|
||||
.no_apic:
|
||||
ret
|
||||
|
||||
@ -491,3 +513,94 @@ endp
|
||||
; popa
|
||||
; ret
|
||||
; 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
|
||||
|
||||
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
|
||||
|
||||
stdcall enable_irq, [irq]
|
||||
|
||||
.fail:
|
||||
popfd
|
||||
.err:
|
||||
pop ebx
|
||||
mov eax, [.irqh]
|
||||
ret
|
||||
|
||||
.pci_irq:
|
||||
bts ecx, ebx ;check for installed handler
|
||||
jmp .set_handler
|
||||
|
||||
endp
|
||||
|
||||
|
@ -271,6 +271,11 @@ irq_owner rd IRQ_RESERVE ; process id
|
||||
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
|
||||
next_irqh rd 1
|
||||
|
||||
mem_block_map rb 512
|
||||
mem_block_list rd 64
|
||||
large_block_list rd 31
|
||||
@ -301,6 +306,8 @@ os_stack_seg rd 1
|
||||
srv.fd rd 1
|
||||
srv.bk rd 1
|
||||
|
||||
irqh_set rd 1
|
||||
pci_irq_set rd 1
|
||||
|
||||
align 16
|
||||
|
||||
|
@ -1017,8 +1017,7 @@ end if
|
||||
stdcall enable_irq, 6 ; FDD
|
||||
stdcall enable_irq, 13 ; co-processor
|
||||
|
||||
stdcall attach_int_handler, dword 1, irq1, dword 0 ; keyboard
|
||||
|
||||
stdcall attach_int_handler_ex, 1, irq1, 0
|
||||
; mov [dma_hdd],1
|
||||
cmp [IDEContrRegsBaseAddr], 0
|
||||
setnz [dma_hdd]
|
||||
|
Loading…
Reference in New Issue
Block a user