interrupt.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  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. #include <common.h>
  35. #include <exports.h>
  36. #include <config.h>
  37. #if defined(CONFIG_MPC5xxx)
  38. #define DFL_IRQ MPC5XXX_IRQ1
  39. #else
  40. #define DFL_IRQ 0
  41. #endif
  42. static void irq_handler (void *arg);
  43. int interrupt (int argc, char *argv[])
  44. {
  45. int c, irq = -1;
  46. app_startup (argv);
  47. if (argc > 1)
  48. irq = simple_strtoul (argv[1], NULL, 0);
  49. if ((irq < 0) || (irq > NR_IRQS))
  50. irq = DFL_IRQ;
  51. printf ("Installing handler for irq vector %d and doing busy wait\n",
  52. irq);
  53. printf ("Press 'q' to quit\n");
  54. /* Install interrupt handler */
  55. install_hdlr (irq, irq_handler, NULL);
  56. while ((c = getc ()) != 'q') {
  57. printf ("Ok, ok, I am still alive!\n");
  58. }
  59. free_hdlr (irq);
  60. printf ("\nInterrupt handler has been uninstalled\n");
  61. return (0);
  62. }
  63. /*
  64. * Handler for interrupt
  65. */
  66. static void irq_handler (void *arg)
  67. {
  68. /* just for demonstration */
  69. printf ("+");
  70. }