added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / arch / x86_64-pc / irq.hidd / irqclass.c
blob7d62a1ebcf29ca59a4da6ac6a75f810f5e1c5a51
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id: irqclass.c 25081 2006-12-15 17:27:59Z jogr0326 $
5 Desc: IRQ class
6 Lang: english
7 */
9 #include <hidd/irq.h>
11 #include <proto/exec.h>
12 #include <proto/utility.h>
13 #include <proto/oop.h>
14 #include <proto/kernel.h>
16 #include <exec/alerts.h>
17 #include <exec/memory.h>
18 #include <aros/system.h>
20 #include "irq.h"
22 #define DEBUG 0
23 #include <aros/debug.h>
25 /* Don't initialize them with "= 0", otherwise they end up in the DATA segment! */
27 static OOP_AttrBase HiddIRQAttrBase;
29 static struct OOP_ABDescr attrbases[] =
31 { IID_Hidd_IRQ, &HiddIRQAttrBase },
32 { NULL, NULL }
35 /*** HIDDIRQ::AddHandler() ***************************************/
37 BOOL Irq__Hidd_IRQ__AddHandler(OOP_Class *cl, OOP_Object *obj, struct pHidd_IRQ_AddHandler *msg)
39 LONG irqnum = msg->id;
41 EnterFunc(bug("HIDDIRQ::AddHandler()\n"));
42 D(bug("Adding handler %s, irq %d\n",msg->handlerinfo->h_Node.ln_Name, msg->id));
44 if (msg->id < 0)
46 switch (msg->id)
48 case vHidd_IRQ_Timer:
49 irqnum = 0x20;
50 break;
52 case vHidd_IRQ_Keyboard:
53 irqnum = 0x21;
54 break;
56 case vHidd_IRQ_Serial2:
57 irqnum = 0x23;
58 break;
60 case vHidd_IRQ_Serial1:
61 irqnum = 0x24;
62 break;
64 case vHidd_IRQ_Floppy:
65 irqnum = 0x26;
66 break;
68 case vHidd_IRQ_RTC:
69 irqnum = 0x28;
70 break;
72 case vHidd_IRQ_Mouse:
73 irqnum = 0x2c;
74 break;
76 case vHidd_IRQ_HDD1:
77 irqnum = 0x2e;
78 break;
80 case vHidd_IRQ_HDD2:
81 irqnum = 0x2f;
82 break;
85 else if (msg->id >= 0 && msg->id <= 15)
86 irqnum = msg->id + 0x20;
88 D(bug("Translated IRQ number is %d\n", irqnum));
90 if (irqnum >= 0x20 && irqnum <= 0xfe)
92 void *KernelBase = TLS_GET(KernelBase);
93 static HIDDT_IRQ_HwInfo dummy;
94 dummy.sysBase = TLS_GET(SysBase);
95 dummy.Error = 0;
98 * The interrupts are added through the kernel.resource now. I will store the Handle in
99 * Node structure of HIDDT_IRQ_Handler, which is not used anymore :)
101 msg->handlerinfo->h_Node.ln_Succ = KrnAddIRQHandler(irqnum, msg->handlerinfo->h_Code, msg->handlerinfo, &dummy);
103 ReturnInt("HIDDIRQ::AddHandler", ULONG, TRUE);
106 ReturnInt("HIDDIRQ::AddHandler", ULONG, FALSE);
109 /*** HIDDIRQ::RemHandler() ***************************************/
111 VOID Irq__Hidd_IRQ__RemHandler(OOP_Class *cl, OOP_Object *obj, struct pHidd_IRQ_RemHandler *msg)
113 EnterFunc(bug("HIDDIRQ::RemHandler()\n"));
114 D(bug("Removing handler %s\n",msg->handlerinfo->h_Node.ln_Name));
116 void *KernelBase = TLS_GET(KernelBase);
118 /* If ln_Succ is not empty then it surely points to the Handle returned from KrnAddIRQHandler().
119 * Use it to remove the handler by kernel.resource now */
121 if (msg->handlerinfo && msg->handlerinfo->h_Node.ln_Succ)
122 KrnRemIRQHandler(msg->handlerinfo->h_Node.ln_Succ);
124 msg->handlerinfo->h_Node.ln_Succ = NULL;
126 ReturnVoid("HIDDIRQ::RemHandler");
129 /*** HIDDIRQ::CauseIRQ() *****************************************/
131 VOID Irq__Hidd_IRQ__CauseIRQ(OOP_Class *cl, OOP_Object *obj, struct pHidd_CauseIRQ *msg)
133 EnterFunc(bug("HIDDIRQ::CauseIRQ()\n"));
134 #warning TODO: Write CauseIRQ method
135 ReturnVoid("HIDDIRQ::CauseIRQ");