1 | /*
|
---|
2 | * TOPPERS ATK2
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems
|
---|
4 | * Automotive Kernel Version 2
|
---|
5 | *
|
---|
6 | * Copyright (C) 2004-2015 by Center for Embedded Computing Systems
|
---|
7 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
8 | * Copyright (C) 2011-2015 by FUJI SOFT INCORPORATED, JAPAN
|
---|
9 | * Copyright (C) 2011-2013 by Spansion LLC, USA
|
---|
10 | * Copyright (C) 2011-2015 by NEC Communication Systems, Ltd., JAPAN
|
---|
11 | * Copyright (C) 2011-2015 by Panasonic Advanced Technology Development Co., Ltd., JAPAN
|
---|
12 | * Copyright (C) 2011-2014 by Renesas Electronics Corporation, JAPAN
|
---|
13 | * Copyright (C) 2011-2015 by Sunny Giken Inc., JAPAN
|
---|
14 | * Copyright (C) 2011-2015 by TOSHIBA CORPORATION, JAPAN
|
---|
15 | * Copyright (C) 2011-2015 by Witz Corporation
|
---|
16 | * Copyright (C) 2014-2015 by AISIN COMCRUISE Co., Ltd., JAPAN
|
---|
17 | * Copyright (C) 2014-2015 by eSOL Co.,Ltd., JAPAN
|
---|
18 | * Copyright (C) 2014-2015 by SCSK Corporation, JAPAN
|
---|
19 | * Copyright (C) 2015 by SUZUKI MOTOR CORPORATION
|
---|
20 | *
|
---|
21 | * ä¸è¨èä½æ¨©è
|
---|
22 | ã¯ï¼ä»¥ä¸ã®(1)ã(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
23 | * ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
24 | * å¤ã»åé
|
---|
25 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
26 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
27 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
28 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
29 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
30 | * ç¨ã§ããå½¢ã§åé
|
---|
31 | å¸ããå ´åã«ã¯ï¼åé
|
---|
32 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
33 | * è
|
---|
34 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
35 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
36 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
37 | * ç¨ã§ããªãå½¢ã§åé
|
---|
38 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
39 | * ã¨ï¼
|
---|
40 | * (a) åé
|
---|
41 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
42 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
43 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
44 | * (b) åé
|
---|
45 | å¸ã®å½¢æ
|
---|
46 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
47 | * å ±åãããã¨ï¼
|
---|
48 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
49 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
50 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
51 | 責ãããã¨ï¼
|
---|
52 | * ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
53 | * ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
54 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
55 | * å
|
---|
56 | 責ãããã¨ï¼
|
---|
57 | *
|
---|
58 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼AUTOSARï¼AUTomotive Open System ARchitectureï¼ä»
|
---|
59 | * æ§ã«åºã¥ãã¦ããï¼ä¸è¨ã®è¨±è«¾ã¯ï¼AUTOSARã®ç¥ç財ç£æ¨©ã許諾ãããã®ã§
|
---|
60 | * ã¯ãªãï¼AUTOSARã¯ï¼AUTOSARä»æ§ã«åºã¥ããã½ããã¦ã§ã¢ãåç¨ç®çã§å©
|
---|
61 | * ç¨ããè
|
---|
62 | ã«å¯¾ãã¦ï¼AUTOSARãã¼ããã¼ã«ãªããã¨ãæ±ãã¦ããï¼
|
---|
63 | *
|
---|
64 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
65 | ã
|
---|
66 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
67 | * ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
68 | * ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
69 | * ã®è²¬ä»»ãè² ããªãï¼
|
---|
70 | *
|
---|
71 | * $Id: osap.c 483 2015-12-17 06:27:31Z ertl-ishikawa $
|
---|
72 | */
|
---|
73 |
|
---|
74 | #include "kernel_impl.h"
|
---|
75 | #include "check.h"
|
---|
76 | #include "osap.h"
|
---|
77 | #include "task.h"
|
---|
78 | #include "interrupt.h"
|
---|
79 | #include "counter.h"
|
---|
80 | #include "alarm.h"
|
---|
81 | #include "resource.h"
|
---|
82 | #include "scheduletable.h"
|
---|
83 |
|
---|
84 | /*
|
---|
85 | * OSã¢ããªã±ã¼ã·ã§ã³ç®¡çã¢ã¸ã¥ã¼ã«
|
---|
86 | */
|
---|
87 |
|
---|
88 | /*
|
---|
89 | * ãã¬ã¼ã¹ãã¯ãã®ããã©ã«ãå®ç¾©
|
---|
90 | */
|
---|
91 | #ifndef LOG_GETOSAPID_ENTER
|
---|
92 | #define LOG_GETOSAPID_ENTER()
|
---|
93 | #endif /* LOG_GETOSAPID_ENTER */
|
---|
94 |
|
---|
95 | #ifndef LOG_GETOSAPID_LEAVE
|
---|
96 | #define LOG_GETOSAPID_LEAVE(id)
|
---|
97 | #endif /* LOG_GETOSAPID_LEAVE */
|
---|
98 |
|
---|
99 | #ifndef LOG_GETAST_ENTER
|
---|
100 | #define LOG_GETAST_ENTER(Application)
|
---|
101 | #endif /* LOG_GETAST_ENTER */
|
---|
102 |
|
---|
103 | #ifndef LOG_GETAST_LEAVE
|
---|
104 | #define LOG_GETAST_LEAVE(ercd, p_value)
|
---|
105 | #endif /* LOG_GETAST_LEAVE */
|
---|
106 |
|
---|
107 | #ifndef LOG_CALTFN_ENTER
|
---|
108 | #define LOG_CALTFN_ENTER(FunctionIndex)
|
---|
109 | #endif /* LOG_CALTFN_ENTER */
|
---|
110 |
|
---|
111 | #ifndef LOG_CALTFN_LEAVE
|
---|
112 | #define LOG_CALTFN_LEAVE(FunctionIndex)
|
---|
113 | #endif /* LOG_CALTFN_LEAVE */
|
---|
114 |
|
---|
115 | #ifndef LOG_TFN_ENTER
|
---|
116 | #define LOG_TFN_ENTER(FunctionIndex)
|
---|
117 | #endif /* LOG_TFN_ENTER */
|
---|
118 |
|
---|
119 | #ifndef LOG_TFN_LEAVE
|
---|
120 | #define LOG_TFN_LEAVE(FunctionIndex, ercd)
|
---|
121 | #endif /* LOG_TFN_LEAVE */
|
---|
122 |
|
---|
123 | #ifndef LOG_CHKTSKACS_ENTER
|
---|
124 | #define LOG_CHKTSKACS_ENTER(ApplID, TaskID)
|
---|
125 | #endif /* LOG_CHKTSKACS_ENTER */
|
---|
126 |
|
---|
127 | #ifndef LOG_CHKTSKACS_LEAVE
|
---|
128 | #define LOG_CHKTSKACS_LEAVE(access)
|
---|
129 | #endif /* LOG_CHKTSKACS_LEAVE */
|
---|
130 |
|
---|
131 | #ifndef LOG_CHKISRACS_ENTER
|
---|
132 | #define LOG_CHKISRACS_ENTER(ApplID, ISRID)
|
---|
133 | #endif /* LOG_CHKISRACS_ENTER */
|
---|
134 |
|
---|
135 | #ifndef LOG_CHKISRACS_LEAVE
|
---|
136 | #define LOG_CHKISRACS_LEAVE(access)
|
---|
137 | #endif /* LOG_CHKISRACS_LEAVE */
|
---|
138 |
|
---|
139 | #ifndef LOG_CHKALMACS_ENTER
|
---|
140 | #define LOG_CHKALMACS_ENTER(ApplID, AlarmID)
|
---|
141 | #endif /* LOG_CHKALMACS_ENTER */
|
---|
142 |
|
---|
143 | #ifndef LOG_CHKALMACS_LEAVE
|
---|
144 | #define LOG_CHKALMACS_LEAVE(access)
|
---|
145 | #endif /* LOG_CHKALMACS_LEAVE */
|
---|
146 |
|
---|
147 | #ifndef LOG_CHKRESACS_ENTER
|
---|
148 | #define LOG_CHKRESACS_ENTER(ApplID, ResID)
|
---|
149 | #endif /* LOG_CHKRESACS_ENTER */
|
---|
150 |
|
---|
151 | #ifndef LOG_CHKRESACS_LEAVE
|
---|
152 | #define LOG_CHKRESACS_LEAVE(access)
|
---|
153 | #endif /* LOG_CHKRESACS_LEAVE */
|
---|
154 |
|
---|
155 | #ifndef LOG_CHKCNTACS_ENTER
|
---|
156 | #define LOG_CHKCNTACS_ENTER(ApplID, CounterID)
|
---|
157 | #endif /* LOG_CHKCNTACS_ENTER */
|
---|
158 |
|
---|
159 | #ifndef LOG_CHKCNTACS_LEAVE
|
---|
160 | #define LOG_CHKCNTACS_LEAVE(access)
|
---|
161 | #endif /* LOG_CHKCNTACS_LEAVE */
|
---|
162 |
|
---|
163 | #ifndef LOG_CHKSCHTBLACS_ENTER
|
---|
164 | #define LOG_CHKSCHTBLACS_ENTER(ApplID, ScheduleTableID)
|
---|
165 | #endif /* LOG_CHKSCHTBLACS_ENTER */
|
---|
166 |
|
---|
167 | #ifndef LOG_CHKSCHTBLACS_LEAVE
|
---|
168 | #define LOG_CHKSCHTBLACS_LEAVE(access)
|
---|
169 | #endif /* LOG_CHKSCHTBLACS_LEAVE */
|
---|
170 |
|
---|
171 | #ifndef LOG_CHKTSKOWN_ENTER
|
---|
172 | #define LOG_CHKTSKOWN_ENTER(TaskID)
|
---|
173 | #endif /* LOG_CHKTSKOWN_ENTER */
|
---|
174 |
|
---|
175 | #ifndef LOG_CHKTSKOWN_LEAVE
|
---|
176 | #define LOG_CHKTSKOWN_LEAVE(owner)
|
---|
177 | #endif /* LOG_CHKTSKOWN_LEAVE */
|
---|
178 |
|
---|
179 | #ifndef LOG_CHKISROWN_ENTER
|
---|
180 | #define LOG_CHKISROWN_ENTER(ISRID)
|
---|
181 | #endif /* LOG_CHKISROWN_ENTER */
|
---|
182 |
|
---|
183 | #ifndef LOG_CHKISROWN_LEAVE
|
---|
184 | #define LOG_CHKISROWN_LEAVE(owner)
|
---|
185 | #endif /* LOG_CHKISROWN_LEAVE */
|
---|
186 |
|
---|
187 | #ifndef LOG_CHKALMOWN_ENTER
|
---|
188 | #define LOG_CHKALMOWN_ENTER(AlarmID)
|
---|
189 | #endif /* LOG_CHKALMOWN_ENTER */
|
---|
190 |
|
---|
191 | #ifndef LOG_CHKALMOWN_LEAVE
|
---|
192 | #define LOG_CHKALMOWN_LEAVE(owner)
|
---|
193 | #endif /* LOG_CHKALMOWN_LEAVE */
|
---|
194 |
|
---|
195 | #ifndef LOG_CHKCNTOWN_ENTER
|
---|
196 | #define LOG_CHKCNTOWN_ENTER(CounterID)
|
---|
197 | #endif /* LOG_CHKCNTOWN_ENTER */
|
---|
198 |
|
---|
199 | #ifndef LOG_CHKCNTOWN_LEAVE
|
---|
200 | #define LOG_CHKCNTOWN_LEAVE(owner)
|
---|
201 | #endif /* LOG_CHKCNTOWN_LEAVE */
|
---|
202 |
|
---|
203 | #ifndef LOG_CHKSCHTBLOWN_ENTER
|
---|
204 | #define LOG_CHKSCHTBLOWN_ENTER(ScheduleTableID)
|
---|
205 | #endif /* LOG_CHKSCHTBLOWN_ENTER */
|
---|
206 |
|
---|
207 | #ifndef LOG_CHKSCHTBLOWN_LEAVE
|
---|
208 | #define LOG_CHKSCHTBLOWN_LEAVE(owner)
|
---|
209 | #endif /* LOG_CHKSCHTBLOWN_LEAVE */
|
---|
210 |
|
---|
211 | #ifndef LOG_ALLOWACCESS_ENTER
|
---|
212 | #define LOG_ALLOWACCESS_ENTER()
|
---|
213 | #endif /* LOG_ALLOWACCESS_ENTER */
|
---|
214 |
|
---|
215 | #ifndef LOG_ALLOWACCESS_LEAVE
|
---|
216 | #define LOG_ALLOWACCESS_LEAVE(ercd)
|
---|
217 | #endif /* LOG_ALLOWACCESS_LEAVE */
|
---|
218 |
|
---|
219 | #ifndef LOG_TERMINATEAPPLICATION_ENTER
|
---|
220 | #define LOG_TERMINATEAPPLICATION_ENTER(Application, RestartOption)
|
---|
221 | #endif /* LOG_TERMINATEAPPLICATION_ENTER */
|
---|
222 |
|
---|
223 | #ifndef LOG_TERMINATEAPPLICATION_LEAVE
|
---|
224 | #define LOG_TERMINATEAPPLICATION_LEAVE(ercd)
|
---|
225 | #endif /* LOG_TERMINATEAPPLICATION_LEAVE */
|
---|
226 |
|
---|
227 | #ifdef TOPPERS_force_term_osap
|
---|
228 | /* å
|
---|
229 | é¨é¢æ°ã®ãããã¿ã¤ãå®£è¨ */
|
---|
230 | static void force_term_osap_main(void);
|
---|
231 | #endif /* TOPPERS_force_term_osap */
|
---|
232 |
|
---|
233 | #ifdef TOPPERS_osap_initialize
|
---|
234 | /*
|
---|
235 | * å®è¡ä¸ã®OSã¢ããªã±ã¼ã·ã§ã³
|
---|
236 | */
|
---|
237 | OSAPCB *p_runosap;
|
---|
238 |
|
---|
239 | /*
|
---|
240 | * OSã¢ããªã±ã¼ã·ã§ã³ç®¡çãããã¯åæå
|
---|
241 | */
|
---|
242 | void
|
---|
243 | osap_initialize(void)
|
---|
244 | {
|
---|
245 | ApplicationType i;
|
---|
246 | OSAPCB *p_osapcb;
|
---|
247 |
|
---|
248 | p_runosap = NULL;
|
---|
249 | for (i = 0U; i < tnum_osap; i++) {
|
---|
250 | p_osapcb = &osapcb_table[i];
|
---|
251 | p_osapcb->p_osapinib = &osapinib_table[i];
|
---|
252 | p_osapcb->osap_stat = APPLICATION_ACCESSIBLE;
|
---|
253 | }
|
---|
254 | }
|
---|
255 |
|
---|
256 | #endif /* TOPPERS_osap_initialize */
|
---|
257 |
|
---|
258 | /*
|
---|
259 | * å®è¡ç¶æ
|
---|
260 | ã®OSã¢ããªã±ã¼ã·ã§ã³ IDåå¾
|
---|
261 | */
|
---|
262 | #ifdef TOPPERS_GetApplicationID
|
---|
263 |
|
---|
264 | ApplicationType
|
---|
265 | GetApplicationID(void)
|
---|
266 | {
|
---|
267 | ApplicationType id;
|
---|
268 | StatusType ercd;
|
---|
269 |
|
---|
270 | LOG_GETOSAPID_ENTER();
|
---|
271 |
|
---|
272 | CHECK_CALLEVEL(CALLEVEL_GETAPPLICATIONID);
|
---|
273 |
|
---|
274 | id = (p_runosap == NULL) ? INVALID_OSAPPLICATION : OSAPID(p_runosap);
|
---|
275 |
|
---|
276 | exit_finish:
|
---|
277 | LOG_GETOSAPID_LEAVE(id);
|
---|
278 | return(id);
|
---|
279 |
|
---|
280 | #ifdef CFG_USE_ERRORHOOK
|
---|
281 | exit_errorhook:
|
---|
282 | x_nested_lock_os_int();
|
---|
283 | call_errorhook(ercd, OSServiceId_GetApplicationID);
|
---|
284 | x_nested_unlock_os_int();
|
---|
285 | #endif /* CFG_USE_ERRORHOOK */
|
---|
286 |
|
---|
287 | exit_no_errorhook:
|
---|
288 | id = INVALID_OSAPPLICATION;
|
---|
289 | goto exit_finish;
|
---|
290 | }
|
---|
291 |
|
---|
292 | #endif /* TOPPERS_GetApplicationID */
|
---|
293 |
|
---|
294 | /*
|
---|
295 | * ã¢ããªã±ã¼ã·ã§ã³ãå©ç¨å¯è½ãªç¶æ
|
---|
296 | ã«ããã·ã¹ãã ãµã¼ãã¹
|
---|
297 | */
|
---|
298 | #ifdef TOPPERS_GetApplicationState
|
---|
299 |
|
---|
300 | StatusType
|
---|
301 | GetApplicationState(ApplicationType Application, ApplicationStateRefType Value)
|
---|
302 | {
|
---|
303 | StatusType ercd = E_OK;
|
---|
304 | OSAPCB *p_osapcb;
|
---|
305 |
|
---|
306 | LOG_GETAST_ENTER(Application);
|
---|
307 |
|
---|
308 | CHECK_CALLEVEL(CALLEVEL_GETAPPLICATIONSTATE);
|
---|
309 | CHECK_PARAM_POINTER(Value);
|
---|
310 | CHECK_MEM_WRITE(Value, ApplicationStateType);
|
---|
311 | CHECK_ID(Application < tnum_osap);
|
---|
312 |
|
---|
313 | p_osapcb = get_osapcb(Application);
|
---|
314 | *Value = p_osapcb->osap_stat;
|
---|
315 |
|
---|
316 | exit_no_errorhook:
|
---|
317 | LOG_GETAST_LEAVE(ercd, Value);
|
---|
318 | return(ercd);
|
---|
319 |
|
---|
320 | #ifdef CFG_USE_ERRORHOOK
|
---|
321 | exit_errorhook:
|
---|
322 | x_nested_lock_os_int();
|
---|
323 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
324 | _errorhook_par1.applid = Application;
|
---|
325 | _errorhook_par2.p_appstat = Value;
|
---|
326 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
327 | call_errorhook(ercd, OSServiceId_GetApplicationState);
|
---|
328 | x_nested_unlock_os_int();
|
---|
329 | goto exit_no_errorhook;
|
---|
330 | #endif /* CFG_USE_ERRORHOOK */
|
---|
331 | }
|
---|
332 |
|
---|
333 | #endif /* TOPPERS_GetApplicationState */
|
---|
334 |
|
---|
335 | #ifdef TOPPERS_CallTrustedFunction
|
---|
336 |
|
---|
337 | StatusType
|
---|
338 | CallTrustedFunction(TrustedFunctionIndexType FunctionIndex,
|
---|
339 | TrustedFunctionParameterRefType FunctionParams)
|
---|
340 | {
|
---|
341 | StatusType ercd = E_OK;
|
---|
342 | const TFINIB *p_tfinib;
|
---|
343 | boolean saved_run_trusted;
|
---|
344 | #ifdef CFG_USE_PROTECTIONHOOK
|
---|
345 | boolean saved_calltfn;
|
---|
346 | #endif /* CFG_USE_PROTECTIONHOOK */
|
---|
347 |
|
---|
348 | LOG_CALTFN_ENTER(FunctionIndex);
|
---|
349 |
|
---|
350 | CHECK_DISABLEDINT();
|
---|
351 | CHECK_CALLEVEL(CALLEVEL_CALLTRUSTEDFUNCTION);
|
---|
352 |
|
---|
353 | /* ãã¡ã³ã¯ã·ã§ã³IDã®ãã§ã㯠*/
|
---|
354 | CHECK_SERVICEID(FunctionIndex < tnum_tfn);
|
---|
355 |
|
---|
356 | /* 使ç¨ããã¹ã¿ãã¯ã®ãã§ã㯠*/
|
---|
357 | p_tfinib = &(tfinib_table[FunctionIndex]);
|
---|
358 | ercd = trustedfunc_stack_check(p_tfinib->tf_stksz);
|
---|
359 | CHECK_NO_ERCD(ercd == E_OK);
|
---|
360 |
|
---|
361 | saved_run_trusted = run_trusted;
|
---|
362 | run_trusted = TRUE;
|
---|
363 |
|
---|
364 | #ifdef CFG_USE_PROTECTIONHOOK
|
---|
365 | /* ä¿¡é ¼é¢æ°å¼ã³åºãä¸ãã©ã°è¨å® */
|
---|
366 | if (callevel_stat == TCL_TASK) {
|
---|
367 | saved_calltfn = p_runtsk->calltfn;
|
---|
368 | p_runtsk->calltfn = TRUE;
|
---|
369 | }
|
---|
370 | else {
|
---|
371 | saved_calltfn = p_runisr->calltfn;
|
---|
372 | p_runisr->calltfn = TRUE;
|
---|
373 | }
|
---|
374 | #endif /* CFG_USE_PROTECTIONHOOK */
|
---|
375 |
|
---|
376 | LOG_TFN_ENTER(FunctionIndex);
|
---|
377 | /* ä¿¡é ¼é¢æ°å®è¡ */
|
---|
378 | ercd = p_tfinib->trs_func(FunctionIndex, FunctionParams);
|
---|
379 | LOG_TFN_LEAVE(FunctionIndex, ercd);
|
---|
380 |
|
---|
381 | #ifdef CFG_USE_STACKMONITORING
|
---|
382 | if ((callevel_stat & TCL_ISR2) != TCL_NULL) {
|
---|
383 | if ((*TOPPERS_ISTK_MAGIC_REGION(_ostk, _ostksz)) != STACK_MAGIC_NUMBER) {
|
---|
384 | x_nested_lock_os_int();
|
---|
385 | pre_protection_supervised = TRUE;
|
---|
386 | call_protectionhk_main(E_OS_STACKFAULT);
|
---|
387 | ASSERT_NO_REACHED;
|
---|
388 | }
|
---|
389 | }
|
---|
390 | else {
|
---|
391 | if ((*TOPPERS_SSTK_MAGIC_REGION(p_runtsk->p_tinib)) != STACK_MAGIC_NUMBER) {
|
---|
392 | x_nested_lock_os_int();
|
---|
393 | pre_protection_supervised = TRUE;
|
---|
394 | call_protectionhk_main_stkchg(E_OS_STACKFAULT);
|
---|
395 | ASSERT_NO_REACHED;
|
---|
396 | }
|
---|
397 | }
|
---|
398 | #endif /* CFG_USE_STACKMONITORING */
|
---|
399 |
|
---|
400 | #ifdef CFG_USE_PROTECTIONHOOK
|
---|
401 | /* ä¿¡é ¼é¢æ°å¼ã³åºãä¸ãã©ã°æ»ã */
|
---|
402 | if (callevel_stat == TCL_TASK) {
|
---|
403 | p_runtsk->calltfn = saved_calltfn;
|
---|
404 | }
|
---|
405 | else {
|
---|
406 | p_runisr->calltfn = saved_calltfn;
|
---|
407 | }
|
---|
408 | #endif /* CFG_USE_PROTECTIONHOOK */
|
---|
409 |
|
---|
410 | run_trusted = saved_run_trusted;
|
---|
411 |
|
---|
412 | /* ä¿¡é ¼é¢æ°ãã¨ã©ã¼ã«ãªã£ãå ´åãã¨ã©ã¼ããã¯ãå¼ã³åºã */
|
---|
413 | CHECK_NO_ERCD(ercd == E_OK);
|
---|
414 |
|
---|
415 | exit_no_errorhook:
|
---|
416 | LOG_CALTFN_LEAVE(ercd);
|
---|
417 | return(ercd);
|
---|
418 |
|
---|
419 | #ifdef CFG_USE_ERRORHOOK
|
---|
420 | exit_errorhook:
|
---|
421 | x_nested_lock_os_int();
|
---|
422 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
423 | _errorhook_par1.tfnid = FunctionIndex;
|
---|
424 | _errorhook_par2.tfnpr = FunctionParams;
|
---|
425 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
426 | call_errorhook(ercd, OSServiceId_CallTrustedFunction);
|
---|
427 | x_nested_unlock_os_int();
|
---|
428 | goto exit_no_errorhook;
|
---|
429 | #endif /* CFG_USE_ERRORHOOK */
|
---|
430 | }
|
---|
431 |
|
---|
432 | #endif /* TOPPERS_CallTrustedFunction */
|
---|
433 |
|
---|
434 | /*
|
---|
435 | * ã¢ã¯ã»ã¹ãã§ãã¯é¢æ°
|
---|
436 | */
|
---|
437 |
|
---|
438 | /*
|
---|
439 | * OSã¢ããªã±ã¼ã·ã§ã³ã®ãªãã¸ã§ã¯ãã®ã¢ã¯ã»ã¹æ¨©éãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
440 | */
|
---|
441 |
|
---|
442 | /*
|
---|
443 | * ãããããããã§ãã¯ãã¯ã
|
---|
444 | * ãã®ãã¡ã¤ã«å
|
---|
445 | ã®ã¿ã§ä½¿ç¨ããããï¼ããã§å®ç¾©ãã¦ãã
|
---|
446 | */
|
---|
447 |
|
---|
448 | #define CHECK_OSAP_ACS(p_osapinib, btmp) (ObjectAccessType) ((((p_osapinib)->osap_trusted) != FALSE) || \
|
---|
449 | (((p_osapinib)->btptn & (btmp)) != 0U))
|
---|
450 |
|
---|
451 | /*
|
---|
452 | * ã¿ã¹ã¯ç¨ã¢ã¯ã»ã¹æ¨©éãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
453 | */
|
---|
454 | #ifdef TOPPERS_CheckTaskAccess
|
---|
455 |
|
---|
456 | ObjectAccessType
|
---|
457 | CheckTaskAccess(ApplicationType ApplID, TaskType TaskID)
|
---|
458 | {
|
---|
459 | ObjectAccessType access;
|
---|
460 | StatusType ercd;
|
---|
461 | TCB *p_tcb;
|
---|
462 |
|
---|
463 | LOG_CHKTSKACS_ENTER(ApplID, TaskID);
|
---|
464 |
|
---|
465 | CHECK_DISABLEDINT();
|
---|
466 | CHECK_CALLEVEL(CALLEVEL_CHECKOBJECTACCESS);
|
---|
467 | CHECK_ID(ApplID < tnum_osap);
|
---|
468 | CHECK_ID(TaskID < tnum_task);
|
---|
469 |
|
---|
470 | p_tcb = get_tcb(TaskID);
|
---|
471 |
|
---|
472 | access = CHECK_OSAP_ACS(get_osapinib(ApplID), p_tcb->p_tinib->acsbtmp);
|
---|
473 |
|
---|
474 | exit_finish:
|
---|
475 | LOG_CHKTSKACS_LEAVE(access);
|
---|
476 | return(access);
|
---|
477 |
|
---|
478 | #ifdef CFG_USE_ERRORHOOK
|
---|
479 | exit_errorhook:
|
---|
480 | x_nested_lock_os_int();
|
---|
481 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
482 | _errorhook_par1.applid = ApplID;
|
---|
483 | _errorhook_par2.tskid = TaskID;
|
---|
484 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
485 | call_errorhook(ercd, OSServiceId_CheckTaskAccess);
|
---|
486 | x_nested_unlock_os_int();
|
---|
487 | #endif /* CFG_USE_ERRORHOOK */
|
---|
488 |
|
---|
489 | exit_no_errorhook:
|
---|
490 | access = NO_ACCESS;
|
---|
491 | goto exit_finish;
|
---|
492 | }
|
---|
493 |
|
---|
494 | #endif /* TOPPERS_CheckTaskAccess */
|
---|
495 |
|
---|
496 | /*
|
---|
497 | * ISRç¨ã¢ã¯ã»ã¹æ¨©éãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
498 | */
|
---|
499 | #ifdef TOPPERS_CheckISRAccess
|
---|
500 |
|
---|
501 | ObjectAccessType
|
---|
502 | CheckISRAccess(ApplicationType ApplID, ISRType ISRID)
|
---|
503 | {
|
---|
504 | ObjectAccessType access;
|
---|
505 | StatusType ercd;
|
---|
506 | ISRCB *p_isrcb;
|
---|
507 |
|
---|
508 | LOG_CHKISRACS_ENTER(ApplID, ISRID);
|
---|
509 |
|
---|
510 | CHECK_DISABLEDINT();
|
---|
511 | CHECK_CALLEVEL(CALLEVEL_CHECKOBJECTACCESS);
|
---|
512 | CHECK_ID(ApplID < tnum_osap);
|
---|
513 | CHECK_ID(ISRID < tnum_isr2);
|
---|
514 |
|
---|
515 | p_isrcb = get_isrcb(ISRID);
|
---|
516 |
|
---|
517 | access = CHECK_OSAP_ACS(get_osapinib(ApplID), p_isrcb->p_isrinib->acsbtmp);
|
---|
518 |
|
---|
519 | exit_finish:
|
---|
520 | LOG_CHKISRACS_LEAVE(access);
|
---|
521 | return(access);
|
---|
522 |
|
---|
523 | #ifdef CFG_USE_ERRORHOOK
|
---|
524 | exit_errorhook:
|
---|
525 | x_nested_lock_os_int();
|
---|
526 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
527 | _errorhook_par1.applid = ApplID;
|
---|
528 | _errorhook_par2.isrid = ISRID;
|
---|
529 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
530 | call_errorhook(ercd, OSServiceId_CheckISRAccess);
|
---|
531 | x_nested_unlock_os_int();
|
---|
532 | #endif /* CFG_USE_ERRORHOOK */
|
---|
533 |
|
---|
534 | exit_no_errorhook:
|
---|
535 | access = NO_ACCESS;
|
---|
536 | goto exit_finish;
|
---|
537 | }
|
---|
538 |
|
---|
539 | #endif /* TOPPERS_CheckISRAccess */
|
---|
540 |
|
---|
541 | /*
|
---|
542 | * ã¢ã©ã¼ã ç¨ã¢ã¯ã»ã¹æ¨©éãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
543 | */
|
---|
544 | #ifdef TOPPERS_CheckAlarmAccess
|
---|
545 |
|
---|
546 | ObjectAccessType
|
---|
547 | CheckAlarmAccess(ApplicationType ApplID, AlarmType AlarmID)
|
---|
548 | {
|
---|
549 | ObjectAccessType access;
|
---|
550 | StatusType ercd;
|
---|
551 | ALMCB *p_almcb;
|
---|
552 |
|
---|
553 | LOG_CHKALMACS_ENTER(ApplID, AlarmID);
|
---|
554 |
|
---|
555 | CHECK_DISABLEDINT();
|
---|
556 | CHECK_CALLEVEL(CALLEVEL_CHECKOBJECTACCESS);
|
---|
557 | CHECK_ID(ApplID < tnum_osap);
|
---|
558 | CHECK_ID(AlarmID < tnum_alarm);
|
---|
559 |
|
---|
560 | p_almcb = get_almcb(AlarmID);
|
---|
561 |
|
---|
562 | access = CHECK_OSAP_ACS(get_osapinib(ApplID), p_almcb->p_alminib->acsbtmp);
|
---|
563 |
|
---|
564 | exit_finish:
|
---|
565 | LOG_CHKALMACS_LEAVE(access);
|
---|
566 | return(access);
|
---|
567 |
|
---|
568 | #ifdef CFG_USE_ERRORHOOK
|
---|
569 | exit_errorhook:
|
---|
570 | x_nested_lock_os_int();
|
---|
571 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
572 | _errorhook_par1.applid = ApplID;
|
---|
573 | _errorhook_par2.almid = AlarmID;
|
---|
574 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
575 | call_errorhook(ercd, OSServiceId_CheckAlarmAccess);
|
---|
576 | x_nested_unlock_os_int();
|
---|
577 | #endif /* CFG_USE_ERRORHOOK */
|
---|
578 |
|
---|
579 | exit_no_errorhook:
|
---|
580 | access = NO_ACCESS;
|
---|
581 | goto exit_finish;
|
---|
582 | }
|
---|
583 |
|
---|
584 | #endif /* TOPPERS_CheckAlarmAccess */
|
---|
585 |
|
---|
586 | /*
|
---|
587 | * ãªã½ã¼ã¹ç¨ã¢ã¯ã»ã¹æ¨©éãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
588 | */
|
---|
589 | #ifdef TOPPERS_CheckResourceAccess
|
---|
590 |
|
---|
591 | ObjectAccessType
|
---|
592 | CheckResourceAccess(ApplicationType ApplID, ResourceType ResID)
|
---|
593 | {
|
---|
594 | ObjectAccessType access;
|
---|
595 | StatusType ercd;
|
---|
596 | RESCB *p_rescb;
|
---|
597 |
|
---|
598 | LOG_CHKRESACS_ENTER(ApplID, ResID);
|
---|
599 |
|
---|
600 | CHECK_DISABLEDINT();
|
---|
601 | CHECK_CALLEVEL(CALLEVEL_CHECKOBJECTACCESS);
|
---|
602 | CHECK_ID(ApplID < tnum_osap);
|
---|
603 | CHECK_ID(ResID < tnum_stdresource);
|
---|
604 |
|
---|
605 | p_rescb = get_rescb(ResID);
|
---|
606 | access = CHECK_OSAP_ACS(get_osapinib(ApplID), p_rescb->p_resinib->acsbtmp);
|
---|
607 |
|
---|
608 | exit_finish:
|
---|
609 | LOG_CHKRESACS_LEAVE(access);
|
---|
610 | return(access);
|
---|
611 |
|
---|
612 | #ifdef CFG_USE_ERRORHOOK
|
---|
613 | exit_errorhook:
|
---|
614 | x_nested_lock_os_int();
|
---|
615 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
616 | _errorhook_par1.applid = ApplID;
|
---|
617 | _errorhook_par2.resid = ResID;
|
---|
618 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
619 | call_errorhook(ercd, OSServiceId_CheckResourceAccess);
|
---|
620 | x_nested_unlock_os_int();
|
---|
621 | #endif /* CFG_USE_ERRORHOOK */
|
---|
622 |
|
---|
623 | exit_no_errorhook:
|
---|
624 | access = NO_ACCESS;
|
---|
625 | goto exit_finish;
|
---|
626 | }
|
---|
627 |
|
---|
628 | #endif /* TOPPERS_CheckResourceAccess */
|
---|
629 |
|
---|
630 | /*
|
---|
631 | * ã«ã¦ã³ã¿ç¨ã¢ã¯ã»ã¹æ¨©éãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
632 | */
|
---|
633 | #ifdef TOPPERS_CheckCounterAccess
|
---|
634 |
|
---|
635 | ObjectAccessType
|
---|
636 | CheckCounterAccess(ApplicationType ApplID, CounterType CounterID)
|
---|
637 | {
|
---|
638 | ObjectAccessType access;
|
---|
639 | StatusType ercd;
|
---|
640 | CNTCB *p_cntcb;
|
---|
641 |
|
---|
642 | LOG_CHKCNTACS_ENTER(ApplID, CounterID);
|
---|
643 |
|
---|
644 | CHECK_DISABLEDINT();
|
---|
645 | CHECK_CALLEVEL(CALLEVEL_CHECKOBJECTACCESS);
|
---|
646 | CHECK_ID(ApplID < tnum_osap);
|
---|
647 | CHECK_ID(CounterID < tnum_counter);
|
---|
648 |
|
---|
649 | p_cntcb = get_cntcb(CounterID);
|
---|
650 |
|
---|
651 | access = CHECK_OSAP_ACS(get_osapinib(ApplID), p_cntcb->p_cntinib->acsbtmp);
|
---|
652 |
|
---|
653 | exit_finish:
|
---|
654 | LOG_CHKCNTACS_LEAVE(access);
|
---|
655 | return(access);
|
---|
656 |
|
---|
657 | #ifdef CFG_USE_ERRORHOOK
|
---|
658 | exit_errorhook:
|
---|
659 | x_nested_lock_os_int();
|
---|
660 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
661 | _errorhook_par1.applid = ApplID;
|
---|
662 | _errorhook_par2.cntid = CounterID;
|
---|
663 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
664 | call_errorhook(ercd, OSServiceId_CheckCounterAccess);
|
---|
665 | x_nested_unlock_os_int();
|
---|
666 | #endif /* CFG_USE_ERRORHOOK */
|
---|
667 |
|
---|
668 | exit_no_errorhook:
|
---|
669 | access = NO_ACCESS;
|
---|
670 | goto exit_finish;
|
---|
671 | }
|
---|
672 |
|
---|
673 | #endif /* TOPPERS_CheckCounterAccess */
|
---|
674 |
|
---|
675 | /*
|
---|
676 | * ã¹ã±ã¸ã¥ã¼ã«ãã¼ãã«ç¨ã¢ã¯ã»ã¹æ¨©éãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
677 | */
|
---|
678 | #ifdef TOPPERS_CheckScheduleTableAccess
|
---|
679 |
|
---|
680 | ObjectAccessType
|
---|
681 | CheckScheduleTableAccess(ApplicationType ApplID, ScheduleTableType ScheduleTableID)
|
---|
682 | {
|
---|
683 | ObjectAccessType access;
|
---|
684 | StatusType ercd;
|
---|
685 | SCHTBLCB *p_schtblcb;
|
---|
686 |
|
---|
687 | LOG_CHKSCHTBLACS_ENTER(ApplID, ScheduleTableID);
|
---|
688 |
|
---|
689 | CHECK_DISABLEDINT();
|
---|
690 | CHECK_CALLEVEL(CALLEVEL_CHECKOBJECTACCESS);
|
---|
691 | CHECK_ID(ApplID < tnum_osap);
|
---|
692 | CHECK_ID(ScheduleTableID < tnum_scheduletable);
|
---|
693 |
|
---|
694 | p_schtblcb = get_schtblcb(ScheduleTableID);
|
---|
695 |
|
---|
696 | access = CHECK_OSAP_ACS(get_osapinib(ApplID), p_schtblcb->p_schtblinib->acsbtmp);
|
---|
697 |
|
---|
698 | exit_finish:
|
---|
699 | LOG_CHKSCHTBLACS_LEAVE(access);
|
---|
700 | return(access);
|
---|
701 |
|
---|
702 | #ifdef CFG_USE_ERRORHOOK
|
---|
703 | exit_errorhook:
|
---|
704 | x_nested_lock_os_int();
|
---|
705 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
706 | _errorhook_par1.applid = ApplID;
|
---|
707 | _errorhook_par2.schtblid = ScheduleTableID;
|
---|
708 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
709 | call_errorhook(ercd, OSServiceId_CheckScheduleTableAccess);
|
---|
710 | x_nested_unlock_os_int();
|
---|
711 | #endif /* CFG_USE_ERRORHOOK */
|
---|
712 |
|
---|
713 | exit_no_errorhook:
|
---|
714 | access = NO_ACCESS;
|
---|
715 | goto exit_finish;
|
---|
716 | }
|
---|
717 |
|
---|
718 | #endif /* TOPPERS_CheckScheduleTableAccess */
|
---|
719 |
|
---|
720 | /*
|
---|
721 | * OSã¢ããªã±ã¼ã·ã§ã³ã®ãªãã¸ã§ã¯ãã®ææãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
722 | */
|
---|
723 |
|
---|
724 | /*
|
---|
725 | * ã¿ã¹ã¯ç¨ãªãã¸ã§ã¯ãææãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
726 | */
|
---|
727 | #ifdef TOPPERS_CheckTaskOwnership
|
---|
728 |
|
---|
729 | ApplicationType
|
---|
730 | CheckTaskOwnership(TaskType TaskID)
|
---|
731 | {
|
---|
732 | ApplicationType owner;
|
---|
733 | StatusType ercd;
|
---|
734 | TCB *p_tcb;
|
---|
735 |
|
---|
736 | LOG_CHKTSKOWN_ENTER(TaskID);
|
---|
737 |
|
---|
738 | CHECK_DISABLEDINT();
|
---|
739 | CHECK_CALLEVEL(CALLEVEL_CHECKOBJECTOWNERSHIP);
|
---|
740 | CHECK_ID(TaskID < tnum_task);
|
---|
741 |
|
---|
742 | p_tcb = get_tcb(TaskID);
|
---|
743 | owner = OSAPID(p_tcb->p_tinib->p_osapcb);
|
---|
744 |
|
---|
745 | exit_finish:
|
---|
746 | LOG_CHKTSKOWN_LEAVE(owner);
|
---|
747 | return(owner);
|
---|
748 |
|
---|
749 | #ifdef CFG_USE_ERRORHOOK
|
---|
750 | exit_errorhook:
|
---|
751 | x_nested_lock_os_int();
|
---|
752 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
753 | _errorhook_par1.tskid = TaskID;
|
---|
754 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
755 | call_errorhook(ercd, OSServiceId_CheckTaskOwnership);
|
---|
756 | x_nested_unlock_os_int();
|
---|
757 | #endif /* CFG_USE_ERRORHOOK */
|
---|
758 |
|
---|
759 | exit_no_errorhook:
|
---|
760 | owner = INVALID_OSAPPLICATION;
|
---|
761 | goto exit_finish;
|
---|
762 | }
|
---|
763 |
|
---|
764 | #endif /* TOPPERS_CheckTaskOwnership */
|
---|
765 |
|
---|
766 | /*
|
---|
767 | * ISRç¨ãªãã¸ã§ã¯ãææãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
768 | */
|
---|
769 | #ifdef TOPPERS_CheckISROwnership
|
---|
770 |
|
---|
771 | ApplicationType
|
---|
772 | CheckISROwnership(ISRType ISRID)
|
---|
773 | {
|
---|
774 | ApplicationType owner;
|
---|
775 | StatusType ercd;
|
---|
776 | ISRCB *p_isrcb;
|
---|
777 |
|
---|
778 | LOG_CHKISROWN_ENTER(ISRID);
|
---|
779 |
|
---|
780 | CHECK_DISABLEDINT();
|
---|
781 | CHECK_CALLEVEL(CALLEVEL_CHECKOBJECTOWNERSHIP);
|
---|
782 | CHECK_ID(ISRID < tnum_isr2);
|
---|
783 |
|
---|
784 | p_isrcb = get_isrcb(ISRID);
|
---|
785 | owner = OSAPID(p_isrcb->p_isrinib->p_osapcb);
|
---|
786 |
|
---|
787 | exit_finish:
|
---|
788 | LOG_CHKISROWN_LEAVE(owner);
|
---|
789 | return(owner);
|
---|
790 |
|
---|
791 | #ifdef CFG_USE_ERRORHOOK
|
---|
792 | exit_errorhook:
|
---|
793 | x_nested_lock_os_int();
|
---|
794 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
795 | _errorhook_par1.isrid = ISRID;
|
---|
796 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
797 | call_errorhook(ercd, OSServiceId_CheckISROwnership);
|
---|
798 | x_nested_unlock_os_int();
|
---|
799 | #endif /* CFG_USE_ERRORHOOK */
|
---|
800 |
|
---|
801 | exit_no_errorhook:
|
---|
802 | owner = INVALID_OSAPPLICATION;
|
---|
803 | goto exit_finish;
|
---|
804 | }
|
---|
805 |
|
---|
806 | #endif /* TOPPERS_CheckISROwnership */
|
---|
807 |
|
---|
808 | /*
|
---|
809 | * ã¢ã©ã¼ã ç¨ãªãã¸ã§ã¯ãææãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
810 | */
|
---|
811 | #ifdef TOPPERS_CheckAlarmOwnership
|
---|
812 |
|
---|
813 | ApplicationType
|
---|
814 | CheckAlarmOwnership(AlarmType AlarmID)
|
---|
815 | {
|
---|
816 | ApplicationType owner;
|
---|
817 | StatusType ercd;
|
---|
818 | ALMCB *p_almcb;
|
---|
819 |
|
---|
820 | LOG_CHKALMOWN_ENTER(AlarmID);
|
---|
821 |
|
---|
822 | CHECK_DISABLEDINT();
|
---|
823 | CHECK_CALLEVEL(CALLEVEL_CHECKOBJECTOWNERSHIP);
|
---|
824 | CHECK_ID(AlarmID < tnum_alarm);
|
---|
825 |
|
---|
826 | p_almcb = get_almcb(AlarmID);
|
---|
827 | owner = OSAPID(p_almcb->p_alminib->p_osapcb);
|
---|
828 |
|
---|
829 | exit_finish:
|
---|
830 | LOG_CHKALMOWN_LEAVE(owner);
|
---|
831 | return(owner);
|
---|
832 |
|
---|
833 | #ifdef CFG_USE_ERRORHOOK
|
---|
834 | exit_errorhook:
|
---|
835 | x_nested_lock_os_int();
|
---|
836 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
837 | _errorhook_par1.almid = AlarmID;
|
---|
838 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
839 | call_errorhook(ercd, OSServiceId_CheckAlarmOwnership);
|
---|
840 | x_nested_unlock_os_int();
|
---|
841 | #endif /* CFG_USE_ERRORHOOK */
|
---|
842 |
|
---|
843 | exit_no_errorhook:
|
---|
844 | owner = INVALID_OSAPPLICATION;
|
---|
845 | goto exit_finish;
|
---|
846 | }
|
---|
847 |
|
---|
848 | #endif /* TOPPERS_CheckAlarmOwnership */
|
---|
849 |
|
---|
850 | /*
|
---|
851 | * ã«ã¦ã³ã¿ç¨ãªãã¸ã§ã¯ãææãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
852 | */
|
---|
853 | #ifdef TOPPERS_CheckCounterOwnership
|
---|
854 |
|
---|
855 | ApplicationType
|
---|
856 | CheckCounterOwnership(CounterType CounterID)
|
---|
857 | {
|
---|
858 | ApplicationType owner;
|
---|
859 | StatusType ercd;
|
---|
860 | CNTCB *p_cntcb;
|
---|
861 |
|
---|
862 | LOG_CHKCNTOWN_ENTER(CounterID);
|
---|
863 |
|
---|
864 | CHECK_DISABLEDINT();
|
---|
865 | CHECK_CALLEVEL(CALLEVEL_CHECKOBJECTOWNERSHIP);
|
---|
866 | CHECK_ID(CounterID < tnum_counter);
|
---|
867 |
|
---|
868 | p_cntcb = get_cntcb(CounterID);
|
---|
869 | owner = OSAPID(p_cntcb->p_cntinib->p_osapcb);
|
---|
870 |
|
---|
871 | exit_finish:
|
---|
872 | LOG_CHKCNTOWN_LEAVE(owner);
|
---|
873 | return(owner);
|
---|
874 |
|
---|
875 | #ifdef CFG_USE_ERRORHOOK
|
---|
876 | exit_errorhook:
|
---|
877 | x_nested_lock_os_int();
|
---|
878 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
879 | _errorhook_par1.cntid = CounterID;
|
---|
880 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
881 | call_errorhook(ercd, OSServiceId_CheckCounterOwnership);
|
---|
882 | x_nested_unlock_os_int();
|
---|
883 | #endif /* CFG_USE_ERRORHOOK */
|
---|
884 |
|
---|
885 | exit_no_errorhook:
|
---|
886 | owner = INVALID_OSAPPLICATION;
|
---|
887 | goto exit_finish;
|
---|
888 | }
|
---|
889 |
|
---|
890 | #endif /* TOPPERS_CheckCounterOwnership */
|
---|
891 |
|
---|
892 | /*
|
---|
893 | * ã¹ã±ã¸ã¥ã¼ã«ãã¼ãã«ç¨ãªãã¸ã§ã¯ãææãã§ãã¯ã·ã¹ãã ãµã¼ãã¹
|
---|
894 | */
|
---|
895 | #ifdef TOPPERS_CheckScheduleTableOwnership
|
---|
896 |
|
---|
897 | ApplicationType
|
---|
898 | CheckScheduleTableOwnership(ScheduleTableType ScheduleTableID)
|
---|
899 | {
|
---|
900 | ApplicationType owner;
|
---|
901 | StatusType ercd;
|
---|
902 | SCHTBLCB *p_schtblcb;
|
---|
903 |
|
---|
904 | LOG_CHKSCHTBLOWN_ENTER(ScheduleTableID);
|
---|
905 |
|
---|
906 | CHECK_DISABLEDINT();
|
---|
907 | CHECK_CALLEVEL(CALLEVEL_CHECKOBJECTOWNERSHIP);
|
---|
908 | CHECK_ID(ScheduleTableID < tnum_scheduletable);
|
---|
909 |
|
---|
910 | p_schtblcb = get_schtblcb(ScheduleTableID);
|
---|
911 | owner = OSAPID(p_schtblcb->p_schtblinib->p_osapcb);
|
---|
912 |
|
---|
913 | exit_finish:
|
---|
914 | LOG_CHKSCHTBLOWN_LEAVE(owner);
|
---|
915 | return(owner);
|
---|
916 |
|
---|
917 | #ifdef CFG_USE_ERRORHOOK
|
---|
918 | exit_errorhook:
|
---|
919 | x_nested_lock_os_int();
|
---|
920 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
921 | _errorhook_par1.schtblid = ScheduleTableID;
|
---|
922 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
923 | call_errorhook(ercd, OSServiceId_CheckScheduleTableOwnership);
|
---|
924 | x_nested_unlock_os_int();
|
---|
925 | #endif /* CFG_USE_ERRORHOOK */
|
---|
926 |
|
---|
927 | exit_no_errorhook:
|
---|
928 | owner = INVALID_OSAPPLICATION;
|
---|
929 | goto exit_finish;
|
---|
930 | }
|
---|
931 |
|
---|
932 | #endif /* TOPPERS_CheckScheduleTableOwnership */
|
---|
933 |
|
---|
934 | /*
|
---|
935 | * èªOSAPãå©ç¨å¯è½ãªç¶æ
|
---|
936 | ã«ãã
|
---|
937 | */
|
---|
938 | #ifdef TOPPERS_AllowAccess
|
---|
939 |
|
---|
940 | StatusType
|
---|
941 | AllowAccess(void)
|
---|
942 | {
|
---|
943 | StatusType ercd = E_OK;
|
---|
944 |
|
---|
945 | LOG_ALLOWACCESS_ENTER();
|
---|
946 |
|
---|
947 | CHECK_DISABLEDINT();
|
---|
948 | CHECK_CALLEVEL(CALLEVEL_ALLOWACCESS);
|
---|
949 | /* ããã«æ¥ãå ´åp_runosap(èªOSAP)ãNULLã§ã¯ãªã */
|
---|
950 | CHECK_STATE(p_runosap->osap_stat == APPLICATION_RESTARTING);
|
---|
951 |
|
---|
952 | x_nested_lock_os_int();
|
---|
953 |
|
---|
954 | p_runosap->osap_stat = APPLICATION_ACCESSIBLE;
|
---|
955 |
|
---|
956 | d_exit_no_errorhook:
|
---|
957 | x_nested_unlock_os_int();
|
---|
958 | exit_no_errorhook:
|
---|
959 | LOG_ALLOWACCESS_LEAVE(ercd);
|
---|
960 | return(ercd);
|
---|
961 |
|
---|
962 | #ifdef CFG_USE_ERRORHOOK
|
---|
963 | exit_errorhook:
|
---|
964 | x_nested_lock_os_int();
|
---|
965 | call_errorhook(ercd, OSServiceId_AllowAccess);
|
---|
966 | goto d_exit_no_errorhook;
|
---|
967 | #endif /* CFG_USE_ERRORHOOK */
|
---|
968 | }
|
---|
969 |
|
---|
970 | #endif /* TOPPERS_AllowAccess */
|
---|
971 |
|
---|
972 | /*
|
---|
973 | * æå®OSAPãçµäº/åèµ·åãã
|
---|
974 | */
|
---|
975 | #ifdef TOPPERS_TerminateApplication
|
---|
976 |
|
---|
977 | StatusType
|
---|
978 | TerminateApplication(ApplicationType Application, RestartType RestartOption)
|
---|
979 | {
|
---|
980 | StatusType ercd = E_OK;
|
---|
981 | OSAPCB *p_osapcb;
|
---|
982 |
|
---|
983 | LOG_TERMINATEAPPLICATION_ENTER(Application, RestartOption);
|
---|
984 |
|
---|
985 | CHECK_DISABLEDINT();
|
---|
986 | CHECK_CALLEVEL(CALLEVEL_TERMINATEAPPLICATION);
|
---|
987 | CHECK_ID((Application < tnum_osap) && (get_osapinib(Application)->osap_trusted == FALSE));
|
---|
988 | p_osapcb = get_osapcb(Application);
|
---|
989 | CHECK_VALUE((RestartOption == NO_RESTART) || ((RestartOption == RESTART) &&
|
---|
990 | (p_osapcb->p_osapinib->p_restart_tcb->p_tinib->task != NULL)));
|
---|
991 |
|
---|
992 | CHECK_ACCESS((run_trusted != FALSE) || (p_osapcb == p_runosap));
|
---|
993 |
|
---|
994 | x_nested_lock_os_int();
|
---|
995 |
|
---|
996 | S_D_CHECK_STATE((p_osapcb->osap_stat == APPLICATION_ACCESSIBLE) ||
|
---|
997 | ((p_osapcb->osap_stat == APPLICATION_RESTARTING) &&
|
---|
998 | (p_osapcb == p_runosap) && (RestartOption == NO_RESTART)));
|
---|
999 |
|
---|
1000 | force_term_osap(p_osapcb, RestartOption);
|
---|
1001 |
|
---|
1002 | d_exit_no_errorhook:
|
---|
1003 | x_nested_unlock_os_int();
|
---|
1004 | exit_no_errorhook:
|
---|
1005 | LOG_TERMINATEAPPLICATION_LEAVE(ercd);
|
---|
1006 | return(ercd);
|
---|
1007 |
|
---|
1008 | #ifdef CFG_USE_ERRORHOOK
|
---|
1009 | exit_errorhook:
|
---|
1010 | x_nested_lock_os_int();
|
---|
1011 | d_exit_errorhook:
|
---|
1012 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
1013 | _errorhook_par1.applid = Application;
|
---|
1014 | _errorhook_par2.restartoption = RestartOption;
|
---|
1015 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
1016 | call_errorhook(ercd, OSServiceId_TerminateApplication);
|
---|
1017 | goto d_exit_no_errorhook;
|
---|
1018 | #endif /* CFG_USE_ERRORHOOK */
|
---|
1019 | }
|
---|
1020 |
|
---|
1021 | #endif /* TOPPERS_TerminateApplication */
|
---|
1022 |
|
---|
1023 | /*
|
---|
1024 | * æå®OSAPãçµäº/åèµ·åããå
|
---|
1025 | é¨é¢æ°
|
---|
1026 | */
|
---|
1027 | #ifdef TOPPERS_force_term_osap
|
---|
1028 |
|
---|
1029 | static void
|
---|
1030 | force_term_osap_main(void)
|
---|
1031 | {
|
---|
1032 | OSAPCB *p_osapcb;
|
---|
1033 |
|
---|
1034 | p_osapcb = p_runosap;
|
---|
1035 |
|
---|
1036 | force_term_osap_counter(p_osapcb);
|
---|
1037 | force_term_osap_task(p_osapcb);
|
---|
1038 |
|
---|
1039 | if (p_osapcb->osap_stat == APPLICATION_RESTARTING) {
|
---|
1040 | (void) make_active(p_osapcb->p_osapinib->p_restart_tcb);
|
---|
1041 | }
|
---|
1042 | /* ä»®ã®ãªã¹ã¿ã¼ãã¿ã¹ã¯ã¯å½¹ç®ãçµããããããã¥ã¼ã®å¦çãå®æ½ */
|
---|
1043 | search_schedtsk();
|
---|
1044 |
|
---|
1045 | /* ã¿ã¹ã¯ã³ã³ããã¹ãã®è¨å® */
|
---|
1046 | callevel_stat = TCL_TASK;
|
---|
1047 |
|
---|
1048 | if (sus_os_cnt > 0U) {
|
---|
1049 | sus_os_cnt = 0U;
|
---|
1050 | x_nested_unlock_os_int();
|
---|
1051 | }
|
---|
1052 | /* èªOSAPããå¼ã³åºãã®ããï¼å¼ã³åºãå
|
---|
1053 | ã«æ»ããªã */
|
---|
1054 | exit_and_dispatch_nohook();
|
---|
1055 | }
|
---|
1056 |
|
---|
1057 | /*
|
---|
1058 | * ãªã¹ã¿ã¼ãã¿ã¹ã¯ã®pcã«force_term_osap_mainã®ã¢ãã¬ã¹ãæ ¼ç´ãã
|
---|
1059 | */
|
---|
1060 | void
|
---|
1061 | force_term_osap(OSAPCB *p_osapcb, RestartType RestartOption)
|
---|
1062 | {
|
---|
1063 | TCB *p_tcb;
|
---|
1064 | PriorityType remove_task_pri;
|
---|
1065 |
|
---|
1066 | /* osap_statã®æ´æ° */
|
---|
1067 | if (RestartOption == RESTART) {
|
---|
1068 | p_osapcb->osap_stat = APPLICATION_RESTARTING;
|
---|
1069 | if (p_osapcb->p_osapinib->p_restart_tcb->p_tinib->task == NULL) {
|
---|
1070 | /* ãªã¹ã¿ã¼ãã¿ã¹ã¯ã®è¨å®ããªãã«ããããããï¼*/
|
---|
1071 | /* RESTARTãªãã·ã§ã³ãè¨å®ããå ´åã¯ã·ã£ãããã¦ã³ãå®æ½ãã */
|
---|
1072 | internal_shutdownos(E_OS_PROTECTION_FATAL);
|
---|
1073 | }
|
---|
1074 | }
|
---|
1075 | else {
|
---|
1076 | p_osapcb->osap_stat = APPLICATION_TERMINATED;
|
---|
1077 | }
|
---|
1078 |
|
---|
1079 | force_term_osap_alarm(p_osapcb);
|
---|
1080 | force_term_osap_schtbl(p_osapcb);
|
---|
1081 | /*ISRãåæ¢*/
|
---|
1082 | force_term_osap_isr(p_osapcb);
|
---|
1083 |
|
---|
1084 | p_tcb = p_osapcb->p_osapinib->p_restart_tcb;
|
---|
1085 |
|
---|
1086 | /* ãªã¹ã¿ã¼ãã¿ã¹ã¯ãæ¢ã«READYç¶æ
|
---|
1087 | ã®å ´åã¯ã¬ãã£ãã¥ã¼ããåé¤ãã */
|
---|
1088 | if (p_tcb->tstat == READY) {
|
---|
1089 | /* ãªã¹ã¿ã¼ãã¿ã¹ã¯ã®çµäº */
|
---|
1090 | p_tcb->actcnt = 0U;
|
---|
1091 | #ifdef CFG_USE_PROTECTIONHOOK
|
---|
1092 | p_tcb->calltfn = FALSE;
|
---|
1093 | #endif /* CFG_USE_PROTECTIONHOOK */
|
---|
1094 | /* curpriã¨inipriãç°ãªãå¤ã§ã¬ãã£ãã¥ã¼ã«ç¹ããã¦ããå ´åã¸ã®å¯¾å¿ */
|
---|
1095 | remove_task_pri = p_tcb->curpri;
|
---|
1096 |
|
---|
1097 | /* ãªã½ã¼ã¹ç¢ºä¿ããã¾ã¾ã®å ´åï¼ãªã½ã¼ã¹è§£æ¾ */
|
---|
1098 | release_taskresources(p_tcb);
|
---|
1099 |
|
---|
1100 | /* ã«ã¦ã³ã¿ã®ç¶æ
|
---|
1101 | ãåæåãã */
|
---|
1102 | cancel_taskcounters(p_tcb);
|
---|
1103 |
|
---|
1104 | /* 対象ã¿ã¹ã¯ãSUSPENDç¶æ
|
---|
1105 | ã¨ãï¼ã¬ãã£ãã¥ã¼ããåé¤ãã */
|
---|
1106 | p_tcb->tstat = SUSPENDED;
|
---|
1107 | if (p_tcb != p_schedtsk) {
|
---|
1108 | remove_task_from_queue(p_tcb, remove_task_pri);
|
---|
1109 | /* p_schedtskããã¥ã¼ã®å
|
---|
1110 | é ã«éé¿ */
|
---|
1111 | move_schedtsk();
|
---|
1112 | }
|
---|
1113 | }
|
---|
1114 | else if (p_schedtsk != NULL) {
|
---|
1115 | /* p_schedtskãNULLã§ãªããã°ï¼ãã¥ã¼ã®å
|
---|
1116 | é ã«éé¿ */
|
---|
1117 | move_schedtsk();
|
---|
1118 | }
|
---|
1119 | else {
|
---|
1120 | /* p_schedtskãNULLã®å ´åã¯ä½ãããªã */
|
---|
1121 | }
|
---|
1122 |
|
---|
1123 | /* ãªã¹ã¿ã¼ãã¿ã¹ã¯ã®pcã«force_term_osap_mainã®ã¢ãã¬ã¹ãæ ¼ç´ */
|
---|
1124 | activate_force_term_osap_main(p_tcb);
|
---|
1125 |
|
---|
1126 | /* curpriãæé«åªå
|
---|
1127 | 度ã«å¤æ´ */
|
---|
1128 | p_tcb->curpri = TPRI_MAXTASK;
|
---|
1129 |
|
---|
1130 | /* p_schedtskã«p_restart_tcbãæ ¼ç´ */
|
---|
1131 | p_schedtsk = p_tcb;
|
---|
1132 |
|
---|
1133 | #if 0
|
---|
1134 | if ((callevel_stat & TCL_ISR2) != TCL_NULL) {
|
---|
1135 | /* C2ISRããå¼ã³åºãããå ´åã¯,C2ISRã®åºå£å¦ç㧠*/
|
---|
1136 | /* ãã£ã¹ããããè¡ãããï¼ããã§ã¯å®æ½ããªã */
|
---|
1137 | }
|
---|
1138 | else if (p_osapcb != p_runosap) {
|
---|
1139 | /* ä»ã®OSAPãçµäº/åèµ·åããå ´åã¯,ãã£ã¹ããããè¡ã */
|
---|
1140 | dispatch();
|
---|
1141 | }
|
---|
1142 | else {
|
---|
1143 | /* èªOSAPãçµäº/åèµ·åããå ´åã¯,å¼ã³åºãå
|
---|
1144 | ã«æ»ããªã */
|
---|
1145 | exit_and_dispatch_nohook();
|
---|
1146 | }
|
---|
1147 | #else
|
---|
1148 | if (p_osapcb != p_runosap) {
|
---|
1149 | /* ä»ã®OSAPãçµäº/åèµ·åããå ´å */
|
---|
1150 | if ((callevel_stat & TCL_ISR2) != TCL_NULL) {
|
---|
1151 | /* C2ISRããå¼ã³åºãããå ´åã¯,C2ISRã®åºå£å¦ç㧠*/
|
---|
1152 | /* ãã£ã¹ããããè¡ãããï¼ããã§ã¯å®æ½ããªã */
|
---|
1153 | }
|
---|
1154 | else {
|
---|
1155 | /*ã¿ã¹ã¯ããå¼ã³åºãããå ´åã¯ãªã¹ã¿ã¼ãã¿ã¹ã¯ã«ãã£ã¹ããã*/
|
---|
1156 | dispatch();
|
---|
1157 | }
|
---|
1158 | }
|
---|
1159 | else {
|
---|
1160 | /* èªOSAPãçµäº/åèµ·åããå ´åã¯,å¼ã³åºãå
|
---|
1161 | ã«æ»ããªã */
|
---|
1162 | if (p_runisr != NULL) {
|
---|
1163 | if (sus_os_cnt > 0U) {
|
---|
1164 | sus_os_cnt = 0U;
|
---|
1165 | }
|
---|
1166 | exit_and_dispatch_isr();
|
---|
1167 | }
|
---|
1168 | else {
|
---|
1169 | exit_and_dispatch_nohook();
|
---|
1170 | }
|
---|
1171 | }
|
---|
1172 | #endif
|
---|
1173 | }
|
---|
1174 |
|
---|
1175 | #endif /* TOPPERS_force_term_osap */
|
---|