2 * AcessOS Microkernel Version
8 #define MAX_CALLBACKS_PER_IRQ 4
12 typedef void (*tIRQ_Callback)(int, void *);
15 void IRQ_Handler(tRegs *Regs);
18 tIRQ_Callback gIRQ_Handlers[16][MAX_CALLBACKS_PER_IRQ];
19 void *gaIRQ_DataPointers[16][MAX_CALLBACKS_PER_IRQ];
23 * \fn void IRQ_Handler(tRegs *Regs)
24 * \brief Handle an IRQ
26 void IRQ_Handler(tRegs *Regs)
28 int i, irq = Regs->int_num - 0xF0;
30 //Log("IRQ_Handler: (Regs={int_num:%i})", Regs->int_num);
32 for( i = 0; i < MAX_CALLBACKS_PER_IRQ; i++ )
34 if( gIRQ_Handlers[irq][i] ) {
35 gIRQ_Handlers[irq][i](irq, gaIRQ_DataPointers[irq][i]);
38 Log("IRQ %i: Call %p", Regs->int_num, gIRQ_Handlers[Regs->int_num][i]);
43 //Log(" IRQ_Handler: Resetting");
45 outb(0xA0, 0x20); // ACK IRQ (Secondary PIC)
46 outb(0x20, 0x20); // ACK IRQ
47 //Log("IRQ_Handler: RETURN");
51 * \fn int IRQ_AddHandler( int Num, void (*Callback)(int) )
53 int IRQ_AddHandler( int Num, void (*Callback)(int, void*), void *Ptr )
56 for( i = 0; i < MAX_CALLBACKS_PER_IRQ; i++ )
58 if( gIRQ_Handlers[Num][i] == NULL ) {
59 Log_Log("IRQ", "Added IRQ%i Cb#%i %p", Num, i, Callback);
60 gIRQ_Handlers[Num][i] = Callback;
61 gaIRQ_DataPointers[Num][i] = Ptr;
66 Log_Warning("IRQ", "No free callbacks on IRQ%i", Num);