xtensa_api.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*******************************************************************************
  2. Copyright (c) 2006-2015 Cadence Design Systems Inc.
  3. Permission is hereby granted, free of charge, to any person obtaining
  4. a copy of this software and associated documentation files (the
  5. "Software"), to deal in the Software without restriction, including
  6. without limitation the rights to use, copy, modify, merge, publish,
  7. distribute, sublicense, and/or sell copies of the Software, and to
  8. permit persons to whom the Software is furnished to do so, subject to
  9. the following conditions:
  10. The above copyright notice and this permission notice shall be included
  11. in all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  15. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  16. CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  17. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  18. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. ******************************************************************************/
  20. /******************************************************************************
  21. Xtensa-specific API for RTOS ports.
  22. ******************************************************************************/
  23. #ifndef __XTENSA_API_H__
  24. #define __XTENSA_API_H__
  25. #include <stdbool.h>
  26. #include <xtensa/hal.h>
  27. #include "xtensa_context.h"
  28. /* Typedef for C-callable interrupt handler function */
  29. typedef void (*xt_handler)(void *);
  30. /* Typedef for C-callable exception handler function */
  31. typedef void (*xt_exc_handler)(XtExcFrame *);
  32. /*
  33. -------------------------------------------------------------------------------
  34. Call this function to set a handler for the specified exception. The handler
  35. will be installed on the core that calls this function.
  36. n - Exception number (type)
  37. f - Handler function address, NULL to uninstall handler.
  38. The handler will be passed a pointer to the exception frame, which is created
  39. on the stack of the thread that caused the exception.
  40. If the handler returns, the thread context will be restored and the faulting
  41. instruction will be retried. Any values in the exception frame that are
  42. modified by the handler will be restored as part of the context. For details
  43. of the exception frame structure see xtensa_context.h.
  44. -------------------------------------------------------------------------------
  45. */
  46. extern xt_exc_handler xt_set_exception_handler(int n, xt_exc_handler f);
  47. /*
  48. -------------------------------------------------------------------------------
  49. Call this function to set a handler for the specified interrupt. The handler
  50. will be installed on the core that calls this function.
  51. n - Interrupt number.
  52. f - Handler function address, NULL to uninstall handler.
  53. arg - Argument to be passed to handler.
  54. -------------------------------------------------------------------------------
  55. */
  56. extern xt_handler xt_set_interrupt_handler(int n, xt_handler f, void * arg);
  57. /*
  58. -------------------------------------------------------------------------------
  59. Call this function to enable the specified interrupts on the core that runs
  60. this code.
  61. mask - Bit mask of interrupts to be enabled.
  62. -------------------------------------------------------------------------------
  63. */
  64. extern void xt_ints_on(unsigned int mask);
  65. /*
  66. -------------------------------------------------------------------------------
  67. Call this function to disable the specified interrupts on the core that runs
  68. this code.
  69. mask - Bit mask of interrupts to be disabled.
  70. -------------------------------------------------------------------------------
  71. */
  72. extern void xt_ints_off(unsigned int mask);
  73. /*
  74. -------------------------------------------------------------------------------
  75. Call this function to set the specified (s/w) interrupt.
  76. -------------------------------------------------------------------------------
  77. */
  78. static inline void xt_set_intset(unsigned int arg)
  79. {
  80. xthal_set_intset(arg);
  81. }
  82. /*
  83. -------------------------------------------------------------------------------
  84. Call this function to clear the specified (s/w or edge-triggered)
  85. interrupt.
  86. -------------------------------------------------------------------------------
  87. */
  88. static inline void xt_set_intclear(unsigned int arg)
  89. {
  90. xthal_set_intclear(arg);
  91. }
  92. /*
  93. -------------------------------------------------------------------------------
  94. Call this function to get handler's argument for the specified interrupt.
  95. n - Interrupt number.
  96. -------------------------------------------------------------------------------
  97. */
  98. extern void * xt_get_interrupt_handler_arg(int n);
  99. /*
  100. -------------------------------------------------------------------------------
  101. Call this function to check if the specified interrupt is free to use.
  102. intr - Interrupt number.
  103. cpu - cpu number.
  104. -------------------------------------------------------------------------------
  105. */
  106. bool xt_int_has_handler(int intr, int cpu);
  107. #endif /* __XTENSA_API_H__ */