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