[ros-diffs] [ion] 24870: - Fix some bugs in the newer IRQL implementation for the HAL (that's still not used because it caused regressions).

ion at svn.reactos.org ion at svn.reactos.org
Mon Nov 27 20:16:24 CET 2006


Author: ion
Date: Mon Nov 27 22:16:24 2006
New Revision: 24870

URL: http://svn.reactos.org/svn/reactos?rev=24870&view=rev
Log:
- Fix some bugs in the newer IRQL implementation for the HAL (that's still not used because it caused regressions).

Modified:
    trunk/reactos/hal/halx86/generic/irq.S

Modified: trunk/reactos/hal/halx86/generic/irq.S
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/irq.S?rev=24870&r1=24869&r2=24870&view=diff
==============================================================================
--- trunk/reactos/hal/halx86/generic/irq.S (original)
+++ trunk/reactos/hal/halx86/generic/irq.S Mon Nov 27 22:16:24 2006
@@ -1,5 +1,5 @@
 /*
- * FILE:            hal/halx86/generic/irql.S
+ * FILE:            hal/halx86/generic/irq.S
  * COPYRIGHT:       See COPYING in the top level directory
  * PURPOSE:         Software, System and Hardware IRQ Management
  * PROGRAMMER:      Alex Ionescu (alex at relsoft.net)
@@ -77,6 +77,8 @@
     .long IRQ15                         /* IRQ 15 */
 .rept 20
     .long GenericIRQ                    /* IRQ 16-35 */
+.rept 172
+    .long InvalidIRQ                    /* IRQ 36-207 */
 .endr
 
 SoftIntByteTable:
@@ -140,7 +142,6 @@
     jnz InitLoop
 
     /* Restore interrupts and return */
-    or dword ptr [esp], EFLAGS_INTERRUPT_MASK
     popf
     pop esi
     ret
@@ -161,7 +162,7 @@
 
     /* Set IRR and get IRQL */
     or [fs:KPCR_IRR], eax
-    mov cl, [fs:KPCR_IRQL]
+    mov ecx, [fs:KPCR_IRQL]
 
     /* Get software IRR mask */
     mov eax, [fs:KPCR_IRR]
@@ -265,7 +266,7 @@
     and [fs:KPCR_IDR], eax
 
     /* Get the current IRQL and mask the IRQs in the PIC */
-    movzx eax, byte ptr [fs:KPCR_IRQL]
+    mov eax, [fs:KPCR_IRQL]
     mov eax, KiI8259MaskTable[eax*4]
     or eax, [fs:KPCR_IDR]
     out 0x21, al
@@ -280,6 +281,7 @@
 Invalid:
 
     /* Fail, invalid IRQ */
+    int 3
     xor eax, eax
     ret 12
 .endfunc
@@ -297,6 +299,7 @@
     /* This is IRQ 15, check if it's spurious */
     mov al, 0xB
     out 0xA0, al
+    jmp $+2
     in al, 0xA0
     test al, 0x80
     jnz GenericIRQ
@@ -311,6 +314,7 @@
     /* This is IRQ 7, check if it's spurious */
     mov al, 0xB
     out 0x20, al
+    jmp $+2
     in al, 0x20
     test al, 0x80
     jnz GenericIRQ
@@ -322,12 +326,12 @@
 GenericIRQ:
     /* Return the current IRQL */
     mov eax, [esp+12]
-    movzx ecx, byte ptr [fs:KPCR_IRQL]
+    mov ecx, [fs:KPCR_IRQL]
     mov [eax], cl
 
     /* Set the new IRQL */
     movzx eax, byte ptr [esp+4]
-    mov [fs:KPCR_IRQL], al
+    mov [fs:KPCR_IRQL], eax
 
     /* Set IRQ mask in the PIC */
     mov eax, KiI8259MaskTable[eax*4]
@@ -337,7 +341,7 @@
     out 0xA1, al
 
     /* Check to which PIC the EOI was sent */
-    mov eax, edx
+    mov eax, ebx
     cmp eax, 8
     jnb Pic1
 
@@ -359,6 +363,11 @@
     sti
     mov eax, 1
     ret 12
+    
+InvalidIRQ:
+    /* Dismiss it */
+    mov eax, 0
+    ret 12
 .endfunc
 
 .globl _HalEndSystemInterrupt at 8
@@ -367,7 +376,7 @@
 
     /* Get the IRQL and check if it's a software interrupt */
     movzx ecx, byte ptr [esp+4]
-    cmp byte ptr [fs:KPCR_IRQL], DISPATCH_LEVEL
+    cmp dword ptr [fs:KPCR_IRQL], DISPATCH_LEVEL
     jbe SkipMask2
 
     /* Hardware interrupt, mask the appropriate IRQs in the PIC */
@@ -380,7 +389,7 @@
 SkipMask2:
 
     /* Set IRQL and check if there are pending software interrupts */
-    mov [fs:KPCR_IRQL], cl
+    mov [fs:KPCR_IRQL], ecx
     mov eax, [fs:KPCR_IRR]
     mov al, SoftIntByteTable[eax]
     cmp al, cl
@@ -404,7 +413,7 @@
 
     /* Disable interrupts and check if IRQL is below DISPATCH_LEVEL */
     movzx ecx, cl
-    cmp byte ptr [fs:KPCR_IRQL], DISPATCH_LEVEL
+    cmp dword ptr [fs:KPCR_IRQL], DISPATCH_LEVEL
     cli
     jbe SkipMask
 
@@ -418,16 +427,18 @@
 SkipMask:
 
     /* Set the new IRQL and check if there's a pending software interrupt */
-    mov [fs:KPCR_IRQL], cl
+    mov [fs:KPCR_IRQL], ecx
     mov eax, [fs:KPCR_IRR]
     mov al, SoftIntByteTable[eax]
     cmp al, cl
-    jbe DoCall3
-
+    ja DoCall3
+
+    /* Restore interrupts and return */
+    popf
+    ret
+DoCall3:
     /* There is, call it */
     call SoftIntHandlerTable[eax*4]
-
-DoCall3:
 
     /* Restore interrupts and return */
     popf
@@ -440,10 +451,9 @@
 @KfRaiseIrql at 4:
 
     /* Get the IRQL and check if it's Software level only */
-    xor eax, eax
-    mov al, [fs:KPCR_IRQL]
+    mov eax, [fs:KPCR_IRQL]
     movzx ecx, cl
-    cmp cl, DISPATCH_LEVEL
+    cmp ecx, DISPATCH_LEVEL
     jbe SetIrql
 
     /* Save the current IRQL */
@@ -471,7 +481,7 @@
 SetIrql:
 
     /* Set the IRQL and return */
-    mov [fs:KPCR_IRQL], cl
+    mov [fs:KPCR_IRQL], ecx
     ret
 .endfunc
 
@@ -480,7 +490,7 @@
 _KeGetCurrentIrql at 0:
 
     /* Return the IRQL */
-    movzx eax, word ptr [fs:KPCR_IRQL]
+    mov eax, [fs:KPCR_IRQL]
     ret
 .endfunc
 
@@ -489,11 +499,10 @@
 _KeRaiseIrqlToDpcLevel at 0:
 
     /* Get the current IRQL */
-    xor eax, eax
-    mov al, [fs:KPCR_IRQL]
+    mov eax, [fs:KPCR_IRQL]
 
     /* Set DISPATCH_LEVEL */
-    mov byte ptr [fs:KPCR_IRQL], DISPATCH_LEVEL
+    mov dword ptr [fs:KPCR_IRQL], DISPATCH_LEVEL
     ret
 .endfunc
 
@@ -513,8 +522,8 @@
     out 0xA1, al
 
     /* Return the old IRQL, enable interrupts and set to DISPATCH */
-    mov al, [fs:KPCR_IRQL]
-    mov byte ptr [fs:KPCR_IRQL], DISPATCH_LEVEL
+    mov eax, [fs:KPCR_IRQL]
+    mov dword ptr [fs:KPCR_IRQL], DISPATCH_LEVEL
     popf
     ret
 .endfunc
@@ -539,7 +548,7 @@
 
     /* Save current IRQL and set to APC level */
     push [fs:KPCR_IRQL]
-    mov byte ptr [fs:KPCR_IRQL], APC_LEVEL
+    mov dword ptr [fs:KPCR_IRQL], APC_LEVEL
     and dword ptr [fs:KPCR_IRR], ~(1 << APC_LEVEL)
 
     /* Enable interrupts and check if we came from User/V86 mode */
@@ -586,7 +595,7 @@
 
     /* Save current IRQL and set to DPC level */
     push [fs:KPCR_IRQL]
-    mov byte ptr [fs:KPCR_IRQL], DISPATCH_LEVEL
+    mov dword ptr [fs:KPCR_IRQL], DISPATCH_LEVEL
     and dword ptr [fs:KPCR_IRR], ~(1 << DISPATCH_LEVEL)
 
     /* Enable interrupts and let the kernel handle this */
@@ -605,7 +614,7 @@
 
     /* Get the IRQL and check if we're in the software region */
     movzx ecx, byte ptr [esp+4]
-    cmp byte ptr [fs:KPCR_IRQL], DISPATCH_LEVEL
+    cmp dword ptr [fs:KPCR_IRQL], DISPATCH_LEVEL
     jbe SoftwareInt
 
     /* Set the right mask in the PIC for the hardware IRQ */
@@ -617,7 +626,7 @@
 
 SoftwareInt:
     /* Check if there are pending software interrupts */
-    mov [fs:KPCR_IRQL], cl
+    mov [fs:KPCR_IRQL], ecx
     mov eax, [fs:KPCR_IRR]
     mov al, SoftIntByteTable[eax]
     cmp al, cl




More information about the Ros-diffs mailing list