IRQs...

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
kapitan_hak
Posts: 3
Joined: Sat Nov 10, 2007 1:03 pm

IRQs...

Post by kapitan_hak »

Hi!
I have this code:

Code: Select all

void *irq_routines[16] =
{
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0
};

/* This installs a custom IRQ handler for the given IRQ */
void irq_install_handler(int irq, void (*handler)(struct regs *r))
{
    irq_routines[irq] = (void *)handler;
}
//...
void irq_handler(regs *r)
{
    /* This is a blank function pointer */
    void (*handler)(void *r);

    /* Find out if we have a custom handler to run for this
    *  IRQ, and then finally, run it */
    handler = irq_routines[r->int_no - 32];
    if (handler)
    {
        handler(r);
    }
//...
}
My problem is compiler error:
sysapi.cpp:149: error: invalid conversion from ‘void*’ to ‘void (*)(void*)’
Line 149 is "handler = irq_routines[r->int_no - 32]"
How repair this error? Thanks(); :) k_h;
RedEagle
Member
Member
Posts: 31
Joined: Sat Nov 04, 2006 5:38 am
Location: Earth
Contact:

Post by RedEagle »

You have to use a pointer to a function, not a pointer to void.

Here some code from my OS:

Code: Select all

typedef void(*ISR)();

Code: Select all

ISR isr_exception[20];

void nullexp()
{
 rr::LogV1(RRFID_ERROR, "Nicht installierte Exception!\n");
 while(true);
}

//...

for(int i=0; i<20; i++)isr_exception[i] = (ISR)nullexp;
and with

Code: Select all

isr_exceotion[0]();
you can call one of the functions
mfg.: RedEagle
Post Reply