[HAL]: Implement system bus (and ISA) vector/interrupt translation.
authorSir Richard <sir_richard@svn.reactos.org>
Mon, 7 Jun 2010 20:34:41 +0000 (20:34 +0000)
committerSir Richard <sir_richard@svn.reactos.org>
Mon, 7 Jun 2010 20:34:41 +0000 (20:34 +0000)
svn path=/trunk/; revision=47672

reactos/hal/halx86/generic/legacy/bus/sysbus.c

index ab8d292..66e45af 100644 (file)
@@ -29,6 +29,35 @@ HalpTranslateSystemBusAddress(IN PBUS_HANDLER BusHandler,
     return FALSE;
 }
 
+ULONG
+NTAPI
+HalpGetRootInterruptVector(IN ULONG BusInterruptLevel,
+                           IN ULONG BusInterruptVector,
+                           OUT PKIRQL Irql,
+                           OUT PKAFFINITY Affinity)
+{
+    ULONG SystemVector;
+    
+    /* Get the system vector */
+    SystemVector = PRIMARY_VECTOR_BASE + BusInterruptLevel;
+    
+    /* Validate it */
+    if ((SystemVector < PRIMARY_VECTOR_BASE) || (SystemVector > PRIMARY_VECTOR_BASE + 27))
+    {
+        /* Invalid vector */
+        DPRINT1("Vector %lx is too low or too high!\n", SystemVector);
+        return 0;
+    }
+    
+    /* Return the IRQL and affinity */
+    *Irql = (PRIMARY_VECTOR_BASE + 27) - SystemVector;
+    *Affinity = HalpDefaultInterruptAffinity;
+    ASSERT(HalpDefaultInterruptAffinity);
+    
+    /* Return the vector */
+    return SystemVector;
+}
+
 ULONG
 NTAPI
 HalpGetSystemInterruptVector(IN PBUS_HANDLER BusHandler,
@@ -38,10 +67,17 @@ HalpGetSystemInterruptVector(IN PBUS_HANDLER BusHandler,
                              OUT PKIRQL Irql,
                              OUT PKAFFINITY Affinity)
 {
+    ULONG Vector;
+    
     /* Get the root vector */
-    DPRINT1("SYSTEM GetVector\n");
-    while (TRUE);
-    return 0;
+    Vector = HalpGetRootInterruptVector(BusInterruptLevel,
+                                        BusInterruptVector,
+                                        Irql,
+                                        Affinity);
+    
+    /* Check if the vector is owned by the HAL and fail if it is */
+    if (HalpIDTUsageFlags[Vector].Flags & IDT_REGISTERED) DPRINT1("Vector %lx is ALREADY IN USE!\n", Vector);
+    return (HalpIDTUsageFlags[Vector].Flags & IDT_REGISTERED) ? 0 : Vector;
 }
 
 /* EOF */