3 * Graeme Russ, <graeme.russ@gmail.com>
6 * Daniel Hellstrom, Gaisler Research, <daniel@gaisler.com>
9 * Detlev Zundel, DENX Software Engineering, <dzu@denx.de>
12 * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
15 * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
18 * Josh Huber, Mission Critical Linux, Inc, <huber@mclx.com>
20 * SPDX-License-Identifier: GPL-2.0+
24 * This file contains the high-level API for the interrupt sub-system
25 * of the x86 port of U-Boot. Most of the functionality has been
26 * shamelessly stolen from the leon2 / leon3 ports of U-Boot.
27 * Daniel Hellstrom, Detlev Zundel, Wolfgang Denk and Josh Huber are
28 * credited for the corresponding work on those ports. The original
29 * interrupt handling routines for the x86 port were written by
34 #include <asm/interrupt.h>
37 interrupt_handler_t *handler;
42 static struct irq_action irq_handlers[CONFIG_SYS_NUM_IRQS] = { {0} };
43 static int spurious_irq_cnt;
44 static int spurious_irq;
46 void irq_install_handler(int irq, interrupt_handler_t *handler, void *arg)
50 if (irq < 0 || irq >= CONFIG_SYS_NUM_IRQS) {
51 printf("irq_install_handler: bad irq number %d\n", irq);
55 if (irq_handlers[irq].handler != NULL)
56 printf("irq_install_handler: 0x%08lx replacing 0x%08lx\n",
58 (ulong) irq_handlers[irq].handler);
60 status = disable_interrupts();
62 irq_handlers[irq].handler = handler;
63 irq_handlers[irq].arg = arg;
64 irq_handlers[irq].count = 0;
74 void irq_free_handler(int irq)
78 if (irq < 0 || irq >= CONFIG_SYS_NUM_IRQS) {
79 printf("irq_free_handler: bad irq number %d\n", irq);
83 status = disable_interrupts();
87 irq_handlers[irq].handler = NULL;
88 irq_handlers[irq].arg = NULL;
96 void do_irq(int hw_irq)
98 int irq = hw_irq - 0x20;
100 if (irq < 0 || irq >= CONFIG_SYS_NUM_IRQS) {
101 printf("do_irq: bad irq number %d\n", irq);
105 if (irq_handlers[irq].handler) {
108 irq_handlers[irq].handler(irq_handlers[irq].arg);
109 irq_handlers[irq].count++;
115 if ((irq & 7) != 7) {
122 #if defined(CONFIG_CMD_IRQ)
123 int do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
127 printf("Spurious IRQ: %u, last unknown IRQ: %d\n",
128 spurious_irq_cnt, spurious_irq);
130 printf("Interrupt-Information:\n");
131 printf("Nr Routine Arg Count\n");
133 for (irq = 0; irq <= CONFIG_SYS_NUM_IRQS; irq++) {
134 if (irq_handlers[irq].handler != NULL) {
135 printf("%02d %08lx %08lx %d\n",
137 (ulong)irq_handlers[irq].handler,
138 (ulong)irq_handlers[irq].arg,
139 irq_handlers[irq].count);