Call CloseDevice() before DeleteIORequest(), and don't call
[AROS.git] / rom / hidds / irq / irqclass.c
blobcec32e3e00294780bdbd4fd66151c1bd61910599
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Legacy IRQ class implementation on top of kernel.resource
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <hidd/irq.h>
11 #include <proto/kernel.h>
13 #include "irq_intern.h"
15 #define KernelBase isd->kernelBase
17 /*** HIDDIRQ::AddHandler() ***************************************/
19 BOOL Irq__Hidd_IRQ__AddHandler(OOP_Class *cl, OOP_Object *obj, struct pHidd_IRQ_AddHandler *msg)
21 UBYTE irqnum;
22 struct irq_staticdata *isd = ISD(cl);
24 D(bug("HIDDIRQ::AddHandler(): handler %s, irq %d\n", msg->handlerinfo->h_Node.ln_Name, msg->id));
27 * Look up machine-specific numbers from a static table (if present).
28 * TODO: kernel.resource can provide us with timer IRQ number sometimes.
29 * May be we should use it ?
30 * Or may be we should query kernel.resource about this table ?
31 * Or may be just declare irq.hidd obsolete ?
33 if (msg->id < 0)
35 /* Negate the index. Now it starts from 1. */
36 irqnum = -msg->id;
38 /* Outside of table? Error if so. */
39 if (irqnum > IRQ_Table[0])
41 D(bug("[HIDDIRQ] IRQ ID %d is outside of table range\n", msg->id));
42 return FALSE;
45 irqnum = IRQ_Table[irqnum];
46 if (irqnum == -1)
48 D(bug("[HIDDIRQ] Table has no mapping for IRQ ID %d \n", msg->id));
49 return FALSE;
52 else
53 irqnum = msg->id;
55 D(bug("Translated IRQ number is %d\n", irqnum));
58 * The interrupts are added through the kernel.resource now. I will store the Handle in
59 * Node structure of HIDDT_IRQ_Handler, which is not used anymore :)
61 msg->handlerinfo->h_Node.ln_Succ = KrnAddIRQHandler(irqnum, msg->handlerinfo->h_Code, msg->handlerinfo, &isd->hwinfo);
63 return msg->handlerinfo->h_Node.ln_Succ ? TRUE : FALSE;
66 /*** HIDDIRQ::RemHandler() ***************************************/
68 VOID Irq__Hidd_IRQ__RemHandler(OOP_Class *cl, OOP_Object *obj, struct pHidd_IRQ_RemHandler *msg)
70 struct irq_staticdata *isd = ISD(cl);
72 D(bug("HIDDIRQ::RemHandler(): handler %s\n", msg->handlerinfo->h_Node.ln_Name));
74 /* If ln_Succ is not empty then it surely points to the Handle returned from KrnAddIRQHandler().
75 * Use it to remove the handler by kernel.resource now */
76 if (msg->handlerinfo && msg->handlerinfo->h_Node.ln_Succ)
78 KrnRemIRQHandler(msg->handlerinfo->h_Node.ln_Succ);
79 msg->handlerinfo->h_Node.ln_Succ = NULL;
82 ReturnVoid("HIDDIRQ::RemHandler");
85 /*** HIDDIRQ::CauseIRQ() *****************************************/
87 VOID Irq__Hidd_IRQ__CauseIRQ(OOP_Class *cl, OOP_Object *obj, struct pHidd_IRQ_CauseIRQ *msg)
89 EnterFunc(bug("HIDDIRQ::CauseIRQ()\n"));
91 /* TODO: Write CauseIRQ method (???) */
93 ReturnVoid("HIDDIRQ::CauseIRQ");