acpi: bugfixes

git-svn-id: svn://kolibrios.org@2229 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2011-09-22 12:21:49 +00:00
parent db9a61710d
commit 7e141ac4d8
4 changed files with 352 additions and 482 deletions

View File

@ -5,7 +5,6 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IRQ_RESERVED = 24 ; 16 or 24
iglobal
IRQ_COUNT dd 24
@ -54,9 +53,11 @@ APIC_init:
stdcall load_file, dev_data_path
test eax, eax
mov [acpi_dev_data], eax
jz .no_apic
mov [acpi_dev_data], eax
mov [acpi_dev_size], ebx
call IRQ_mask_all
; IOAPIC init
@ -112,28 +113,9 @@ APIC_init:
mov al, 1
out 0x23, al
call pci_irq_fixup
.no_apic:
;init handlers table
mov ecx, IRQ_RESERVED
mov edi, irqh_tab
@@:
mov eax, edi
stosd
stosd
loop @B
mov ecx, 47
mov eax, irqh_pool+IRQH.sizeof
mov [next_irqh], irqh_pool
@@:
mov [eax-IRQH.sizeof], eax
add eax, IRQH.sizeof
loop @B
mov [eax-IRQH.sizeof], dword 0
ret
;===========================================================
@ -430,137 +412,6 @@ pci_irq_fixup:
ret
; IRQ_TYPE_DISABLE equ 0
; IRQ_TYPE_PIC equ 1
; IRQ_TYPE_APIC equ 2
; uglobal
; irq_type_to_set rd 1
; irq_types rd IRQ_RESERVE
; endg
; -----------------------------------------
; End Of Interrupt
; al - IRQ number
; align 16
; IRQ_EOI:
; movzx eax, al
; cmp dword[irq_types + eax * 4], IRQ_TYPE_APIC
; jne @f
; mov eax, [LAPIC_BASE]
; mov dword [eax + APIC_EOI], 0 ; EOI
; ret
; @@:
; cmp al, 8
; mov al, 0x20
; jb @f
; out 0xa0, al
; @@: out 0x20, al
; ret
; align 4
; proc enable_irq stdcall, irq_line:dword
; cmp dword[irq_type_to_set], IRQ_TYPE_APIC
; jne @f
; stdcall APIC_enable_irq, [irq_line]
; ret
; @@: stdcall PIC_enable_irq, [irq_line]
; ret
; endp
; align 4
; proc disable_irq stdcall, irq_line:dword
; push eax
; mov eax, [irq_line]
; cmp dword[irq_types + eax * 4], IRQ_TYPE_APIC
; jne @f
; stdcall APIC_disable_irq, eax
; pop eax
; ret
; @@: stdcall PIC_disable_irq, eax
; pop eax
; ret
; endp
; align 4
; proc PIC_enable_irq stdcall, irq_line:dword
; pusha
; mov ebx, [irq_line]
; mov eax, [irq_types + ebx * 4]
; cmp eax, IRQ_TYPE_DISABLE
; je @f
; cmp eax, IRQ_TYPE_PIC
; je @f
; stdcall disable_irq, ebx
; @@: mov dword[irq_types + ebx * 4], IRQ_TYPE_PIC
; mov edx, 0x21
; cmp ebx, 8
; jb @F
; mov edx, 0xA1
; sub ebx,8
; @@: in al,dx
; btr eax, ebx
; out dx, al
; popa
; ret
; endp
; align 4
; proc PIC_disable_irq stdcall, irq_line:dword
; pusha
; mov ebx, [irq_line]
; mov dword[irq_types + ebx * 4], IRQ_TYPE_DISABLE
; mov edx, 0x21
; cmp ebx, 8
; jb @F
; mov edx, 0xA1
; sub ebx,8
; @@: in al,dx
; bts eax, ebx
; out dx, al
; popa
; ret
; endp
; align 4
; proc APIC_enable_irq stdcall, irq_line:dword
; pusha
; mov ebx, [irq_line]
; mov eax, [irq_types + ebx * 4]
; cmp eax, IRQ_TYPE_DISABLE
; je @f
; cmp eax, IRQ_TYPE_APIC
; je @f
; stdcall disable_irq, ebx
; @@: mov dword[irq_types + ebx * 4], IRQ_TYPE_APIC
; shl ebx, 1
; add ebx, 0x10
; mov eax, ebx
; call IOAPIC_read
; and eax, 0xfffeffff ; bit 16
; xchg eax, ebx
; call IOAPIC_write
; popa
; ret
; endp
; align 4
; proc APIC_disable_irq stdcall, irq_line:dword
; pusha
; mov ebx, [irq_line]
; mov dword[irq_types + ebx * 4], IRQ_TYPE_DISABLE
; shl ebx, 1
; add ebx, 0x10
; mov eax, ebx
; call IOAPIC_read
; or eax, 0x10000
; xchg eax, ebx
; call IOAPIC_write
; popa
; ret
; endp

View File

@ -5,6 +5,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IRQ_RESERVED equ 24
IRQ_POOL_SIZE equ 48
@ -21,6 +22,29 @@ irq_failed rd IRQ_RESERVED
endg
align 4
init_irqs:
mov ecx, IRQ_RESERVED
mov edi, irqh_tab
@@:
mov eax, edi
stosd
stosd
loop @B
mov ecx, IRQ_POOL_SIZE-1
mov eax, irqh_pool+IRQH.sizeof
mov [next_irqh], irqh_pool
@@:
mov [eax-IRQH.sizeof], eax
add eax, IRQH.sizeof
loop @B
mov [eax-IRQH.sizeof], dword 0
ret
align 4
proc attach_int_handler stdcall, irq:dword, handler:dword, user_data:dword
locals

View File

@ -226,7 +226,7 @@ B32:
mov fs,ax
mov gs,ax
mov ss,ax
mov esp,0x5ec00 ; Set stack
mov esp,0x006CC00 ; Set stack
; CLEAR 0x280000 - HEAP_BASE
@ -236,13 +236,11 @@ B32:
cld
rep stosd
mov edi,0x40000
mov ecx,(0x90000-0x40000)/4
rep stosd
; CLEAR KERNEL UNDEFINED GLOBALS
mov edi, endofcode-OS_BASE
mov ecx, (uglobals_size/4)+4
mov ecx, 0x90000
sub ecx, edi
shr ecx, 2
rep stosd
; SAVE & CLEAR 0-0xffff
@ -604,6 +602,7 @@ high_code:
; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f
call init_irqs
call PIC_init
; Initialize system V86 machine
@ -615,8 +614,6 @@ high_code:
; Try to Initialize APIC
call APIC_init
call pci_irq_fixup
; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15)
; they are used: when partitions are scanned, hd_read relies on timer
call unmask_timer
@ -680,11 +677,9 @@ end if
; Display APIC status
mov esi, boot_APIC_found
cmp [irq_mode], IRQ_APIC
jne @f
je @f
mov esi, boot_APIC_nfound
@@:
call boot_log
; PRINT AMOUNT OF MEMORY
mov esi, boot_memdetect

View File

@ -220,8 +220,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
include "core/apic.inc" ; Interrupt Controller functions
include "core/timers.inc"
; GUI stuff