blob: 6e0086015b7960d6fcf20f774caa8a491b41cb6c [file] [log] [blame]
Detlev Zundel3f434df2006-09-01 15:02:06 +02001/*
2 * (C) Copyright 2006
3 * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Detlev Zundel3f434df2006-09-01 15:02:06 +02006 *
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
29static void irq_handler (void *arg);
30
Wolfgang Denk6262d0212010-06-28 22:00:46 +020031int interrupt (int argc, char * const argv[])
Detlev Zundel3f434df2006-09-01 15:02:06 +020032{
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 */
61static void irq_handler (void *arg)
62{
63 /* just for demonstration */
64 printf ("+");
65}