There are already hal private dispatch table functions to deal with this. Please see older HAL commits and the changes in ke/i386/interrupt.c & friends.

Best regards,
Alex Ionescu


On Mon, Sep 5, 2011 at 4:20 PM, <tkreuzer@svn.reactos.org> wrote:
Author: tkreuzer
Date: Mon Sep  5 15:20:07 2011
New Revision: 53600

URL: http://svn.reactos.org/svn/reactos?rev=53600&view=rev
Log:
[HAL]
- Use functions instead of macros for irq<->vector<->irql translation, this will be neccessary, once apic support is there
- Disable mp hal in rbuild for now, its broken anyway

Modified:
   trunk/reactos/hal/halx86/directory.rbuild
   trunk/reactos/hal/halx86/include/hal.h
   trunk/reactos/hal/halx86/include/halirq.h
   trunk/reactos/hal/halx86/up/pic.c

Modified: trunk/reactos/hal/halx86/directory.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/directory.rbuild?rev=53600&r1=53599&r2=53600&view=diff
==============================================================================
--- trunk/reactos/hal/halx86/directory.rbuild [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/directory.rbuild [iso-8859-1] Mon Sep  5 15:20:07 2011
@@ -13,9 +13,9 @@
               <xi:include href="hal.rbuild" />
               <xi:include href="halacpi.rbuild" />
               <xi:include href="halxbox.rbuild" />
-               <if property="BUILD_MP" value="1">
+               <!-- if property="BUILD_MP" value="1">
                       <xi:include href="halmps.rbuild" />
-               </if>
+               </if -->
       </if>

       <if property="ARCH" value="amd64">

Modified: trunk/reactos/hal/halx86/include/hal.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/include/hal.h?rev=53600&r1=53599&r2=53600&view=diff
==============================================================================
--- trunk/reactos/hal/halx86/include/hal.h [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/include/hal.h [iso-8859-1] Mon Sep  5 15:20:07 2011
@@ -55,13 +55,11 @@
 #define TAG_BUS_HANDLER 'BusH'

 /* Internal HAL Headers */
-#include "apic.h"
 #include "bus.h"
 #include "halirq.h"
 #include "haldma.h"
 #include "halp.h"
 #include "mps.h"
-#include "ioapic.h"
 #include "halacpi.h"

 /* EOF */

Modified: trunk/reactos/hal/halx86/include/halirq.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/include/halirq.h?rev=53600&r1=53599&r2=53600&view=diff
==============================================================================
--- trunk/reactos/hal/halx86/include/halirq.h [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/include/halirq.h [iso-8859-1] Mon Sep  5 15:20:07 2011
@@ -4,29 +4,19 @@

 #pragma once

-#ifdef CONFIG_SMP
+UCHAR
+FASTCALL
+HalpIrqToVector(UCHAR Irq);

-#define FIRST_DEVICE_VECTOR    (0x30)
-#define FIRST_SYSTEM_VECTOR    (0xef)
+KIRQL
+FASTCALL
+HalpVectorToIrql(UCHAR Vector);

-#define IRQ_BASE               FIRST_DEVICE_VECTOR
-#define        NR_IRQS                 (FIRST_SYSTEM_VECTOR - FIRST_DEVICE_VECTOR)
+UCHAR
+FASTCALL
+HalpVectorToIrq(UCHAR Vector);

-/*
- * FIXME:
- *   This does not work if we have more than 24 IRQs (ie. more than one I/O APIC)
- */
-#define VECTOR2IRQ(vector)     (23 - (vector - IRQ_BASE) / 8)
-#define VECTOR2IRQL(vector)    (PROFILE_LEVEL - VECTOR2IRQ(vector))
-#define IRQ2VECTOR(irq)                (((23 - (irq)) * 8) + FIRST_DEVICE_VECTOR)
+#define VECTOR2IRQ(vector)     HalpVectorToIrq(vector)
+#define VECTOR2IRQL(vector)    HalpVectorToIrql(vector)
+#define IRQ2VECTOR(irq)                HalpIrqToVector(irq)

-#else
-
-#define IRQ_BASE               (0x30)
-#define        NR_IRQS                 (16)
-
-#define VECTOR2IRQ(vector)     ((vector) - IRQ_BASE)
-#define VECTOR2IRQL(vector)    (PROFILE_LEVEL - VECTOR2IRQ(vector))
-#define IRQ2VECTOR(irq)                ((irq) + IRQ_BASE)
-
-#endif

Modified: trunk/reactos/hal/halx86/up/pic.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/up/pic.c?rev=53600&r1=53599&r2=53600&view=diff
==============================================================================
--- trunk/reactos/hal/halx86/up/pic.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/up/pic.c [iso-8859-1] Mon Sep  5 15:20:07 2011
@@ -512,6 +512,27 @@
    __writeeflags(EFlags);
 }

+UCHAR
+FASTCALL
+HalpIrqToVector(UCHAR Irq)
+{
+    return (PRIMARY_VECTOR_BASE + Irq);
+}
+
+UCHAR
+FASTCALL
+HalpVectorToIrq(UCHAR Vector)
+{
+    return (Vector - PRIMARY_VECTOR_BASE);
+}
+
+KIRQL
+FASTCALL
+HalpVectorToIrql(UCHAR Vector)
+{
+    return (PROFILE_LEVEL - (Vector - PRIMARY_VECTOR_BASE));
+}
+
 /* IRQL MANAGEMENT ************************************************************/

 /*