irq.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  4. * Derived (i.e. mostly copied) from arch/i386/kernel/irq.c:
  5. * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
  6. */
  7. #include "linux/config.h"
  8. #include "linux/kernel.h"
  9. #include "linux/module.h"
  10. #include "linux/smp.h"
  11. #include "linux/irq.h"
  12. #include "linux/kernel_stat.h"
  13. #include "linux/interrupt.h"
  14. #include "linux/random.h"
  15. #include "linux/slab.h"
  16. #include "linux/file.h"
  17. #include "linux/proc_fs.h"
  18. #include "linux/init.h"
  19. #include "linux/seq_file.h"
  20. #include "linux/profile.h"
  21. #include "linux/hardirq.h"
  22. #include "asm/irq.h"
  23. #include "asm/hw_irq.h"
  24. #include "asm/atomic.h"
  25. #include "asm/signal.h"
  26. #include "asm/system.h"
  27. #include "asm/errno.h"
  28. #include "asm/uaccess.h"
  29. #include "user_util.h"
  30. #include "kern_util.h"
  31. #include "irq_user.h"
  32. #include "irq_kern.h"
  33. /*
  34. * Generic, controller-independent functions:
  35. */
  36. int show_interrupts(struct seq_file *p, void *v)
  37. {
  38. int i = *(loff_t *) v, j;
  39. struct irqaction * action;
  40. unsigned long flags;
  41. if (i == 0) {
  42. seq_printf(p, " ");
  43. for_each_online_cpu(j)
  44. seq_printf(p, "CPU%d ",j);
  45. seq_putc(p, '\n');
  46. }
  47. if (i < NR_IRQS) {
  48. spin_lock_irqsave(&irq_desc[i].lock, flags);
  49. action = irq_desc[i].action;
  50. if (!action)
  51. goto skip;
  52. seq_printf(p, "%3d: ",i);
  53. #ifndef CONFIG_SMP
  54. seq_printf(p, "%10u ", kstat_irqs(i));
  55. #else
  56. for_each_online_cpu(j)
  57. seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
  58. #endif
  59. seq_printf(p, " %14s", irq_desc[i].handler->typename);
  60. seq_printf(p, " %s", action->name);
  61. for (action=action->next; action; action = action->next)
  62. seq_printf(p, ", %s", action->name);
  63. seq_putc(p, '\n');
  64. skip:
  65. spin_unlock_irqrestore(&irq_desc[i].lock, flags);
  66. } else if (i == NR_IRQS) {
  67. seq_putc(p, '\n');
  68. }
  69. return 0;
  70. }
  71. /*
  72. * do_IRQ handles all normal device IRQ's (the special
  73. * SMP cross-CPU interrupts have their own specific
  74. * handlers).
  75. */
  76. unsigned int do_IRQ(int irq, union uml_pt_regs *regs)
  77. {
  78. irq_enter();
  79. __do_IRQ(irq, (struct pt_regs *) regs);
  80. irq_exit();
  81. return 1;
  82. }
  83. int um_request_irq(unsigned int irq, int fd, int type,
  84. irqreturn_t (*handler)(int, void *, struct pt_regs *),
  85. unsigned long irqflags, const char * devname,
  86. void *dev_id)
  87. {
  88. int err;
  89. err = request_irq(irq, handler, irqflags, devname, dev_id);
  90. if(err)
  91. return(err);
  92. if(fd != -1)
  93. err = activate_fd(irq, fd, type, dev_id);
  94. return(err);
  95. }
  96. EXPORT_SYMBOL(um_request_irq);
  97. EXPORT_SYMBOL(reactivate_fd);
  98. static DEFINE_SPINLOCK(irq_spinlock);
  99. unsigned long irq_lock(void)
  100. {
  101. unsigned long flags;
  102. spin_lock_irqsave(&irq_spinlock, flags);
  103. return(flags);
  104. }
  105. void irq_unlock(unsigned long flags)
  106. {
  107. spin_unlock_irqrestore(&irq_spinlock, flags);
  108. }
  109. /* presently hw_interrupt_type must define (startup || enable) &&
  110. * disable && end */
  111. static void dummy(unsigned int irq)
  112. {
  113. }
  114. static struct hw_interrupt_type SIGIO_irq_type = {
  115. .typename = "SIGIO",
  116. .disable = dummy,
  117. .enable = dummy,
  118. .ack = dummy,
  119. .end = dummy
  120. };
  121. static struct hw_interrupt_type SIGVTALRM_irq_type = {
  122. .typename = "SIGVTALRM",
  123. .shutdown = dummy, /* never called */
  124. .disable = dummy,
  125. .enable = dummy,
  126. .ack = dummy,
  127. .end = dummy
  128. };
  129. void __init init_IRQ(void)
  130. {
  131. int i;
  132. irq_desc[TIMER_IRQ].status = IRQ_DISABLED;
  133. irq_desc[TIMER_IRQ].action = NULL;
  134. irq_desc[TIMER_IRQ].depth = 1;
  135. irq_desc[TIMER_IRQ].handler = &SIGVTALRM_irq_type;
  136. enable_irq(TIMER_IRQ);
  137. for(i=1;i<NR_IRQS;i++){
  138. irq_desc[i].status = IRQ_DISABLED;
  139. irq_desc[i].action = NULL;
  140. irq_desc[i].depth = 1;
  141. irq_desc[i].handler = &SIGIO_irq_type;
  142. enable_irq(i);
  143. }
  144. }
  145. /*
  146. * Overrides for Emacs so that we follow Linus's tabbing style.
  147. * Emacs will notice this stuff at the end of the file and automatically
  148. * adjust the settings for this buffer only. This must remain at the end
  149. * of the file.
  150. * ---------------------------------------------------------------------------
  151. * Local variables:
  152. * c-file-style: "linux"
  153. * End:
  154. */