1 /*
2 * FreeRTOS Kernel V11.1.0
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, xt_exc_handler f);
66
67
68 /*
69 -------------------------------------------------------------------------------
70 Call this function to set a handler for the specified interrupt.
71
72 n - Interrupt number.
73 f - Handler function address, NULL to uninstall handler.
74 arg - Argument to be passed to handler.
75 -------------------------------------------------------------------------------
76 */
77 extern xt_handler xt_set_interrupt_handler(int n, xt_handler f, void * arg);
78
79
80 /*
81 -------------------------------------------------------------------------------
82 Call this function to enable the specified interrupts.
83
84 mask - Bit mask of interrupts to be enabled.
85
86 Returns the previous state of the interrupt enables.
87 -------------------------------------------------------------------------------
88 */
89 extern unsigned int xt_ints_on(unsigned int mask);
90
91
92 /*
93 -------------------------------------------------------------------------------
94 Call this function to disable the specified interrupts.
95
96 mask - Bit mask of interrupts to be disabled.
97
98 Returns the previous state of the interrupt enables.
99 -------------------------------------------------------------------------------
100 */
101 extern unsigned int xt_ints_off(unsigned int mask);
102
103
104 /*
105 -------------------------------------------------------------------------------
106 Call this function to set the specified (s/w) interrupt.
107 -------------------------------------------------------------------------------
108 */
xt_set_intset(unsigned int arg)109 static inline void xt_set_intset(unsigned int arg)
110 {
111 xthal_set_intset(arg);
112 }
113
114
115 /*
116 -------------------------------------------------------------------------------
117 Call this function to clear the specified (s/w or edge-triggered)
118 interrupt.
119 -------------------------------------------------------------------------------
120 */
xt_set_intclear(unsigned int arg)121 static inline void xt_set_intclear(unsigned int arg)
122 {
123 xthal_set_intclear(arg);
124 }
125
126
127 #endif /* __XTENSA_API_H__ */
128