interrupts.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * (C) Copyright 2006
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * (C) Copyright 2002
  6. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  7. * Marius Groeger <mgroeger@sysgo.de>
  8. *
  9. * (C) Copyright 2002
  10. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  11. * Alex Zuepke <azu@sysgo.de>
  12. *
  13. * See file CREDITS for list of people who contributed to this
  14. * project.
  15. *
  16. * This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License as
  18. * published by the Free Software Foundation; either version 2 of
  19. * the License, or (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  29. * MA 02111-1307 USA
  30. */
  31. #include <common.h>
  32. #include <asm/arch/ixp425.h>
  33. #include <asm/proc-armv/ptrace.h>
  34. struct _irq_handler {
  35. void *m_data;
  36. void (*m_func)( void *data);
  37. };
  38. static struct _irq_handler IRQ_HANDLER[N_IRQS];
  39. static void default_isr(void *data)
  40. {
  41. printf("default_isr(): called for IRQ %d, Interrupt Status=%x PR=%x\n",
  42. (int)data, *IXP425_ICIP, *IXP425_ICIH);
  43. }
  44. static int next_irq(void)
  45. {
  46. return (((*IXP425_ICIH & 0x000000fc) >> 2) - 1);
  47. }
  48. void do_irq (struct pt_regs *pt_regs)
  49. {
  50. int irq = next_irq();
  51. IRQ_HANDLER[irq].m_func(IRQ_HANDLER[irq].m_data);
  52. }
  53. void irq_install_handler (int irq, interrupt_handler_t handle_irq, void *data)
  54. {
  55. if (irq >= N_IRQS || !handle_irq)
  56. return;
  57. IRQ_HANDLER[irq].m_data = data;
  58. IRQ_HANDLER[irq].m_func = handle_irq;
  59. }
  60. int arch_interrupt_init (void)
  61. {
  62. int i;
  63. /* install default interrupt handlers */
  64. for (i = 0; i < N_IRQS; i++)
  65. irq_install_handler(i, default_isr, (void *)i);
  66. /* configure interrupts for IRQ mode */
  67. *IXP425_ICLR = 0x00000000;
  68. return (0);
  69. }