interrupt.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (c) 2021, Shenzhen Academy of Aerospace Technology
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-11-16 Dystopia the first version
  9. */
  10. #include "interrupt.h"
  11. #include "c66xx.h"
  12. #include "trap.h"
  13. #define MAX_HANDLERS 128
  14. extern volatile rt_uint8_t rt_interrupt_nest;
  15. struct rt_irq_desc isr_table[MAX_HANDLERS];
  16. rt_uint32_t rt_interrupt_from_thread;
  17. rt_uint32_t rt_interrupt_to_thread;
  18. rt_uint32_t rt_thread_switch_interrupt_flag;
  19. /**
  20. * This function will initialize hardware interrupt
  21. */
  22. void rt_hw_interrupt_init(void)
  23. {
  24. // initial system trap
  25. rt_trap_init();
  26. /* init exceptions table */
  27. rt_memset(isr_table, 0x00, sizeof(isr_table));
  28. /* init interrupt nest, and context in thread sp */
  29. rt_interrupt_nest = 0;
  30. rt_interrupt_from_thread = 0;
  31. rt_interrupt_to_thread = 0;
  32. rt_thread_switch_interrupt_flag = 0;
  33. }
  34. /**
  35. * This function will mask a interrupt.
  36. * @param vector the interrupt number
  37. */
  38. void rt_hw_interrupt_mask(int vector)
  39. {
  40. if (vector < 0 || vector >= MAX_HANDLERS)
  41. return;
  42. }
  43. /**
  44. * This function will un-mask a interrupt.
  45. * @param vector the interrupt number
  46. */
  47. void rt_hw_interrupt_umask(int vector)
  48. {
  49. if (vector < 0 || vector >= MAX_HANDLERS)
  50. return;
  51. }
  52. /**
  53. * This function will install a interrupt service routine to a interrupt.
  54. * @param vector the interrupt number
  55. * @param new_handler the interrupt service routine to be installed
  56. * @param old_handler the old interrupt service routine
  57. */
  58. rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
  59. void *param, const char *name)
  60. {
  61. rt_isr_handler_t old_handler = RT_NULL;
  62. if (vector < MAX_HANDLERS || vector >= 0)
  63. {
  64. old_handler = isr_table[vector].handler;
  65. if (handler != RT_NULL)
  66. {
  67. #ifdef RT_USING_INTERRUPT_INFO
  68. rt_strncpy(isr_table[vector].name, name, RT_NAME_MAX);
  69. #endif /* RT_USING_INTERRUPT_INFO */
  70. isr_table[vector].handler = handler;
  71. isr_table[vector].param = param;
  72. }
  73. }
  74. return old_handler;
  75. }
  76. void rt_hw_interrupt_clear(int vector)
  77. {
  78. if (vector < 0 || vector >= MAX_HANDLERS)
  79. return;
  80. }