From 71ef7e28cd974a87ceec1cb58566838d95d998b5 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Wed, 21 Sep 2011 13:58:48 +0000 Subject: [PATCH] acpi: define IRQ_PIC, IRQ_APIC git-svn-id: svn://kolibrios.org@2219 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../branches/Kolibri-acpi/bus/pci/pci32.inc | 44 ---------- kernel/branches/Kolibri-acpi/const.inc | 2 + kernel/branches/Kolibri-acpi/core/apic.inc | 83 +++++++++++++++---- kernel/branches/Kolibri-acpi/gui/window.inc | 13 ++- kernel/branches/Kolibri-acpi/init.inc | 5 +- kernel/branches/Kolibri-acpi/kernel.asm | 8 +- 6 files changed, 88 insertions(+), 67 deletions(-) diff --git a/kernel/branches/Kolibri-acpi/bus/pci/pci32.inc b/kernel/branches/Kolibri-acpi/bus/pci/pci32.inc index c88baae37e..e67afcea92 100644 --- a/kernel/branches/Kolibri-acpi/bus/pci/pci32.inc +++ b/kernel/branches/Kolibri-acpi/bus/pci/pci32.inc @@ -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 diff --git a/kernel/branches/Kolibri-acpi/const.inc b/kernel/branches/Kolibri-acpi/const.inc index 885bf688e2..7f7b446c5f 100644 --- a/kernel/branches/Kolibri-acpi/const.inc +++ b/kernel/branches/Kolibri-acpi/const.inc @@ -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 { diff --git a/kernel/branches/Kolibri-acpi/core/apic.inc b/kernel/branches/Kolibri-acpi/core/apic.inc index 5970ae6700..e4ab5486e5 100644 --- a/kernel/branches/Kolibri-acpi/core/apic.inc +++ b/kernel/branches/Kolibri-acpi/core/apic.inc @@ -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 diff --git a/kernel/branches/Kolibri-acpi/gui/window.inc b/kernel/branches/Kolibri-acpi/gui/window.inc index 2cb04f94ad..3ed545ab66 100644 --- a/kernel/branches/Kolibri-acpi/gui/window.inc +++ b/kernel/branches/Kolibri-acpi/gui/window.inc @@ -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 diff --git a/kernel/branches/Kolibri-acpi/init.inc b/kernel/branches/Kolibri-acpi/init.inc index 75b5f55222..80a070b2bc 100644 --- a/kernel/branches/Kolibri-acpi/init.inc +++ b/kernel/branches/Kolibri-acpi/init.inc @@ -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 diff --git a/kernel/branches/Kolibri-acpi/kernel.asm b/kernel/branches/Kolibri-acpi/kernel.asm index 67451bb259..95462d8c92 100644 --- a/kernel/branches/Kolibri-acpi/kernel.asm +++ b/kernel/branches/Kolibri-acpi/kernel.asm @@ -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