From d75c968b8e718697599e764841eb072ab7d3c717 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Sun, 24 Jul 2011 07:26:00 +0000 Subject: [PATCH] fix pci irq's git-svn-id: svn://kolibrios.org@2015 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../branches/Kolibri-acpi/bus/pci/pci32.inc | 44 +++++++++++++++++++ kernel/branches/Kolibri-acpi/data32.inc | 3 +- .../branches/Kolibri-acpi/drivers/sound.asm | 34 +++++++++++++- kernel/branches/Kolibri-acpi/gui/mouse.inc | 1 + kernel/branches/Kolibri-acpi/kernel.asm | 6 ++- 5 files changed, 83 insertions(+), 5 deletions(-) diff --git a/kernel/branches/Kolibri-acpi/bus/pci/pci32.inc b/kernel/branches/Kolibri-acpi/bus/pci/pci32.inc index e67afcea92..c88baae37e 100644 --- a/kernel/branches/Kolibri-acpi/bus/pci/pci32.inc +++ b/kernel/branches/Kolibri-acpi/bus/pci/pci32.inc @@ -652,3 +652,47 @@ 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/data32.inc b/kernel/branches/Kolibri-acpi/data32.inc index e89f2c1946..530acda14d 100644 --- a/kernel/branches/Kolibri-acpi/data32.inc +++ b/kernel/branches/Kolibri-acpi/data32.inc @@ -63,7 +63,7 @@ keymap_alt: boot_failed db 'Failed to start first app',0 boot_APIC_found db 'APIC enabled', 0 boot_APIC_nfound db 'APIC not found', 0 - + if preboot_blogesc boot_tasking db 'All set - press ESC to start',0 end if @@ -114,6 +114,7 @@ vmode db '/sys/drivers/VMODE.MDR',0 vrr_m db 'VRR_M',0 kernel_file db 'KERNEL MNT' +dev_data_path db '/RD/1/DRIVERS/DEVICES.DAT',0 align 4 diff --git a/kernel/branches/Kolibri-acpi/drivers/sound.asm b/kernel/branches/Kolibri-acpi/drivers/sound.asm index 9910bf8f86..f4dc59663e 100644 --- a/kernel/branches/Kolibri-acpi/drivers/sound.asm +++ b/kernel/branches/Kolibri-acpi/drivers/sound.asm @@ -334,7 +334,37 @@ proc START stdcall, state:dword mov esi, msgDone call SysMsgBoardStr - stdcall AttachIntHandler, 17, ac97_irq, dword 0 + if IRQ_REMAP + pushf + cli + + mov ebx, [ctrl.int_line] + in al, 0xA1 + mov ah, al + in al, 0x21 + test ebx, ebx + jz .skip + bts ax, bx ;mask old line +.skip + bts ax, IRQ_LINE ;mask new ine + out 0x21, al + mov al, ah + out 0xA1, al + ;remap IRQ + stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE + + mov dx, 0x4d0 ;8259 ELCR1 + in al, dx + bts ax, IRQ_LINE + out dx, al ;set level-triggered mode + mov [ctrl.int_line], IRQ_LINE + popf + mov esi, msgRemap + call SysMsgBoardStr + end if + + mov ebx, [ctrl.int_line] + stdcall AttachIntHandler, ebx, ac97_irq, dword 0 .reg: stdcall RegService, sz_sound_srv, service_proc ret @@ -511,7 +541,7 @@ proc ac97_irq stdcall [ctrl.user_callback], ebx .done: pop eax - and eax, 0x40 +; and eax, 0x40 mov edx, CTRL_STAT call [ctrl.ctrl_write32] ret diff --git a/kernel/branches/Kolibri-acpi/gui/mouse.inc b/kernel/branches/Kolibri-acpi/gui/mouse.inc index f22900c141..ddac7cd88d 100644 --- a/kernel/branches/Kolibri-acpi/gui/mouse.inc +++ b/kernel/branches/Kolibri-acpi/gui/mouse.inc @@ -306,6 +306,7 @@ mouse._.left_button_release_handler: ;///////////////////////////////////////// call sys_window_end_moving_handler .exit: + and [mouse.active_sys_window.action], 0 ret align 4 diff --git a/kernel/branches/Kolibri-acpi/kernel.asm b/kernel/branches/Kolibri-acpi/kernel.asm index b2b5bb628a..66a913c769 100644 --- a/kernel/branches/Kolibri-acpi/kernel.asm +++ b/kernel/branches/Kolibri-acpi/kernel.asm @@ -563,7 +563,7 @@ high_code: mov edi, irq_tab xor eax, eax - mov ecx, 16 + mov ecx, IRQ_RESERVE rep stosd ;Set base of graphic segment to linear address of LFB @@ -613,11 +613,13 @@ 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 stdcall enable_irq, 12 - stdcall enable_irq, 1 + stdcall enable_irq, 1 stdcall enable_irq, 14 stdcall enable_irq, 15