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: .return_a:
mov dword[esp + 32], eax mov dword[esp + 32], eax
ret 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) 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 struc TSS
{ {

View File

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

View File

@ -1306,7 +1306,18 @@ end if
mov ecx, 4 mov ecx, 4
repz cmpsd repz cmpsd
pop edi 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 add esp, -BOX.sizeof

View File

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

View File

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