60 static int nr_of_interrupt_handlers = 0;
67 static void no_interrupt_assert(
struct interrupt *i) { }
68 static void no_interrupt_deassert(
struct interrupt *i) { }
85 #ifdef INTERRUPT_DEBUG 86 printf(
"interrupt_handler_register(\"%s\")\n", templ->
name);
90 for (i=0; i<nr_of_interrupt_handlers; i++) {
91 if (strcmp(templ->
name,
95 fatal(
"\ninterrupt_handler_register(): An interrupt handler" 96 " using the name '%s' is already registered.\n",
101 nr_of_interrupt_handlers ++;
106 interrupt_handlers[nr_of_interrupt_handlers-1].
templ = *
templ;
123 #ifdef INTERRUPT_DEBUG 124 printf(
"interrupt_handler_remove(\"%s\")\n", name);
127 for (i=0; i<nr_of_interrupt_handlers; i++) {
128 if (strcmp(name, interrupt_handlers[i].
templ.
name) != 0)
136 fatal(
"interrupt_handler_remove(): Attempt to " 137 "remove interrupt handler '%s' which has %i " 138 "exclusive and %i non-exclusive users. Aborting.\n",
144 if (i != nr_of_interrupt_handlers-1)
145 memcpy(&interrupt_handlers[i],
146 &interrupt_handlers[i + 1],
147 nr_of_interrupt_handlers - i - 1);
149 nr_of_interrupt_handlers --;
154 fatal(
"interrupt_handler_remove(): '%s' not found? Aborting.\n", name);
170 #ifdef INTERRUPT_DEBUG 171 printf(
"interrupt_handler_lookup(\"%s\")\n", name);
174 if (name[0] ==
'\0') {
176 memset(templ, 0,
sizeof(
struct interrupt));
181 for (i=0; i<nr_of_interrupt_handlers; i++) {
182 if (strcmp(name, interrupt_handlers[i].templ.
name) != 0)
185 *templ = interrupt_handlers[i].
templ;
190 if (i >= nr_of_interrupt_handlers) {
191 printf(
"interrupt_handler_lookup(\"%s\") failed. " 192 "Aborting.\n", name);
209 #ifdef INTERRUPT_DEBUG 210 printf(
"interrupt_connect(\"%s\")\n", in->
name);
213 if (in->
name == NULL || in->
name[0] ==
'\0')
216 for (i=0; i<nr_of_interrupt_handlers; i++) {
223 fatal(
"Fatal error in interrupt_connect(): " 224 "more than 1 exclusive user. Dumping " 225 "core for backtrace.\n");
235 fatal(
"Internal error in interrupt_connect(): name '%s' not " 236 "found? Dumping core for debugging.\n", in->
name);
250 if (in->
name == NULL || in->
name[0] ==
'\0')
253 for (i=0; i<nr_of_interrupt_handlers; i++) {
260 fatal(
"Fatal error in interrupt_disconnect():" 261 "nr of exclusive users < 0?\n");
267 fatal(
"Fatal error in interrupt_disconnect():" 268 "nr of non-exclusive users < 0?\n");
276 fatal(
"Internal error in interrupt_disconnect(): name '%s' not " 277 "found?\n", in->
name);
void fatal(const char *fmt,...)
void(* interrupt_assert)(struct interrupt *)
int nr_of_nonexclusive_users
void(* interrupt_deassert)(struct interrupt *)
int nr_of_exclusive_users
#define CHECK_ALLOCATION(ptr)
void interrupt_handler_remove(const char *name)
int interrupt_handler_lookup(const char *name, struct interrupt *templ)
void interrupt_connect(struct interrupt *in, int exclusive)
void interrupt_handler_register(struct interrupt *templ)
void interrupt_disconnect(struct interrupt *in, int exclusive)