acpi: define IRQ_PIC, IRQ_APIC

git-svn-id: svn://kolibrios.org@2219 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2011-09-21 13:58:48 +00:00
parent e06410d094
commit 71ef7e28cd
6 changed files with 88 additions and 67 deletions

View File

@ -652,47 +652,3 @@ sys_pcibios:
.return_a:
mov dword[esp + 32], eax
ret
align 4
pci_irq_fixup:
push ebp
stdcall load_file, dev_data_path
test eax, eax
jz .fail
push eax
mov esi, eax
lea edi, [eax+ebx]
.iterate:
cmp esi, edi
jae .done
mov eax, [esi]
cmp eax, -1
je .done
movzx ebx, al
movzx ebp, ah
stdcall pci_read32, ebp, ebx, 0
cmp eax, [esi+4]
jne .skip
mov eax, [esi+8]
stdcall pci_write8, ebp, ebx, 0x3C, eax
.skip:
add esi, 16
jmp .iterate
.done:
call kernel_free ;and pop file base from stack
.fail:
pop ebp
ret

View File

@ -143,6 +143,8 @@ SSE_FZ equ 0x8000
SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM)
IRQ_PIC equ 0
IRQ_APIC equ 1
struc TSS
{

View File

@ -8,11 +8,11 @@
IRQ_RESERVED = 24 ; 16 or 24
iglobal
IRQ_COUNT dd 24
IRQ_COUNT dd 24
endg
uglobal
APIC rd 1
irq_mode rd 1
IOAPIC_base rd 1
LAPIC_BASE rd 1
endg
@ -44,15 +44,22 @@ IOAPIC_REDTBL equ 0x10
align 4
APIC_init:
mov dword[APIC], 0
mov [irq_mode], IRQ_PIC
mov eax, [acpi_ioapic_base]
cmp [acpi_ioapic_base], 0
jz .no_apic
cmp [acpi_lapic_base], 0
jz .no_apic
stdcall load_file, dev_data_path
test eax, eax
mov [acpi_dev_data], eax
jz .no_apic
call IRQ_mask_all
; IOAPIC init
; IOAPIC init
stdcall map_io_mem, [acpi_ioapic_base], 0x20, PG_SW
mov [IOAPIC_base], eax
@ -98,15 +105,13 @@ APIC_init:
call LAPIC_init
mov dword[APIC], 0xffffffff
mov [irq_mode], IRQ_APIC
mov al, 0x70
out 0x22, al
mov al, 1
out 0x23, al
; mov dword[irq_type_to_set], IRQ_TYPE_APIC
.no_apic:
;init handlers table
@ -242,6 +247,7 @@ IOAPIC_write:
;===========================================================
; Remap all IRQ to 0x20+ Vectors
; IRQ0 to vector 0x20, IRQ1 to vector 0x21....
align 4
PIC_init:
cli
mov al,0x11 ; icw4, edge triggered
@ -268,6 +274,7 @@ PIC_init:
; -----------------------------------------
; TIMER SET TO 1/100 S
align 4
PIT_init:
mov al,0x34 ; set to 100Hz
out 0x43,al
@ -278,9 +285,11 @@ PIT_init:
ret
; -----------------------------------------
align 4
unmask_timer:
test dword[APIC], 0xffffffff
jnz @f
cmp [irq_mode], IRQ_APIC
je @f
stdcall enable_irq, 0
ret
@@:
@ -306,9 +315,11 @@ unmask_timer:
; -----------------------------------------
; Disable all IRQ
align 4
IRQ_mask_all:
test dword[APIC], 0xffffffff
jnz .APIC
cmp [irq_mode], IRQ_APIC
je .APIC
mov al, 0xFF
out 0x21, al
out 0xA1, al
@ -331,10 +342,10 @@ IRQ_mask_all:
; -----------------------------------------
; End Of Interrupt
; cl - IRQ number
align 16
align 4
irq_eoi: ; __fastcall
test dword[APIC], 0xffffffff
jnz .APIC
cmp [irq_mode], IRQ_APIC
je .APIC
cmp cl, 8
mov al, 0x20
@ -354,8 +365,8 @@ irq_eoi: ; __fastcall
align 4
proc enable_irq stdcall, irq_line:dword
mov ebx, [irq_line]
test dword[APIC], 0xffffffff
jnz .APIC
cmp [irq_mode], IRQ_APIC
je .APIC
mov edx, 0x21
cmp ebx, 8
@ -379,6 +390,44 @@ proc enable_irq stdcall, irq_line:dword
ret
endp
align 4
pci_irq_fixup:
push ebp
mov esi, [acpi_dev_data]
mov ebx, [acpi_dev_size]
lea edi, [esi+ebx]
.iterate:
cmp esi, edi
jae .done
mov eax, [esi]
cmp eax, -1
je .done
movzx ebx, al
movzx ebp, ah
stdcall pci_read32, ebp, ebx, 0
cmp eax, [esi+4]
jne .skip
mov eax, [esi+8]
stdcall pci_write8, ebp, ebx, 0x3C, eax
.skip:
add esi, 16
jmp .iterate
.done:
.fail:
pop ebp
ret
; IRQ_TYPE_DISABLE equ 0

View File

@ -1306,7 +1306,18 @@ end if
mov ecx, 4
repz cmpsd
pop edi
jz .exit
jnz @f
mov edi,eax
mov eax, [edi + BOX.left - 2]
mov ax, word[edi + BOX.left]
add ax, word[edi + BOX.width]
mov ebx, [edi + BOX.top - 2]
mov bx, word[edi + BOX.top]
add bx, word[edi + BOX.height]
xor esi,esi
call draw_rectangle.forced
jmp .exit
@@:
add esp, -BOX.sizeof

View File

@ -437,6 +437,9 @@ acpi_rsdp rd 1
acpi_rsdt rd 1
acpi_madt rd 1
acpi_dev_data rd 1
acpi_dev_size rd 1
acpi_rsdt_base rd 1
acpi_madt_base rd 1
acpi_lapic_base rd 1
@ -514,8 +517,6 @@ align 4
check_acpi:
xchg bx, bx
call acpi_locate
test eax, eax
jz .done

View File

@ -679,10 +679,12 @@ end if
; Display APIC status
mov esi, boot_APIC_found
test dword[APIC], 0xffffffff
jnz @f
cmp [irq_mode], IRQ_APIC
jne @f
mov esi, boot_APIC_nfound
@@: call boot_log
@@:
call boot_log
; PRINT AMOUNT OF MEMORY
mov esi, boot_memdetect