Attaching a low-level handler

Top  Previous  Next

You attach a low-level handler to an interrupt selector using c6xint_attach_handler:

 

c6xint_attach_handler

#include <c6xint.h>

int c6xint_attach_handler(int sel, struct c6xint_ICB *MyICB);

 stand-alone


Sel 

selects the interrupt to which the handler must be attached. It must be in the range 4 ≤ Sel ≤ 15

MyICB

is a pointer to an c6xint_ICB structure that has already had its Arg and Handler fields initialised; this structure must continue to exist for the rest of the execution of your application. Once attached, the ICB cannot be removed from the list of handlers for the interrupt. Attaching a handler does not enable the associated interrupt in IER; you must do this explicitly at the appropriate time after the attachment.

 

Handler

This must be the address of a handler function, written in assembler to the requirements described below.

Arg

The address of a data structure that is passed into the hander function in register a2.

 

Note that all handlers attached to an interrupt are invoked. It is the responsibility of each handler to check that the device it is controlling is the one that has provoked the interrupt.

 

For example:

 

extern void MyInt12Handler(void);     // the interrupt handler

static struct c6xint_ICB MyInt12ICB;

static int Parameters[3] = {000}; // depends on the handler

...

MyInt12ICB.Arg     = Parameters;

MyInt12ICB.Handler = (void *)MyInt12Handler;

c6xint_attach_handler(12, &MyInt12ICB);

 

// now enable interrupt 12...

 

When interrupt 12 occurs, the handler is be called and register a2 contains the address of the array Parameters.