interrupt.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. {
  42. return;
  43. }
  44. }
  45. /**
  46. * This function will un-mask a interrupt.
  47. * @param vector the interrupt number
  48. */
  49. void rt_hw_interrupt_umask(int vector)
  50. {
  51. if (vector < 0 || vector >= MAX_HANDLERS)
  52. {
  53. return;
  54. }
  55. }
  56. /**
  57. * This function will install a interrupt service routine to a interrupt.
  58. * @param vector the interrupt number
  59. * @param new_handler the interrupt service routine to be installed
  60. * @param old_handler the old interrupt service routine
  61. */
  62. rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
  63. void *param, const char *name)
  64. {
  65. rt_isr_handler_t old_handler = RT_NULL;
  66. if (vector < MAX_HANDLERS || vector >= 0)
  67. {
  68. old_handler = isr_table[vector].handler;
  69. if (handler != RT_NULL)
  70. {
  71. #ifdef RT_USING_INTERRUPT_INFO
  72. rt_strncpy(isr_table[vector].name, name, RT_NAME_MAX);
  73. #endif /* RT_USING_INTERRUPT_INFO */
  74. isr_table[vector].handler = handler;
  75. isr_table[vector].param = param;
  76. }
  77. }
  78. return old_handler;
  79. }
  80. void rt_hw_interrupt_clear(int vector)
  81. {
  82. if (vector < 0 || vector >= MAX_HANDLERS)
  83. {
  84. return;
  85. }
  86. }