source: UsbWattMeter/trunk/asp_dcre/kernel/check.h@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 6 years ago

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr
File size: 12.2 KB
RevLine 
[164]1/*
2 * TOPPERS/ASP Kernel
3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Advanced Standard Profile Kernel
5 *
6 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
7 * Toyohashi Univ. of Technology, JAPAN
8 * Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
9 * Graduate School of Information Science, Nagoya Univ., JAPAN
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 * @(#) $Id: check.h 164 2016-03-07 11:33:50Z coas-nagasima $
45 */
46
47/*
48 * ƒGƒ‰[ƒ`ƒFƒbƒN—pƒ}ƒNƒ
49 */
50
51#ifndef TOPPERS_CHECK_H
52#define TOPPERS_CHECK_H
53
54/*
55 * —\–ñ‘®«ƒGƒ‰[‚̃`ƒFƒbƒNiE_PARj
56 */
57#define CHECK_RSATR(atr, valid_atr) do { \
58 if (((atr) & ~(valid_atr)) != 0U) { \
59 ercd = E_RSATR; \
60 goto error_exit; \
61 } \
62} while (false)
63
64/*
65 * —Dæ“x‚͈̔͂̔»’è
66 */
67#define VALID_TPRI(tpri) (TMIN_TPRI <= (tpri) && (tpri) <= TMAX_TPRI)
68
69#define VALID_DPRI(dpri) (TMIN_DPRI <= (dpri) && (dpri) <= TMAX_DPRI)
70
71#define VALID_MPRI(mpri) (TMIN_MPRI <= (mpri) && (mpri) <= TMAX_MPRI)
72
73#define VALID_ISRPRI(isrpri) \
74 (TMIN_ISRPRI <= (isrpri) && (isrpri) <= TMAX_ISRPRI)
75
76#ifndef VALID_INTPRI_CHGIPM
77#define VALID_INTPRI_CHGIPM(intpri) \
78 (TMIN_INTPRI <= (intpri) && (intpri) <= TIPM_ENAALL)
79#endif /* VALID_INTPRI_CHGIPM */
80
81/*
82 * ƒ^ƒXƒN—Dæ“x‚̃`ƒFƒbƒNiE_PARj
83 */
84#define CHECK_TPRI(tpri) do { \
85 if (!VALID_TPRI(tpri)) { \
86 ercd = E_PAR; \
87 goto error_exit; \
88 } \
89} while (false)
90
91#define CHECK_TPRI_INI(tpri) do { \
92 if (!(VALID_TPRI(tpri) || (tpri) == TPRI_INI)) { \
93 ercd = E_PAR; \
94 goto error_exit; \
95 } \
96} while (false)
97
98#define CHECK_TPRI_SELF(tpri) do { \
99 if (!(VALID_TPRI(tpri) || (tpri) == TPRI_SELF)) { \
100 ercd = E_PAR; \
101 goto error_exit; \
102 } \
103} while (false)
104
105/*
106 * ƒf[ƒ^—Dæ“x‚̃`ƒFƒbƒNiE_PARj
107 */
108#define CHECK_DPRI(dpri) do { \
109 if (!VALID_DPRI(dpri)) { \
110 ercd = E_PAR; \
111 goto error_exit; \
112 } \
113} while (false)
114
115/*
116 * ƒƒbƒZ[ƒW—Dæ“x‚̃`ƒFƒbƒNiE_PARj
117 */
118#define CHECK_MPRI(mpri) do { \
119 if (!VALID_MPRI(mpri)) { \
120 ercd = E_PAR; \
121 goto error_exit; \
122 } \
123} while (false)
124
125/*
126 * Š„ž‚݃T[ƒrƒXƒ‹[ƒ`ƒ“—Dæ“x‚̃`ƒFƒbƒNiE_PARj
127 */
128#define CHECK_ISRPRI(isrpri) do { \
129 if (!VALID_ISRPRI(isrpri)) { \
130 ercd = E_PAR; \
131 goto error_exit; \
132 } \
133} while (false)
134
135/*
136 * ƒ^ƒCƒ€ƒAƒEƒgŽw’è’l‚̃`ƒFƒbƒNiE_PARj
137 */
138#define CHECK_TMOUT(tmout) do { \
139 if (!(TMO_FEVR <= (tmout))) { \
140 ercd = E_PAR; \
141 goto error_exit; \
142 } \
143} while (false)
144
145/*
146 * Š„ž‚Ý—Dæ“x‚̃`ƒFƒbƒNiE_PARj
147 */
148#define CHECK_INTPRI_CHGIPM(intpri) do { \
149 if (!VALID_INTPRI_CHGIPM(intpri)) { \
150 ercd = E_PAR; \
151 goto error_exit; \
152 } \
153} while (false)
154
155/*
156 * Š„ž‚ݔԍ†‚̃`ƒFƒbƒNiE_PARj
157 */
158#define CHECK_INTNO_CREISR(intno) do { \
159 if (!VALID_INTNO_CREISR(intno)) { \
160 ercd = E_PAR; \
161 goto error_exit; \
162 } \
163} while (false)
164
165#define CHECK_INTNO_DISINT(intno) do { \
166 if (!VALID_INTNO_DISINT(intno)) { \
167 ercd = E_PAR; \
168 goto error_exit; \
169 } \
170} while (false)
171
172/*
173 * ƒAƒ‰ƒCƒ“‚µ‚Ä‚¢‚é‚©‚Ì”»’è
174 */
175#define ALIGNED(val, align) ((((uintptr_t)(val)) & ((align) - 1U)) == 0U)
176
177#ifdef CHECK_FUNC_ALIGN
178#define FUNC_ALIGNED(func) ALIGNED(func, CHECK_FUNC_ALIGN)
179#else /* CHECK_FUNC_ALIGN */
180#define FUNC_ALIGNED(func) true
181#endif /* CHECK_FUNC_ALIGN */
182
183#ifdef CHECK_STKSZ_ALIGN
184#define STKSZ_ALIGNED(stksz) ALIGNED(stksz, CHECK_STKSZ_ALIGN)
185#else /* CHECK_STKSZ_ALIGN */
186#define STKSZ_ALIGNED(stksz) true
187#endif /* CHECK_STKSZ_ALIGN */
188
189#ifdef CHECK_STACK_ALIGN
190#define STACK_ALIGNED(stack) ALIGNED(stack, CHECK_STACK_ALIGN)
191#else /* CHECK_STACK_ALIGN */
192#define STACK_ALIGNED(stack) true
193#endif /* CHECK_STACK_ALIGN */
194
195#ifdef CHECK_MPF_ALIGN
196#define MPF_ALIGNED(mpf) ALIGNED(mpf, CHECK_MPF_ALIGN)
197#else /* CHECK_MPF_ALIGN */
198#define MPF_ALIGNED(mpf) true
199#endif /* CHECK_MPF_ALIGN */
200
201#ifdef CHECK_MB_ALIGN
202#define MB_ALIGNED(mb) ALIGNED(mb, CHECK_MB_ALIGN)
203#else /* CHECK_MB_ALIGN */
204#define MB_ALIGNED(mb) true
205#endif /* CHECK_MB_ALIGN */
206
207/*
208 * NULL‚Å‚È‚¢‚±‚Ƃ̃`ƒFƒbƒN
209 */
210#ifdef CHECK_FUNC_NONNULL
211#define FUNC_NONNULL(func) ((func) != NULL)
212#else /* CHECK_FUNC_NONNULL */
213#define FUNC_NONNULL(func) true
214#endif /* CHECK_FUNC_NONNULL */
215
216/*
217 * ŠÖ”‚̐擪”Ô’n‚̃`ƒFƒbƒNiE_PARj
218 */
219#define CHECK_ALIGN_FUNC(func) do { \
220 if (!FUNC_ALIGNED(func)) { \
221 ercd = E_PAR; \
222 goto error_exit; \
223 } \
224} while (false)
225
226#define CHECK_NONNULL_FUNC(func) do { \
227 if (!FUNC_NONNULL(func)) { \
228 ercd = E_PAR; \
229 goto error_exit; \
230 } \
231} while (false)
232
233/*
234 * ƒXƒ^ƒbƒNƒTƒCƒY‚̃`ƒFƒbƒNiE_PARj
235 */
236#define CHECK_ALIGN_STKSZ(stksz) do { \
237 if (!STKSZ_ALIGNED(stksz)) { \
238 ercd = E_PAR; \
239 goto error_exit; \
240 } \
241} while (false)
242
243/*
244 * ƒXƒ^ƒbƒN‚̐擪”Ô’n‚̃`ƒFƒbƒNiE_PARj
245 */
246#define CHECK_ALIGN_STACK(stack) do { \
247 if (!STACK_ALIGNED(stack)) { \
248 ercd = E_PAR; \
249 goto error_exit; \
250 } \
251} while (false)
252
253/*
254 * ŒÅ’è’·ƒƒ‚ƒŠƒv[ƒ‹—̈æ‚̐擪”Ô’n‚̃`ƒFƒbƒNiE_PARj
255 */
256#define CHECK_ALIGN_MPF(mpf) do { \
257 if (!MPF_ALIGNED(mpf)) { \
258 ercd = E_PAR; \
259 goto error_exit; \
260 } \
261} while (false)
262
263/*
264 * ŠÇ——̈æ‚̐擪”Ô’n‚̃`ƒFƒbƒNiE_PARj
265 */
266#define CHECK_ALIGN_MB(mb) do { \
267 if (!MB_ALIGNED(mb)) { \
268 ercd = E_PAR; \
269 goto error_exit; \
270 } \
271} while (false)
272
273/*
274 * ‚»‚Ì‘¼‚̃pƒ‰ƒ[ƒ^ƒGƒ‰[‚̃`ƒFƒbƒNiE_PARj
275 */
276#define CHECK_PAR(exp) do { \
277 if (!(exp)) { \
278 ercd = E_PAR; \
279 goto error_exit; \
280 } \
281} while (false)
282
283/*
284 * ƒIƒuƒWƒFƒNƒgID‚͈̔͂̔»’è
285 */
286#define VALID_TSKID(tskid) (TMIN_TSKID <= (tskid) && (tskid) <= tmax_tskid)
287#define VALID_SEMID(semid) (TMIN_SEMID <= (semid) && (semid) <= tmax_semid)
288#define VALID_FLGID(flgid) (TMIN_FLGID <= (flgid) && (flgid) <= tmax_flgid)
289#define VALID_DTQID(dtqid) (TMIN_DTQID <= (dtqid) && (dtqid) <= tmax_dtqid)
290#define VALID_PDQID(pdqid) (TMIN_PDQID <= (pdqid) && (pdqid) <= tmax_pdqid)
291#define VALID_MBXID(mbxid) (TMIN_MBXID <= (mbxid) && (mbxid) <= tmax_mbxid)
292#define VALID_MPFID(mpfid) (TMIN_MPFID <= (mpfid) && (mpfid) <= tmax_mpfid)
293#define VALID_CYCID(cycid) (TMIN_CYCID <= (cycid) && (cycid) <= tmax_cycid)
294#define VALID_ALMID(almid) (TMIN_ALMID <= (almid) && (almid) <= tmax_almid)
295#define VALID_ISRID(isrid) (TMIN_ISRID <= (isrid) && (isrid) <= tmax_isrid)
296
297/*
298 * ƒIƒuƒWƒFƒNƒgID‚̃`ƒFƒbƒNiE_IDj
299 */
300#define CHECK_TSKID(tskid) do { \
301 if (!VALID_TSKID(tskid)) { \
302 ercd = E_ID; \
303 goto error_exit; \
304 } \
305} while (false)
306
307#define CHECK_TSKID_SELF(tskid) do { \
308 if (!(VALID_TSKID(tskid) || (tskid) == TSK_SELF)) { \
309 ercd = E_ID; \
310 goto error_exit; \
311 } \
312} while (false)
313
314#define CHECK_SEMID(semid) do { \
315 if (!VALID_SEMID(semid)) { \
316 ercd = E_ID; \
317 goto error_exit; \
318 } \
319} while (false)
320
321#define CHECK_FLGID(flgid) do { \
322 if (!VALID_FLGID(flgid)) { \
323 ercd = E_ID; \
324 goto error_exit; \
325 } \
326} while (false)
327
328#define CHECK_DTQID(dtqid) do { \
329 if (!VALID_DTQID(dtqid)) { \
330 ercd = E_ID; \
331 goto error_exit; \
332 } \
333} while (false)
334
335#define CHECK_PDQID(pdqid) do { \
336 if (!VALID_PDQID(pdqid)) { \
337 ercd = E_ID; \
338 goto error_exit; \
339 } \
340} while (false)
341
342#define CHECK_MBXID(mbxid) do { \
343 if (!VALID_MBXID(mbxid)) { \
344 ercd = E_ID; \
345 goto error_exit; \
346 } \
347} while (false)
348
349#define CHECK_MPFID(mpfid) do { \
350 if (!VALID_MPFID(mpfid)) { \
351 ercd = E_ID; \
352 goto error_exit; \
353 } \
354} while (false)
355
356#define CHECK_CYCID(cycid) do { \
357 if (!VALID_CYCID(cycid)) { \
358 ercd = E_ID; \
359 goto error_exit; \
360 } \
361} while (false)
362
363#define CHECK_ALMID(almid) do { \
364 if (!VALID_ALMID(almid)) { \
365 ercd = E_ID; \
366 goto error_exit; \
367 } \
368} while (false)
369
370#define CHECK_ISRID(isrid) do { \
371 if (!VALID_ISRID(isrid)) { \
372 ercd = E_ID; \
373 goto error_exit; \
374 } \
375} while (false)
376
377/*
378 * ŒÄo‚µƒRƒ“ƒeƒLƒXƒg‚̃`ƒFƒbƒNiE_CTXj
379 */
380#define CHECK_TSKCTX() do { \
381 if (sense_context()) { \
382 ercd = E_CTX; \
383 goto error_exit; \
384 } \
385} while (false)
386
387#define CHECK_INTCTX() do { \
388 if (!sense_context()) { \
389 ercd = E_CTX; \
390 goto error_exit; \
391 } \
392} while (false)
393
394/*
395 * ŒÄo‚µƒRƒ“ƒeƒLƒXƒg‚ÆCPUƒƒbƒNó‘Ԃ̃`ƒFƒbƒNiE_CTXj
396 */
397#define CHECK_TSKCTX_UNL() do { \
398 if (sense_context() || t_sense_lock()) { \
399 ercd = E_CTX; \
400 goto error_exit; \
401 } \
402} while (false)
403
404#define CHECK_INTCTX_UNL() do { \
405 if (!sense_context() || i_sense_lock()) { \
406 ercd = E_CTX; \
407 goto error_exit; \
408 } \
409} while (false)
410
411/*
412 * ƒfƒBƒXƒpƒbƒ`•Û—¯ó‘Ô‚Å‚È‚¢‚©‚̃`ƒFƒbƒNiE_CTXj
413 */
414#define CHECK_DISPATCH() do { \
415 if (sense_context() || t_sense_lock() || !dspflg) { \
416 ercd = E_CTX; \
417 goto error_exit; \
418 } \
419} while (false)
420
421/*
422 * ‚»‚Ì‘¼‚̃Rƒ“ƒeƒLƒXƒgƒGƒ‰[‚̃`ƒFƒbƒNiE_CTXj
423 */
424#define CHECK_CTX(exp) do { \
425 if (!(exp)) { \
426 ercd = E_CTX; \
427 goto error_exit; \
428 } \
429} while (false)
430
431/*
432 * Ž©ƒ^ƒXƒN‚ðŽw’肵‚Ä‚¢‚È‚¢‚©‚̃`ƒFƒbƒNiE_ILUSEj
433 */
434#define CHECK_NONSELF(p_tcb) do { \
435 if ((p_tcb) == p_runtsk) { \
436 ercd = E_ILUSE; \
437 goto error_exit; \
438 } \
439} while (false)
440
441/*
442 * ‚»‚Ì‘¼‚Ì•s³Žg—pƒGƒ‰[‚̃`ƒFƒbƒNiE_ILUSEj
443 */
444#define CHECK_ILUSE(exp) do { \
445 if (!(exp)) { \
446 ercd = E_ILUSE; \
447 goto error_exit; \
448 } \
449} while (false)
450
451/*
452 * –¢ƒTƒ|[ƒg‹@”\ƒGƒ‰[‚̃`ƒFƒbƒNiE_NOSPTj
453 */
454#define CHECK_NOSPT(exp) do { \
455 if (!(exp)) { \
456 ercd = E_NOSPT; \
457 goto error_exit; \
458 } \
459} while (false)
460
461/*
462 * Ã“I‚ȃIƒuƒWƒFƒNƒgó‘ÔƒGƒ‰[‚̃`ƒFƒbƒNiE_OBJj
463 */
464#define CHECK_OBJ(exp) do { \
465 if (!(exp)) { \
466 ercd = E_OBJ; \
467 goto error_exit; \
468 } \
469} while (false)
470
471#endif /* TOPPERS_CHECK_H */
Note: See TracBrowser for help on using the repository browser.