interrupt.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #include <common.h>
  19. #include <exports.h>
  20. #include <config.h>
  21. #if defined(CONFIG_MPC5xxx)
  22. #define DFL_IRQ MPC5XXX_IRQ1
  23. #else
  24. #define DFL_IRQ 0
  25. #endif
  26. static void irq_handler (void *arg);
  27. int interrupt (int argc, char * const argv[])
  28. {
  29. int c, irq = -1;
  30. app_startup (argv);
  31. if (argc > 1)
  32. irq = simple_strtoul (argv[1], NULL, 0);
  33. if ((irq < 0) || (irq > NR_IRQS))
  34. irq = DFL_IRQ;
  35. printf ("Installing handler for irq vector %d and doing busy wait\n",
  36. irq);
  37. printf ("Press 'q' to quit\n");
  38. /* Install interrupt handler */
  39. install_hdlr (irq, irq_handler, NULL);
  40. while ((c = getc ()) != 'q') {
  41. printf ("Ok, ok, I am still alive!\n");
  42. }
  43. free_hdlr (irq);
  44. printf ("\nInterrupt handler has been uninstalled\n");
  45. return (0);
  46. }
  47. /*
  48. * Handler for interrupt
  49. */
  50. static void irq_handler (void *arg)
  51. {
  52. /* just for demonstration */
  53. printf ("+");
  54. }