irq_cpu.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Copyright 2001 MontaVista Software Inc.
  3.  * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
  4.  *
  5.  * This file define the irq handler for MIPS CPU interrupts.
  6.  *
  7.  * This program is free software; you can redistribute  it and/or modify it
  8.  * under  the terms of  the GNU General  Public License as published by the
  9.  * Free Software Foundation;  either version 2 of the  License, or (at your
  10.  * option) any later version.
  11.  */
  12. /*
  13.  * Almost all MIPS CPUs define 8 interrupt sources.  They are typically
  14.  * level triggered (i.e., cannot be cleared from CPU; must be cleared from
  15.  * device).  The first two are software interrupts.  The last one is
  16.  * usually the CPU timer interrupt if counter register is present or, for
  17.  * CPUs with an external FPU, by convention it's the FPU exception interrupt.
  18.  *
  19.  * This file exports one global function:
  20.  * void mips_cpu_irq_init(int irq_base);
  21.  */
  22. #include <linux/init.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/kernel.h>
  25. #include <asm/irq_cpu.h>
  26. #include <asm/mipsregs.h>
  27. static int mips_cpu_irq_base = -1;
  28. static void mips_cpu_irq_enable(unsigned int irq)
  29. {
  30. clear_cp0_cause( 1 << (irq - mips_cpu_irq_base + 8));
  31. set_cp0_status(1 << (irq - mips_cpu_irq_base + 8));
  32. }
  33. static void mips_cpu_irq_disable(unsigned int irq)
  34. {
  35. clear_cp0_status(1 << (irq - mips_cpu_irq_base + 8));
  36. }
  37. static unsigned int mips_cpu_irq_startup(unsigned int irq)
  38. {
  39. mips_cpu_irq_enable(irq);
  40. return 0;
  41. }
  42. #define mips_cpu_irq_shutdown mips_cpu_irq_disable
  43. static void mips_cpu_irq_ack(unsigned int irq)
  44. {
  45. /* although we attemp to clear the IP bit in cause reigster, I think
  46.  * usually it is cleared by device (irq source)
  47.  */
  48. clear_cp0_cause(1 << (irq - mips_cpu_irq_base + 8));
  49. /* disable this interrupt - so that we safe proceed to the handler */
  50. mips_cpu_irq_disable(irq);
  51. }
  52. static void mips_cpu_irq_end(unsigned int irq)
  53. {
  54. if(!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  55. mips_cpu_irq_enable(irq);
  56. }
  57. static hw_irq_controller mips_cpu_irq_controller = {
  58. "MIPS",
  59. mips_cpu_irq_startup,
  60. mips_cpu_irq_shutdown,
  61. mips_cpu_irq_enable,
  62. mips_cpu_irq_disable,
  63. mips_cpu_irq_ack,
  64. mips_cpu_irq_end,
  65. NULL /* no affinity stuff for UP */
  66. };
  67. void __init mips_cpu_irq_init(int irq_base)
  68. {
  69. int i;
  70. for (i = irq_base; i < irq_base + 8; i++) {
  71. irq_desc[i].status = IRQ_DISABLED;
  72. irq_desc[i].action = NULL;
  73. irq_desc[i].depth = 1;
  74. irq_desc[i].handler = &mips_cpu_irq_controller;
  75. }
  76. mips_cpu_irq_base = irq_base;
  77. }