irq.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. *
  3. * linux/arch/cris/kernel/irq.c
  4. *
  5. * Copyright (c) 2000,2001 Axis Communications AB
  6. *
  7. * Authors: Bjorn Wesen (bjornw@axis.com)
  8. *
  9. * This file contains the code used by various IRQ handling routines:
  10. * asking for different IRQ's should be done through these routines
  11. * instead of just grabbing them. Thus setups with different IRQ numbers
  12. * shouldn't result in any weird surprises, and installing new handlers
  13. * should be easier.
  14. *
  15. */
  16. /*
  17. * IRQ's are in fact implemented a bit like signal handlers for the kernel.
  18. * Naturally it's not a 1:1 relation, but there are similarities.
  19. */
  20. #include <linux/config.h>
  21. #include <linux/module.h>
  22. #include <linux/ptrace.h>
  23. #include <linux/irq.h>
  24. #include <linux/kernel_stat.h>
  25. #include <linux/signal.h>
  26. #include <linux/sched.h>
  27. #include <linux/ioport.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/timex.h>
  30. #include <linux/slab.h>
  31. #include <linux/random.h>
  32. #include <linux/init.h>
  33. #include <linux/seq_file.h>
  34. #include <linux/errno.h>
  35. #include <linux/spinlock.h>
  36. #include <asm/io.h>
  37. void ack_bad_irq(unsigned int irq)
  38. {
  39. printk("unexpected IRQ trap at vector %02x\n", irq);
  40. }
  41. int show_interrupts(struct seq_file *p, void *v)
  42. {
  43. int i = *(loff_t *) v, j;
  44. struct irqaction * action;
  45. unsigned long flags;
  46. if (i == 0) {
  47. seq_printf(p, " ");
  48. for (j=0; j<NR_CPUS; j++)
  49. if (cpu_online(j))
  50. seq_printf(p, "CPU%d ",j);
  51. seq_putc(p, '\n');
  52. }
  53. if (i < NR_IRQS) {
  54. spin_lock_irqsave(&irq_desc[i].lock, flags);
  55. action = irq_desc[i].action;
  56. if (!action)
  57. goto skip;
  58. seq_printf(p, "%3d: ",i);
  59. #ifndef CONFIG_SMP
  60. seq_printf(p, "%10u ", kstat_irqs(i));
  61. #else
  62. for (j = 0; j < NR_CPUS; j++)
  63. if (cpu_online(j))
  64. seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
  65. #endif
  66. seq_printf(p, " %14s", irq_desc[i].handler->typename);
  67. seq_printf(p, " %s", action->name);
  68. for (action=action->next; action; action = action->next)
  69. seq_printf(p, ", %s", action->name);
  70. seq_putc(p, '\n');
  71. skip:
  72. spin_unlock_irqrestore(&irq_desc[i].lock, flags);
  73. }
  74. return 0;
  75. }
  76. /* called by the assembler IRQ entry functions defined in irq.h
  77. * to dispatch the interrupts to registred handlers
  78. * interrupts are disabled upon entry - depending on if the
  79. * interrupt was registred with SA_INTERRUPT or not, interrupts
  80. * are re-enabled or not.
  81. */
  82. asmlinkage void do_IRQ(int irq, struct pt_regs * regs)
  83. {
  84. unsigned long sp;
  85. irq_enter();
  86. sp = rdsp();
  87. if (unlikely((sp & (PAGE_SIZE - 1)) < (PAGE_SIZE/8))) {
  88. printk("do_IRQ: stack overflow: %lX\n", sp);
  89. show_stack(NULL, (unsigned long *)sp);
  90. }
  91. __do_IRQ(irq, regs);
  92. irq_exit();
  93. }
  94. void weird_irq(void)
  95. {
  96. local_irq_disable();
  97. printk("weird irq\n");
  98. while(1);
  99. }