diff --git a/kernel/trunk/core/apic.inc b/kernel/trunk/core/apic.inc new file mode 100644 index 0000000000..755796f10b --- /dev/null +++ b/kernel/trunk/core/apic.inc @@ -0,0 +1,90 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +align 4 +pic_delay: + + jmp pdl1 +pdl1: ret + +align 4 +rerouteirqs: + + cli + + mov al,0x11 ; icw4, edge triggered + out 0x20,al + call pic_delay + out 0xA0,al + call pic_delay + + mov al,0x20 ; generate 0x20 + + out 0x21,al + call pic_delay + mov al,0x28 ; generate 0x28 + + out 0xA1,al + call pic_delay + + mov al,0x04 ; slave at irq2 + out 0x21,al + call pic_delay + mov al,0x02 ; at irq9 + out 0xA1,al + call pic_delay + + mov al,0x01 ; 8086 mode + out 0x21,al + call pic_delay + out 0xA1,al + call pic_delay + + mov al,255 ; mask all irq's + out 0xA1,al + call pic_delay + out 0x21,al + call pic_delay + + mov ecx,0x1000 + cld +picl1: call pic_delay + loop picl1 + + mov al,255 ; mask all irq's + out 0xA1,al + call pic_delay + out 0x21,al + call pic_delay + + ret + + +align 4 +;proc enable_irq stdcall, irq_line:dword +enable_irq: ; FIXME make fastcall + mov ebx, [esp+4] ;irq_line + mov edx, 0x21 + cmp ebx, 8 + jb @F + mov edx, 0xA1 + sub ebx,8 +@@: + in al,dx + btr eax, ebx + out dx, al + ret 4 + + +align 4 +;proc irq_eoi fastcall, irq_line:dword +irq_eoi: + cmp cl, 8 + mov al, 0x20 + jb @f + out 0xa0, al +@@: + out 0x20, al + ret diff --git a/kernel/trunk/core/irq.inc b/kernel/trunk/core/irq.inc index 89ad1d9005..cb9941becb 100644 --- a/kernel/trunk/core/irq.inc +++ b/kernel/trunk/core/irq.inc @@ -143,21 +143,6 @@ proc detach_int_handler ret endp -align 4 -proc enable_irq stdcall, irq_line:dword - mov ebx, [irq_line] - mov edx, 0x21 - cmp ebx, 8 - jb @F - mov edx, 0xA1 - sub ebx,8 -@@: - in al,dx - btr eax, ebx - out dx, al - ret -endp - macro irq_serv_h [num] { forward @@ -246,15 +231,22 @@ align 16 .exit: mov [check_idle_semaphore],5 - cmp bp, 8 - mov al, 0x20 - jb @f - out 0xa0, al -@@: - out 0x20, al + mov ecx, ebp + call irq_eoi restore_ring3_context add esp, 4 iret +align 4 +irqD: + push eax + push ecx + xor eax,eax + out 0xf0,al + mov cl, 13 + call irq_eoi + pop ecx + pop eax + iret diff --git a/kernel/trunk/core/sched.inc b/kernel/trunk/core/sched.inc index 00b4551bca..b95466c966 100644 --- a/kernel/trunk/core/sched.inc +++ b/kernel/trunk/core/sched.inc @@ -27,8 +27,8 @@ irq0: add [next_usage_update],100 call updatecputimes .nocounter: - mov al,0x20 ; send End Of Interrupt signal - out 0x20,al + xor ecx, ecx + call irq_eoi btr dword[DONT_SWITCH], 0 jc .return call find_next_task diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index 6b043d2aef..a05ccbf469 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -120,7 +120,7 @@ exc_c: ; reg_esi equ esp+0x04 reg_edi equ esp+0x00 - Mov ds,ax,app_data ; загрузим правильные значения + Mov ds,ax,app_data ; загрузим правильные значени mov es,ax ; в сегментные регистры cld ; и приводим DF к стандарту movzx ebx,bl @@ -237,18 +237,6 @@ show_error_parameters: restore reg_edi -align 4 -irqD: - push eax - xor eax,eax - out 0xf0,al - mov al,0x20 - out 0xa0,al - out 0x20,al - pop eax - iret - - align 4 set_application_table_status: push eax diff --git a/kernel/trunk/core/v86.inc b/kernel/trunk/core/v86.inc index 1712da13ca..b26bb9e463 100644 --- a/kernel/trunk/core/v86.inc +++ b/kernel/trunk/core/v86.inc @@ -839,6 +839,7 @@ end if ; mov byte [BOOT_VAR + 48Eh], 0FFh ; ret +align 4 v86_irq: ; push irq/pushad/jmp v86_irq ; eax = irq @@ -898,12 +899,8 @@ v86_irq2: pop ecx .cont: loop .scan - mov al, 20h - out 20h, al - cmp edi, 8 - jb @f - out 0A0h, al -@@: + mov ecx, edi + call irq_eoi popad iretd .found: diff --git a/kernel/trunk/drivers/com_mouse.asm b/kernel/trunk/drivers/com_mouse.asm index 4996aae182..eb77ac3bce 100644 --- a/kernel/trunk/drivers/com_mouse.asm +++ b/kernel/trunk/drivers/com_mouse.asm @@ -332,7 +332,7 @@ irq_handler: mov [esi+COM_MOUSE_DATA.MouseByteNumber],0 .EndMouseInterrupt: - + mov al, 1 ret ;all initialized data place here diff --git a/kernel/trunk/drivers/emu10k1x.asm b/kernel/trunk/drivers/emu10k1x.asm index 24e7746cc9..90833e87f4 100644 --- a/kernel/trunk/drivers/emu10k1x.asm +++ b/kernel/trunk/drivers/emu10k1x.asm @@ -524,7 +524,7 @@ proc ac97_irq mov edx, IPR call [ctrl.ctrl_read32] test eax, eax - jz @f + jz @f mov dword [status], eax diff --git a/kernel/trunk/drivers/sb16/sb16.asm b/kernel/trunk/drivers/sb16/sb16.asm index 424c7f9583..70af1896bb 100644 --- a/kernel/trunk/drivers/sb16/sb16.asm +++ b/kernel/trunk/drivers/sb16/sb16.asm @@ -239,7 +239,8 @@ else if sb_buffer_size eq full_buffer stdcall [callback],SB16Buffer0 ;for 64k buffer stdcall [callback],SB16Buffer1 ;for 64k buffer end if - xor eax,eax + xor eax, eax + not eax ret .fill_second_half: @@ -249,7 +250,8 @@ else if sb_buffer_size eq full_buffer stdcall [callback],SB16Buffer2 ;for 64k buffer stdcall [callback],SB16Buffer3 ;for 64k buffer end if - xor eax,eax + xor eax, eax + not eax ret endp ;------------------------------------------------------------------------------- diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 69b7549cc8..a8c93e40da 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -4119,62 +4119,6 @@ _rdtsc: ret end if -rerouteirqs: - - cli - - mov al,0x11 ; icw4, edge triggered - out 0x20,al - call pic_delay - out 0xA0,al - call pic_delay - - mov al,0x20 ; generate 0x20 + - out 0x21,al - call pic_delay - mov al,0x28 ; generate 0x28 + - out 0xA1,al - call pic_delay - - mov al,0x04 ; slave at irq2 - out 0x21,al - call pic_delay - mov al,0x02 ; at irq9 - out 0xA1,al - call pic_delay - - mov al,0x01 ; 8086 mode - out 0x21,al - call pic_delay - out 0xA1,al - call pic_delay - - mov al,255 ; mask all irq's - out 0xA1,al - call pic_delay - out 0x21,al - call pic_delay - - mov ecx,0x1000 - cld -picl1: call pic_delay - loop picl1 - - mov al,255 ; mask all irq's - out 0xA1,al - call pic_delay - out 0x21,al - call pic_delay - - cli - - ret - - -pic_delay: - - jmp pdl1 -pdl1: ret sys_msg_board_str: diff --git a/kernel/trunk/kernel32.inc b/kernel/trunk/kernel32.inc index 6f1bcd8d2e..873c2e3bc6 100644 --- a/kernel/trunk/kernel32.inc +++ b/kernel/trunk/kernel32.inc @@ -221,7 +221,7 @@ 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/apic.inc" ; Interrupt Controller functions include "core/irq.inc" ; irq handling functions ; GUI stuff