source: ssp_qb_r5f100le_cs/trunk/kernel/sys_manage.c@ 93

Last change on this file since 93 was 93, checked in by nmir-saito, 8 years ago

add Combined package of SSP kernel for QB-R5F100LE-TB(RL78 processor)

File size: 7.7 KB
Line 
1/*
2 * TOPPERS/SSP Kernel
3 * Smallest Set Profile Kernel
4 *
5 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
6 * Toyohashi Univ. of Technology, JAPAN
7 * Copyright (C) 2005-2008 by Embedded and Real-Time Systems Laboratory
8 * Graduate School of Information Science, Nagoya Univ., JAPAN
9 * Copyright (C) 2010 by Meika Sugimoto
10 *
11 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
12 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
13 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
14 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
15 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
16 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
17 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
18 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
19ƒƒ“ƒgi—˜—p
20 * ŽÒƒ}ƒjƒ…
21ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
22 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
23 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
24 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
25 * ‚ƁD
26 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
27ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
28ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
29 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
30 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
31 * •ñ‚·‚邱‚ƁD
32 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
33 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
34 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
35 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
36 * –Ɛӂ·‚邱‚ƁD
37 *
38 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
39 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
40 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
41 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
42 * ‚̐ӔC‚𕉂í‚È‚¢D
43 *
44 */
45
46/*
47 * ƒVƒXƒeƒ€ó‘ÔŠÇ—‹@”\
48 */
49
50#include "kernel_impl.h"
51#include "check.h"
52#include "task.h"
53
54/*
55 * ƒgƒŒ[ƒXƒƒOƒ}ƒNƒ‚̃fƒtƒHƒ‹ƒg’è‹`
56 */
57
58#ifndef LOG_LOC_CPU_ENTER
59#define LOG_LOC_CPU_ENTER()
60#endif /* LOG_LOC_CPU_ENTER */
61
62#ifndef LOG_LOC_CPU_LEAVE
63#define LOG_LOC_CPU_LEAVE(ercd)
64#endif /* LOG_LOC_CPU_LEAVE */
65
66#ifndef LOG_ILOC_CPU_ENTER
67#define LOG_ILOC_CPU_ENTER()
68#endif /* LOG_ILOC_CPU_ENTER */
69
70#ifndef LOG_ILOC_CPU_LEAVE
71#define LOG_ILOC_CPU_LEAVE(ercd)
72#endif /* LOG_ILOC_CPU_LEAVE */
73
74#ifndef LOG_UNL_CPU_ENTER
75#define LOG_UNL_CPU_ENTER()
76#endif /* LOG_UNL_CPU_ENTER */
77
78#ifndef LOG_UNL_CPU_LEAVE
79#define LOG_UNL_CPU_LEAVE(ercd)
80#endif /* LOG_UNL_CPU_LEAVE */
81
82#ifndef LOG_IUNL_CPU_ENTER
83#define LOG_IUNL_CPU_ENTER()
84#endif /* LOG_IUNL_CPU_ENTER */
85
86#ifndef LOG_IUNL_CPU_LEAVE
87#define LOG_IUNL_CPU_LEAVE(ercd)
88#endif /* LOG_IUNL_CPU_LEAVE */
89
90#ifndef LOG_DIS_DSP_ENTER
91#define LOG_DIS_DSP_ENTER()
92#endif /* LOG_DIS_DSP_ENTER */
93
94#ifndef LOG_DIS_DSP_LEAVE
95#define LOG_DIS_DSP_LEAVE(ercd)
96#endif /* LOG_DIS_DSP_LEAVE */
97
98#ifndef LOG_ENA_DSP_ENTER
99#define LOG_ENA_DSP_ENTER()
100#endif /* LOG_ENA_DSP_ENTER */
101
102#ifndef LOG_ENA_DSP_LEAVE
103#define LOG_ENA_DSP_LEAVE(ercd)
104#endif /* LOG_ENA_DSP_LEAVE */
105
106#ifndef LOG_SNS_CTX_ENTER
107#define LOG_SNS_CTX_ENTER()
108#endif /* LOG_SNS_CTX_ENTER */
109
110#ifndef LOG_SNS_CTX_LEAVE
111#define LOG_SNS_CTX_LEAVE(state)
112#endif /* LOG_SNS_CTX_LEAVE */
113
114#ifndef LOG_SNS_LOC_ENTER
115#define LOG_SNS_LOC_ENTER()
116#endif /* LOG_SNS_LOC_ENTER */
117
118#ifndef LOG_SNS_LOC_LEAVE
119#define LOG_SNS_LOC_LEAVE(state)
120#endif /* LOG_SNS_LOC_LEAVE */
121
122#ifndef LOG_SNS_DSP_ENTER
123#define LOG_SNS_DSP_ENTER()
124#endif /* LOG_SNS_DSP_ENTER */
125
126#ifndef LOG_SNS_DSP_LEAVE
127#define LOG_SNS_DSP_LEAVE(state)
128#endif /* LOG_SNS_DSP_LEAVE */
129
130#ifndef LOG_SNS_DPN_ENTER
131#define LOG_SNS_DPN_ENTER()
132#endif /* LOG_SNS_DPN_ENTER */
133
134#ifndef LOG_SNS_DPN_LEAVE
135#define LOG_SNS_DPN_LEAVE(state)
136#endif /* LOG_SNS_DPN_LEAVE */
137
138#ifndef LOG_SNS_KER_ENTER
139#define LOG_SNS_KER_ENTER()
140#endif /* LOG_SNS_KER_ENTER */
141
142#ifndef LOG_SNS_KER_LEAVE
143#define LOG_SNS_KER_LEAVE(state)
144#endif /* LOG_SNS_KER_LEAVE */
145
146/*
147 * CPUƒƒbƒNó‘Ԃւ̈ڍs
148 */
149#ifdef TOPPERS_loc_cpu
150
151ER
152loc_cpu(void)
153{
154 ER ercd;
155
156 LOG_LOC_CPU_ENTER();
157 CHECK_TSKCTX();
158
159 if (!t_sense_lock()) {
160 t_lock_cpu();
161 }
162 ercd = E_OK;
163
164 error_exit:
165 LOG_LOC_CPU_LEAVE(ercd);
166 return(ercd);
167}
168
169#endif /* TOPPERS_loc_cpu */
170
171/*
172 * CPUƒƒbƒNó‘Ԃւ̈ڍsi”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg—pj
173 */
174#ifdef TOPPERS_iloc_cpu
175
176ER
177iloc_cpu(void)
178{
179 ER ercd;
180
181 LOG_ILOC_CPU_ENTER();
182 CHECK_INTCTX();
183
184 if (!i_sense_lock()) {
185 i_lock_cpu();
186 }
187 ercd = E_OK;
188
189 error_exit:
190 LOG_ILOC_CPU_LEAVE(ercd);
191 return(ercd);
192}
193
194#endif /* TOPPERS_iloc_cpu */
195
196/*
197 * CPUƒƒbƒNó‘Ԃ̉ðœ
198 *
199 * CPUƒƒbƒN’†‚́CƒfƒBƒXƒpƒbƒ`‚ª•K—v‚Æ‚È‚éƒT[ƒrƒXƒR[ƒ‹‚ðŒÄ‚яo‚·‚±
200 * ‚Æ‚Í‚Å‚«‚È‚¢‚½‚߁CCPUƒƒbƒNó‘Ô‚Ì‰ðœŽž‚ɃfƒBƒXƒpƒbƒ`ƒƒ‚ð‹N“®‚·‚é
201 * •K—v‚Í‚È‚¢D
202 */
203#ifdef TOPPERS_unl_cpu
204
205ER
206unl_cpu(void)
207{
208 ER ercd;
209
210 LOG_UNL_CPU_ENTER();
211 CHECK_TSKCTX();
212
213 if (t_sense_lock()) {
214 t_unlock_cpu();
215 }
216 ercd = E_OK;
217
218 error_exit:
219 LOG_UNL_CPU_LEAVE(ercd);
220 return(ercd);
221}
222
223#endif /* TOPPERS_unl_cpu */
224
225/*
226 * CPUƒƒbƒNó‘Ô‚Ì‰ðœi”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg—pj
227 *
228 * CPUƒƒbƒN’†‚́CƒfƒBƒXƒpƒbƒ`‚ª•K—v‚Æ‚È‚éƒT[ƒrƒXƒR[ƒ‹‚ðŒÄ‚яo‚·‚±
229 * ‚Æ‚Í‚Å‚«‚È‚¢‚½‚߁CCPUƒƒbƒNó‘Ô‚Ì‰ðœŽž‚ɃfƒBƒXƒpƒbƒ`ƒƒ‚Ì‹N“®‚ð—v
230 * ‹‚·‚é•K—v‚Í‚È‚¢D
231 */
232#ifdef TOPPERS_iunl_cpu
233
234ER
235iunl_cpu(void)
236{
237 ER ercd;
238
239 LOG_IUNL_CPU_ENTER();
240 CHECK_INTCTX();
241
242 if (i_sense_lock()) {
243 i_unlock_cpu();
244 }
245 ercd = E_OK;
246
247 error_exit:
248 LOG_IUNL_CPU_LEAVE(ercd);
249 return(ercd);
250}
251
252#endif /* TOPPERS_iunl_cpu */
253
254/*
255 * ƒfƒBƒXƒpƒbƒ`‚Ì‹ÖŽ~
256 */
257#ifdef TOPPERS_dis_dsp
258
259ER
260dis_dsp(void)
261{
262 ER ercd;
263
264 LOG_DIS_DSP_ENTER();
265 CHECK_TSKCTX_UNL();
266
267 t_lock_cpu();
268 disdsp = true;
269 ercd = E_OK;
270 t_unlock_cpu();
271
272 error_exit:
273 LOG_DIS_DSP_LEAVE(ercd);
274 return(ercd);
275}
276
277#endif /* TOPPERS_dis_dsp */
278
279/*
280 * ƒfƒBƒXƒpƒbƒ`‚Ì‹–‰Â
281 */
282#ifdef TOPPERS_ena_dsp
283
284ER
285ena_dsp(void)
286{
287 ER ercd;
288 uint_t tskipri;
289
290 LOG_ENA_DSP_ENTER();
291 CHECK_TSKCTX_UNL();
292
293 t_lock_cpu();
294 disdsp = false;
295
296 tskipri = search_schedtsk();
297 if (tskipri < runtsk_curpri) {
298 run_task(tskipri);
299 }
300 ercd = E_OK;
301 t_unlock_cpu();
302
303 error_exit:
304 LOG_ENA_DSP_LEAVE(ercd);
305 return(ercd);
306}
307
308#endif /* TOPPERS_ena_dsp */
309
310/*
311 * ƒRƒ“ƒeƒLƒXƒg‚ÌŽQÆ
312 */
313#ifdef TOPPERS_sns_ctx
314
315bool_t
316sns_ctx(void)
317{
318 bool_t state;
319
320 LOG_SNS_CTX_ENTER();
321 state = sense_context() ? true : false;
322 LOG_SNS_CTX_LEAVE(state);
323
324 return(state);
325}
326
327#endif /* TOPPERS_sns_ctx */
328
329/*
330 * CPUƒƒbƒNó‘Ô‚ÌŽQÆ
331 */
332#ifdef TOPPERS_sns_loc
333
334bool_t
335sns_loc(void)
336{
337 bool_t state;
338
339 LOG_SNS_LOC_ENTER();
340 state = x_sense_lock() ? true : false;
341 LOG_SNS_LOC_LEAVE(state);
342
343 return(state);
344}
345
346#endif /* TOPPERS_sns_loc */
347
348/*
349 * ƒfƒBƒXƒpƒbƒ`‹ÖŽ~ó‘Ô‚ÌŽQÆ
350 */
351#ifdef TOPPERS_sns_dsp
352
353bool_t
354sns_dsp(void)
355{
356 bool_t state;
357
358 LOG_SNS_DSP_ENTER();
359 state = disdsp;
360 LOG_SNS_DSP_LEAVE(state);
361
362 return(state);
363}
364
365#endif /* TOPPERS_sns_dsp */
366
367/*
368 * ƒfƒBƒXƒpƒbƒ`•Û—¯ó‘Ô‚ÌŽQÆ
369 */
370#ifdef TOPPERS_sns_dpn
371
372bool_t
373sns_dpn(void)
374{
375 bool_t state;
376
377 LOG_SNS_DPN_ENTER();
378 state = ((sense_context()) || (t_sense_lock()) || disdsp) ?
379 true : false;
380 LOG_SNS_DPN_LEAVE(state);
381
382 return(state);
383}
384
385#endif /* TOPPERS_sns_dpn */
386
387/*
388 * ƒJ[ƒlƒ‹”ñ“®ìó‘Ô‚ÌŽQÆ
389 */
390#ifdef TOPPERS_sns_ker
391
392bool_t
393sns_ker(void)
394{
395 bool_t state;
396
397 LOG_SNS_KER_ENTER();
398 state = kerflg ? false : true;
399 LOG_SNS_KER_LEAVE(state);
400
401 return(state);
402}
403
404#endif /* TOPPERS_sns_ker */
Note: See TracBrowser for help on using the repository browser.