]> git.ipfire.org Git - people/ms/u-boot.git/blob - examples/standalone/interrupt.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[people/ms/u-boot.git] / examples / standalone / interrupt.c
1 /*
2 * (C) Copyright 2006
3 * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 *
7 * This is a very simple standalone application demonstrating
8 * catching IRQs on the MPC52xx architecture.
9 *
10 * The interrupt to be intercepted can be specified as an argument
11 * to the application. Specifying nothing will intercept IRQ1 on the
12 * MPC5200 platform. On the CR825 carrier board from MicroSys this
13 * maps to the ABORT switch :)
14 *
15 * Note that the specified vector is only a logical number specified
16 * by the respective header file.
17 */
18
19 #include <common.h>
20 #include <exports.h>
21 #include <config.h>
22
23 #if defined(CONFIG_MPC5xxx)
24 #define DFL_IRQ MPC5XXX_IRQ1
25 #else
26 #define DFL_IRQ 0
27 #endif
28
29 static void irq_handler (void *arg);
30
31 int interrupt (int argc, char * const argv[])
32 {
33 int c, irq = -1;
34
35 app_startup (argv);
36
37 if (argc > 1)
38 irq = simple_strtoul (argv[1], NULL, 0);
39 if ((irq < 0) || (irq > NR_IRQS))
40 irq = DFL_IRQ;
41
42 printf ("Installing handler for irq vector %d and doing busy wait\n",
43 irq);
44 printf ("Press 'q' to quit\n");
45
46 /* Install interrupt handler */
47 install_hdlr (irq, irq_handler, NULL);
48 while ((c = getc ()) != 'q') {
49 printf ("Ok, ok, I am still alive!\n");
50 }
51
52 free_hdlr (irq);
53 printf ("\nInterrupt handler has been uninstalled\n");
54
55 return (0);
56 }
57
58 /*
59 * Handler for interrupt
60 */
61 static void irq_handler (void *arg)
62 {
63 /* just for demonstration */
64 printf ("+");
65 }