-
Notifications
You must be signed in to change notification settings - Fork 268
/
tpl_os_interrupt_kernel.h
254 lines (221 loc) · 6.25 KB
/
tpl_os_interrupt_kernel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/**
* @file tpl_os_interrupts.h
*
* @section desc File description
*
* Trampoline interrupt service routines management
*
* @section copyright Copyright
*
* Trampoline RTOS
*
* Trampoline is copyright (c) CNRS, University of Nantes, Ecole Centrale de
* Nantes Trampoline is protected by the French intellectual property law.
*
* This software is distributed under the GNU Public Licence V2.
* Check the LICENSE file in the root directory of Trampoline
*
* @section infos File informations
*
* $Date$
* $Rev$
* $Author$
* $URL$
*/
#ifndef TPL_OS_IT_KERNEL_H
#define TPL_OS_IT_KERNEL_H
#include "tpl_machine.h"
#include "tpl_os_kernel.h"
/**
* An ISR helper is a function which should return true
* if the related ISR decides to handle the interrupt
*
* This type is not intended to be used alone.
*
* @see #TPL_ISR_STATIC
*/
typedef P2FUNC(tpl_bool, OS_APPL_CODE, tpl_isr_helper)(void);
typedef P2FUNC(void, OS_APPL_CODE,
tpl_it_handler)(P2CONST(void, OS_APPL_DATA, AUTOMATIC));
/**
* Function pointer type for enable/disable interrupts functions
*/
typedef P2FUNC(void, OS_APPL_CODE, tpl_enable_disable_func)(void);
/**
* @struct TPL_IT_VECTOR_ENTRY
*
* Entry of the tpl interrupt vector
*/
struct TPL_IT_VECTOR_ENTRY
{
CONST(tpl_it_handler, AUTOMATIC)
func; /**< pointer to the request
handling function for
this interrupt
*/
P2VAR(void, OS_APPL_DATA, AUTOMATIC)
args; /**< pointer to the
arguments the function
*/
};
/**
* @typedef tpl_it_vector_entry
*
* This is an alias for #TPL_IT_VECTOR_ENTRY structure
*
* @see #TPL_IT_VECTOR_ENTRY
*/
typedef struct TPL_IT_VECTOR_ENTRY tpl_it_vector_entry;
/**
* @struct TPL_ISR_STATIC
*
* Static descriptor of a category 2 interrupt service routine
*/
struct TPL_ISR_STATIC
{
CONST(tpl_isr_helper, AUTOMATIC)
helper; /**< pointer to a helper function used
to search for hardware that
launched the interrupt
*/
struct P2VAR(TPL_ISR_STATIC, OS_APPL_DATA,
AUTOMATIC) next; /**< when there is several handler for
the same interrupt priority, the
tpl_isr are chained. In this case.
Trampoline uses the helper to check
what handler will be called for the
interrupt.
*/
CONST(tpl_isr_id, AUTOMATIC)
isr_id; /**< The id of the ISR
*/
};
/**
* @typedef tpl_isr_static
*
* This is an alias for #TPL_ISR_STATIC structure
*
* @see #TPL_ISR_STATIC
*/
typedef struct TPL_ISR_STATIC tpl_isr_static;
#if ISR_COUNT > 0
#define OS_START_SEC_CONST_UNSPECIFIED
#include "tpl_memmap.h"
extern CONSTP2CONST(tpl_isr_static, AUTOMATIC,
OS_APPL_DATA) tpl_isr_stat_table[ISR_COUNT];
#define OS_STOP_SEC_CONST_UNSPECIFIED
#include "tpl_memmap.h"
#endif /* ISR_COUNT */
#define OS_START_SEC_CODE
#include "tpl_memmap.h"
/**
* Check if interrupts are disabled or not by the user
*
* @retval TRUE interrupts disabled
* @retval FALSE interrupts enabled
*/
FUNC(tpl_bool, OS_CODE) tpl_get_interrupt_lock_status(void);
/**
* Check if interrupts are disabled or not by the user
*/
FUNC(void, OS_CODE) tpl_reset_interrupt_lock_status(void);
/**
* Additional non-standard system service to terminate a category 2 interrupt
* routine.
*
* This service is equivalent to TerminateTask but for ISR2
*/
FUNC(tpl_status, OS_CODE) tpl_terminate_isr2_service(void);
/**
* This is the dispatcher of interrupts. It should be called by
* the root interrupt handler with an ISR identifier
*
* @param interrupt service routine identifier
*/
FUNC(void, OS_CODE) tpl_central_interrupt_handler(CONST(uint16, AUTOMATIC) id);
/**
* This is the fast dispatcher of interrupts. It should be called by
* the root interrupt handler with an ISR identifier
* This dispatcher does not look for many isr connected to the id.
* It activates only one isr.
*
* @param interrupt service routine identifier
*/
FUNC(void, OS_CODE)
tpl_fast_central_interrupt_handler(CONST(uint16, AUTOMATIC) id);
/**
* This is the dispatcher of interrupts. It should be called by
* the root interrupt handler with an ISR identifier. VP2 version.
*
* @param interrupt service routine identifier
*/
FUNC(void, OS_CODE)
tpl_central_interrupt_handler_2(P2CONST(void, OS_APPL_DATA, AUTOMATIC) id);
/**
* This function is called when an unknown interrupt is raised.
* It is empty. It is only present to attach a breakpoint for
* debugging purposes. VP2 version.
*/
FUNC(void, OS_CODE) tpl_null_it(P2CONST(void, OS_APPL_DATA, AUTOMATIC));
/**
* Enable all interrupts service
*
* @see #EnableAllInterrupts
*/
FUNC(void, OS_CODE) tpl_enable_all_interrupts_service(void);
/**
* Disable all interrupts
*
* @see #DisableAllInterrupts
*/
FUNC(void, OS_CODE) tpl_disable_all_interrupts_service(void);
/**
* Resume all interrupts
*
* @see #ResumeAllInterrupts
*/
FUNC(void, OS_CODE) tpl_resume_all_interrupts_service(void);
/**
* Suspend all interrupts
*
* @see #SuspendAllInterrupts
*/
FUNC(void, OS_CODE) tpl_suspend_all_interrupts_service(void);
/**
* Resume category 2 interrupts
*
* @see #ResumeOSInterrupts
*/
FUNC(void, OS_CODE) tpl_resume_os_interrupts_service(void);
/**
* Suspend category 2 interrupts
*
* @see #SuspendOSInterrupts
*/
FUNC(void, OS_CODE) tpl_suspend_os_interrupts_service(void);
#if WITH_ISR2_PRIORITY_MASKING == YES && ISR_COUNT > 0
/**
* @internal
*
* tpl_mask_isr2_priority masks ISR2s which have a lower priority than
* the ISR2 id given in argument
*
* @param isr isr for which interrupts have to be masked
*/
extern FUNC(void, OS_CODE)
tpl_mask_isr2_priority(CONST(tpl_proc_id, AUTOMATIC) proc_id);
/**
* @internal
*
* tpl_unmask_isr2_priority unmask ISR2s which have a lower priority than
* the ISR2 id given in argument
*
* @param isr isr for which interrupts have to be unmasked
*/
extern FUNC(void, OS_CODE)
tpl_unmask_isr2_priority(CONST(tpl_proc_id, AUTOMATIC) proc_id);
#endif /* WITH_ISR2_PRIORITY_MASKING */
#define OS_STOP_SEC_CODE
#include "tpl_memmap.h"
#endif /* TPL_OS_IT_KERNEL_H */
/* End of file tpl_os_it_kernel.h */