2 * AcessOS Microkernel Version
8 #define MAX_CALLBACKS_PER_IRQ 4
12 typedef void (*tIRQ_Callback)(int);
15 void IRQ_Handler(tRegs *Regs);
18 tIRQ_Callback gIRQ_Handlers[16][MAX_CALLBACKS_PER_IRQ];
22 * \fn void IRQ_Handler(tRegs *Regs)
23 * \brief Handle an IRQ
25 void IRQ_Handler(tRegs *Regs)
29 Regs->int_num -= 0xF0; // Adjust
31 //Log("IRQ_Handler: (Regs={int_num:%i})", Regs->int_num);
33 for( i = 0; i < MAX_CALLBACKS_PER_IRQ; i++ )
35 if( gIRQ_Handlers[Regs->int_num][i] ) {
36 gIRQ_Handlers[Regs->int_num][i](Regs->int_num);
38 if( Regs->int_num != 8 )
39 Log("IRQ %i: Call %p", Regs->int_num, gIRQ_Handlers[Regs->int_num][i]);
44 //Log(" IRQ_Handler: Resetting");
45 if(Regs->int_num >= 8)
46 outb(0xA0, 0x20); // ACK IRQ (Secondary PIC)
47 outb(0x20, 0x20); // ACK IRQ
48 //Log("IRQ_Handler: RETURN");
52 * \fn int IRQ_AddHandler( int Num, void (*Callback)(int) )
54 int IRQ_AddHandler( int Num, void (*Callback)(int) )
57 for( i = 0; i < MAX_CALLBACKS_PER_IRQ; i++ )
59 if( gIRQ_Handlers[Num][i] == NULL ) {
60 Log_Log("IRQ", "Added IRQ%i Cb#%i %p", Num, i, Callback);
61 gIRQ_Handlers[Num][i] = Callback;
66 Log_Warning("IRQ", "No free callbacks on IRQ%i", Num);