separate the interrupt controller header. protect kernel_intr against re-inclusion.
[AROS.git] / rom / kernel / kernel_interruptcontrollers.h
blobfd83e2bd10c6bcea40feec8cb66216250d14b5a4
1 #ifndef KERNEL_INTERRUPTCONTROLLERS_H
2 #define KERNEL_INTERRUPTCONTROLLERS_H
3 /*
4 Copyright © 2017, The AROS Development Team. All rights reserved.
5 $Id$
7 Desc:
8 */
10 #ifdef KERNELIRQ_NEEDSCONTROLLERS
11 #include <inttypes.h>
13 /* Interrupt controller definitions ... */
15 struct IntrInstance;
17 typedef UBYTE icid_t;
18 typedef UWORD icintrid_t;
20 #define ICINTR_ICID(icintr) ((icintr >> 8) & 0xFF)
21 #define ICINTR_INST(icintr) (icintr & 0xFF)
24 * Details:
26 * .ln_Node = "Controller Type" Name - set by the "driver".
27 * .ln_Type = icid_t - value filled in by/returned from krnAddInterruptController.
28 * .ln_Pri = use count - value filled in by/returned from krnAddInterruptController.
30 struct IntrController
32 struct Node ic_Node;
33 ULONG ic_Type; /* IC drivers private "type" */
34 ULONG ic_Flags;
35 APTR ic_Private;
36 icid_t (*ic_Register)(struct KernelBase *); /* one time initialization called during Add */
37 BOOL (*ic_Init)(struct KernelBase *, icid_t); /* */
38 BOOL (*ic_IntrEnable)(APTR, icid_t, icid_t);
39 BOOL (*ic_IntrDisable)(APTR, icid_t, icid_t);
40 BOOL (*ic_IntrAck)(APTR, icid_t, icid_t);
44 * Interrupt controller needs to re-enable
45 * the interrupt after acknowledging/processing
47 #define ICF_ACKENABLE (1 << 0)
49 #define ICF_READY (1 << 30)
50 #define ICF_DISABLED (1 << 31)
52 static inline struct IntrController *krnGetInterruptController(struct KernelBase *KernelBase, icid_t icid)
54 struct IntrController *intContr;
55 ForeachNode(&KernelBase->kb_ICList, intContr)
57 if (intContr->ic_Node.ln_Type == icid)
59 return intContr;
62 return NULL;
65 /* Functions to be called by machine-specific code */
66 icintrid_t krnAddInterruptController(struct KernelBase *, struct IntrController *);
67 struct IntrController *krnFindInterruptController(struct KernelBase *, ULONG);
68 int krnInitInterruptControllers(struct KernelBase *);
69 BOOL krnInitInterrupt(struct KernelBase *, icid_t, icid_t, icid_t);
70 #endif /* KERNELIRQ_NEEDSCONTROLLERS */
71 #endif /* !KERNEL_INTERRUPTCONTROLLERS_H */