blob: f3061d1ec038ada1764e9c3bead01dbd4ae1d3c4 [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 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 *
23 * This is a very simple standalone application demonstrating
24 * catching IRQs on the MPC52xx architecture.
25 *
26 * The interrupt to be intercepted can be specified as an argument
27 * to the application. Specifying nothing will intercept IRQ1 on the
28 * MPC5200 platform. On the CR825 carrier board from MicroSys this
29 * maps to the ABORT switch :)
30 *
31 * Note that the specified vector is only a logical number specified
32 * by the respective header file.
33 */
34
35#include <common.h>
36#include <exports.h>
37#include <config.h>
38
39#if defined(CONFIG_MPC5xxx)
40#define DFL_IRQ MPC5XXX_IRQ1
41#else
42#define DFL_IRQ 0
43#endif
44
45static void irq_handler (void *arg);
46
47int interrupt (int argc, char *argv[])
48{
49 int c, irq = -1;
50
51 app_startup (argv);
52
53 if (argc > 1)
54 irq = simple_strtoul (argv[1], NULL, 0);
55 if ((irq < 0) || (irq > NR_IRQS))
56 irq = DFL_IRQ;
57
58 printf ("Installing handler for irq vector %d and doing busy wait\n",
59 irq);
60 printf ("Press 'q' to quit\n");
61
62 /* Install interrupt handler */
63 install_hdlr (irq, irq_handler, NULL);
64 while ((c = getc ()) != 'q') {
65 printf ("Ok, ok, I am still alive!\n");
66 }
67
68 free_hdlr (irq);
69 printf ("\nInterrupt handler has been uninstalled\n");
70
71 return (0);
72}
73
74/*
75 * Handler for interrupt
76 */
77static void irq_handler (void *arg)
78{
79 /* just for demonstration */
80 printf ("+");
81}