1 /*
2 * FreeRTOS Kernel V11.0.1
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 /*
31 * Xtensa-specific API for RTOS ports.
32 */
33
34 #ifndef __XTENSA_API_H__
35 #define __XTENSA_API_H__
36
37 #include <xtensa/hal.h>
38
39 #include "xtensa_context.h"
40
41
42 /* Typedef for C-callable interrupt handler function */
43 typedef void (* xt_handler)( void * );
44
45 /* Typedef for C-callable exception handler function */
46 typedef void (* xt_exc_handler)( XtExcFrame * );
47
48
49 /*
50 * -------------------------------------------------------------------------------
51 * Call this function to set a handler for the specified exception.
52 *
53 * n - Exception number (type)
54 * f - Handler function address, NULL to uninstall handler.
55 *
56 * The handler will be passed a pointer to the exception frame, which is created
57 * on the stack of the thread that caused the exception.
58 *
59 * If the handler returns, the thread context will be restored and the faulting
60 * instruction will be retried. Any values in the exception frame that are
61 * modified by the handler will be restored as part of the context. For details
62 * of the exception frame structure see xtensa_context.h.
63 * -------------------------------------------------------------------------------
64 */
65 extern xt_exc_handler xt_set_exception_handler( int n,
66 xt_exc_handler f );
67
68
69 /*
70 * -------------------------------------------------------------------------------
71 * Call this function to set a handler for the specified interrupt.
72 *
73 * n - Interrupt number.
74 * f - Handler function address, NULL to uninstall handler.
75 * arg - Argument to be passed to handler.
76 * -------------------------------------------------------------------------------
77 */
78 extern xt_handler xt_set_interrupt_handler( int n,
79 xt_handler f,
80 void * arg );
81
82
83 /*
84 * -------------------------------------------------------------------------------
85 * Call this function to enable the specified interrupts.
86 *
87 * mask - Bit mask of interrupts to be enabled.
88 *
89 * Returns the previous state of the interrupt enables.
90 * -------------------------------------------------------------------------------
91 */
92 extern unsigned int xt_ints_on( unsigned int mask );
93
94
95 /*
96 * -------------------------------------------------------------------------------
97 * Call this function to disable the specified interrupts.
98 *
99 * mask - Bit mask of interrupts to be disabled.
100 *
101 * Returns the previous state of the interrupt enables.
102 * -------------------------------------------------------------------------------
103 */
104 extern unsigned int xt_ints_off( unsigned int mask );
105
106
107 /*
108 * -------------------------------------------------------------------------------
109 * Call this function to set the specified (s/w) interrupt.
110 * -------------------------------------------------------------------------------
111 */
xt_set_intset(unsigned int arg)112 static inline void xt_set_intset( unsigned int arg )
113 {
114 xthal_set_intset( arg );
115 }
116
117
118 /*
119 * -------------------------------------------------------------------------------
120 * Call this function to clear the specified (s/w or edge-triggered)
121 * interrupt.
122 * -------------------------------------------------------------------------------
123 */
xt_set_intclear(unsigned int arg)124 static inline void xt_set_intclear( unsigned int arg )
125 {
126 xthal_set_intclear( arg );
127 }
128
129
130 #endif /* __XTENSA_API_H__ */
131