2 Copyright © 1995-2018, The AROS Development Team. All rights reserved.
6 #include <proto/arossupport.h>
10 #include "kernel_base.h"
11 #include "kernel_intern.h"
12 #include "kernel_interrupts.h"
13 #include "kernel_debug.h"
20 void ictl_enable_irq(unsigned char irq
, struct KernelBase
*KernelBase
)
22 struct IntrController
*irqIC
;
23 struct KernelInt
*irqInt
= &KernelBase
->kb_Interrupts
[irq
];
25 D(bug("[Kernel] %s(%d)\n", __func__
, irq
));
27 if ((irqIC
= krnGetInterruptController(KernelBase
, irqInt
->ki_List
.lh_Type
)) != NULL
)
29 if ((irqIC
->ic_IntrEnable
) && (irqIC
->ic_IntrEnable(irqIC
->ic_Private
, irqInt
->ki_List
.l_pad
, irq
)))
31 D(bug("[Kernel] %s: controller enabled\n", __func__
));
32 irqInt
->ki_Priv
|= IRQINTF_ENABLED
;
37 D(bug("[Kernel] %s: enabled\n", __func__
));
38 irqInt
->ki_Priv
|= IRQINTF_ENABLED
;
42 void ictl_disable_irq(unsigned char irq
, struct KernelBase
*KernelBase
)
44 struct IntrController
*irqIC
;
45 struct KernelInt
*irqInt
= &KernelBase
->kb_Interrupts
[irq
];
47 D(bug("[Kernel] %s(%d)\n", __func__
, irq
));
49 if ((irqIC
= krnGetInterruptController(KernelBase
, irqInt
->ki_List
.lh_Type
)) != NULL
)
51 if ((irqIC
->ic_IntrDisable
) && (irqIC
->ic_IntrDisable(irqIC
->ic_Private
, irqInt
->ki_List
.l_pad
, irq
)))
53 D(bug("[Kernel] %s: controller disabled\n", __func__
));
54 irqInt
->ki_Priv
&= ~IRQINTF_ENABLED
;
59 D(bug("[Kernel] %s: disabled\n", __func__
));
60 irqInt
->ki_Priv
&= ~IRQINTF_ENABLED
;
64 BOOL
ictl_is_irq_enabled(unsigned char irq
, struct KernelBase
*KernelBase
)
66 struct KernelInt
*irqInt
= &KernelBase
->kb_Interrupts
[irq
];
68 D(bug("[Kernel] %s(%d)\n", __func__
, irq
));
70 return (BOOL
)(irqInt
->ki_Priv
& IRQINTF_ENABLED
);
73 void ictl_Initialize(struct KernelBase
*KernelBase
)
75 struct PlatformData
*pdata
= KernelBase
->kb_PlatformData
;
77 struct TagItem
*cmdTags
;
79 D(bug("[Kernel] %s()\n", __func__
));
83 /* No APIC was discovered by ACPI/whatever else. Do the probe. */
84 cmdTags
= LibFindTagItem(KRN_CmdLine
, BootMsg
);
85 if (cmdTags
&& strstr((const char *)cmdTags
->ti_Data
, "noapic"))
86 D(bug("[Kernel] %s: APIC support disabled\n", __func__
));
89 D(bug("[Kernel] %s(): probing for APIC\n", __func__
));
90 pdata
->kb_APIC
= core_APIC_Probe();
97 /* We are x86-64, so we should always have APIC. */
98 krnPanic(KernelBase
, "Failed to allocate APIC descriptor.");
102 /* Check if the 8259A has already been registered, if not probe for it */
103 if (!krnFindInterruptController(KernelBase
, ICTYPE_I8259A
))
105 D(__unused icintrid_t xtpicICInstID
;)
107 D(bug("[Kernel] %s(): probing for PIC\n", __func__
));
110 D(xtpicICInstID
=) krnAddInterruptController(KernelBase
, &i8259a_IntrController
);
114 if ((cnt
= krnInitInterruptControllers(KernelBase
)) > 0)
116 D(bug("[Kernel] %s: %d Interrupt Controllers Initialized\n", __func__
, cnt
));
120 krnPanic(KernelBase
, "Failed to detect any Interrupt Controllers.");