pic_rthw.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-08-24 GuEe-GUI first version
  9. */
  10. #include <rtthread.h>
  11. #include <rtdevice.h>
  12. /**
  13. * This function will initialize hardware interrupt
  14. */
  15. void rt_hw_interrupt_init(void)
  16. {
  17. /* initialize pic */
  18. rt_pic_irq_init();
  19. }
  20. /**
  21. * This function will mask a interrupt.
  22. * @param vector the interrupt number
  23. */
  24. void rt_hw_interrupt_mask(int vector)
  25. {
  26. rt_pic_irq_mask(vector);
  27. }
  28. /**
  29. * This function will un-mask a interrupt.
  30. * @param vector the interrupt number
  31. */
  32. void rt_hw_interrupt_umask(int vector)
  33. {
  34. rt_pic_irq_unmask(vector);
  35. }
  36. /**
  37. * This function will install a interrupt service routine to a interrupt.
  38. * @param vector the interrupt number
  39. * @param new_handler the interrupt service routine to be installed
  40. * @param old_handler the old interrupt service routine
  41. */
  42. rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
  43. void *param, const char *name)
  44. {
  45. rt_pic_attach_irq(vector, handler, param, name, RT_IRQ_F_NONE);
  46. return RT_NULL;
  47. }
  48. /**
  49. * This function will install a interrupt service routine to a interrupt.
  50. * @param vector the interrupt number
  51. * @param new_handler the interrupt service routine to be installed
  52. * @param old_handler the old interrupt service routine
  53. */
  54. void rt_hw_interrupt_uninstall(int vector, rt_isr_handler_t handler, void *param)
  55. {
  56. rt_pic_detach_irq(vector, param);
  57. }
  58. #if defined(RT_USING_SMP) || defined(RT_USING_AMP)
  59. void rt_hw_ipi_send(int ipi_vector, unsigned int cpu_mask)
  60. {
  61. RT_BITMAP_DECLARE(cpu_masks, RT_CPUS_NR) = { cpu_mask };
  62. rt_pic_irq_send_ipi(ipi_vector, cpu_masks);
  63. }
  64. void rt_hw_ipi_handler_install(int ipi_vector, rt_isr_handler_t ipi_isr_handler)
  65. {
  66. /* note: ipi_vector maybe different with irq_vector */
  67. rt_hw_interrupt_install(ipi_vector, ipi_isr_handler, 0, "IPI_HANDLER");
  68. }
  69. #endif