interrupt.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * File : interrupt.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. */
  23. #include <rthw.h>
  24. #include "gk7101.h"
  25. #define MAX_HANDLERS (64)
  26. extern rt_uint32_t rt_interrupt_nest;
  27. /* exception and interrupt handler table */
  28. struct rt_irq_desc irq_desc[MAX_HANDLERS];
  29. rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
  30. rt_uint32_t rt_thread_switch_interrupt_flag;
  31. /* --------------------------------------------------------------------
  32. * Interrupt initialization
  33. * -------------------------------------------------------------------- */
  34. void rt_hw_interrupt_mask(int irq);
  35. void rt_hw_interrupt_umask(int irq);
  36. rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector, void *param)
  37. {
  38. rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
  39. return RT_NULL;
  40. }
  41. /**
  42. * This function will initialize hardware interrupt
  43. */
  44. void rt_hw_interrupt_init(void)
  45. {
  46. //rt_int32_t i;
  47. //register rt_uint32_t idx;
  48. /* init interrupt nest, and context in thread sp */
  49. rt_interrupt_nest = 0;
  50. rt_interrupt_from_thread = 0;
  51. rt_interrupt_to_thread = 0;
  52. rt_thread_switch_interrupt_flag = 0;
  53. }
  54. /**
  55. * This function will mask a interrupt.
  56. * @param vector the interrupt number
  57. */
  58. void rt_hw_interrupt_mask(int irq)
  59. {
  60. }
  61. /**
  62. * This function will un-mask a interrupt.
  63. * @param vector the interrupt number
  64. */
  65. void rt_hw_interrupt_umask(int irq)
  66. {
  67. }
  68. /**
  69. * This function will install a interrupt service routine to a interrupt.
  70. * @param vector the interrupt number
  71. * @param handler the interrupt service routine to be installed
  72. * @param param the interrupt service function parameter
  73. * @param name the interrupt name
  74. * @return old handler
  75. */
  76. rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
  77. void *param, char *name)
  78. {
  79. rt_isr_handler_t old_handler = RT_NULL;
  80. if(vector < MAX_HANDLERS)
  81. {
  82. old_handler = irq_desc[vector].handler;
  83. if (handler != RT_NULL)
  84. {
  85. #ifdef RT_USING_INTERRUPT_INFO
  86. rt_snprintf(irq_desc[vector].name, RT_NAME_MAX - 1, "%s", name);
  87. irq_desc[vector].counter = 0;
  88. #endif
  89. irq_desc[vector].handler = (rt_isr_handler_t)handler;
  90. irq_desc[vector].param = param;
  91. }
  92. }
  93. return old_handler;
  94. }
  95. /*@}*/
  96. #ifdef RT_USING_FINSH
  97. void list_irq(void)
  98. {
  99. int irq;
  100. #ifdef RT_USING_INTERRUPT_INFO
  101. rt_kprintf("number\tcount\tname\n");
  102. for (irq = 0; irq < MAX_HANDLERS; irq++)
  103. {
  104. if (rt_strncmp(irq_desc[irq].name, "default", sizeof("default")))
  105. {
  106. rt_kprintf("%02ld: %10ld %s\n", irq, irq_desc[irq].counter, irq_desc[irq].name);
  107. }
  108. }
  109. #endif
  110. }
  111. #include <finsh.h>
  112. FINSH_FUNCTION_EXPORT(list_irq, list system irq);
  113. #endif