xtensa_api.h 4.3 KB

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