refactored some code. compiles now without suppresing any warning with gcc-6.3.0.
[AROS.git] / rom / kernel / kernel_interruptcontrollers.h
blobb2bc448a4828a1b530bf15fce1c0fe7cec7a91b6
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_Count;
34 ULONG ic_Type; /* IC drivers private "type" */
35 ULONG ic_Flags;
36 APTR ic_Private;
37 icid_t (*ic_Register)(struct KernelBase *); /* one time initialization called during Add */
38 BOOL (*ic_Init)(struct KernelBase *, icid_t); /* */
39 BOOL (*ic_IntrEnable)(APTR, icid_t, icid_t);
40 BOOL (*ic_IntrDisable)(APTR, icid_t, icid_t);
41 BOOL (*ic_IntrAck)(APTR, icid_t, icid_t);
44 struct IntrMapping
46 struct Node im_Node; /* NB - ln_Pri == source IRQ */
47 UBYTE im_IRQ; /* actual IRQ to use */
51 * Interrupt controller needs to re-enable
52 * the interrupt after acknowledging/processing
54 #define ICF_ACKENABLE (1 << 0)
56 #define ICF_READY (1 << 30)
57 #define ICF_DISABLED (1 << 31)
59 static inline struct IntrController *krnGetInterruptController(struct KernelBase *KernelBase, icid_t icid)
61 struct IntrController *intContr;
62 ForeachNode(&KernelBase->kb_ICList, intContr)
64 if (intContr->ic_Node.ln_Type == icid)
66 return intContr;
69 return NULL;
72 /* Functions to be called by machine-specific code */
73 icintrid_t krnAddInterruptController(struct KernelBase *, struct IntrController *);
74 struct IntrController *krnFindInterruptController(struct KernelBase *, ULONG);
75 int krnInitInterruptControllers(struct KernelBase *);
76 BOOL krnInitInterrupt(struct KernelBase *, icid_t, icid_t, icid_t);
77 struct IntrMapping *krnInterruptMapping(struct KernelBase *, icid_t);
78 struct IntrMapping *krnInterruptMapped(struct KernelBase *, icid_t);
80 #endif /* KERNELIRQ_NEEDSCONTROLLERS */
81 #endif /* !KERNEL_INTERRUPTCONTROLLERS_H */