source: ssp_qb_r5f100le_cs/trunk/extension/eventflag.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: 5.8 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-2010 by Embedded and Real-Time Systems Laboratory
8 * Graduate School of Information Science, Nagoya Univ., JAPAN
9 * Copyright (C) 2011 by Meika Sugimoto
10 * Copyright (C) 2015 by Naoki Saito
11 * Nagoya Municipal Industrial Research Institute, JAPAN
12 *
13 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì (1)`(4) ‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
14 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü•ÏE
15 * Ä”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
16 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ìŒ 
17 * •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[ƒX
18 * ƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
19 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg—p
20 * ‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
21ƒƒ“ƒgi—˜—pŽÒƒ}
22 * ƒjƒ…
23ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•Û
24 * Ø‹K’è‚ðŒfÚ‚·‚邱‚ƁD
25 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg—p
26 * ‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±‚ƁD
27 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
28ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
29ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ì
30 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
31 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É•ñ
32 * ‚·‚邱‚ƁD
33 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹ŠQ
34 * ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD‚Ü‚½C
35 * –{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝—R‚ÉŠî‚Ã
36 * ‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚Ɓ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ƒA‚Ì—˜—p
41 * ‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»‚̐ӔC‚ð•‰
42 * ‚í‚È‚¢D
43 *
44 */
45/*
46 * ƒCƒxƒ“ƒgƒtƒ‰ƒO‹@”\
47 */
48
49
50#include "kernel_impl.h"
51#include "check.h"
52#include "eventflag.h"
53
54/*
55 * ƒgƒŒ[ƒXƒƒOƒ}ƒNƒ‚̃fƒtƒHƒ‹ƒg’è‹`
56 */
57#ifndef LOG_SET_FLG_ENTER
58#define LOG_SET_FLG_ENTER(flgid, setptn)
59#endif /* LOG_SET_FLG_ENTER */
60
61#ifndef LOG_SET_FLG_LEAVE
62#define LOG_SET_FLG_LEAVE(ercd)
63#endif /* LOG_SET_FLG_LEAVE */
64
65#ifndef LOG_ISET_FLG_ENTER
66#define LOG_ISET_FLG_ENTER(flgid, setptn)
67#endif /* LOG_ISET_FLG_ENTER */
68
69#ifndef LOG_ISET_FLG_LEAVE
70#define LOG_ISET_FLG_LEAVE(ercd)
71#endif /* LOG_ISET_FLG_LEAVE */
72
73#ifndef LOG_CLR_FLG_ENTER
74#define LOG_CLR_FLG_ENTER(flgid, clrptn)
75#endif /* LOG_CLR_FLG_ENTER */
76
77#ifndef LOG_CLR_FLG_LEAVE
78#define LOG_CLR_FLG_LEAVE(ercd)
79#endif /* LOG_CLR_FLG_LEAVE */
80
81#ifndef LOG_POL_FLG_ENTER
82#define LOG_POL_FLG_ENTER(flgid, waiptn, wfmode, p_flgptn)
83#endif /* LOG_POL_FLG_ENTER */
84
85#ifndef LOG_POL_FLG_LEAVE
86#define LOG_POL_FLG_LEAVE(ercd, flgptn)
87#endif /* LOG_POL_FLG_LEAVE */
88
89
90
91/* ƒCƒxƒ“ƒgƒtƒ‰ƒOIDID‚©‚ç‚Ì”z—ñƒIƒtƒZƒbƒg‚Ö‚Ì•ÏŠ·ƒ}ƒNƒ */
92#define INDEX_FLG(flgid) ((uint_t)((flgid) - TMIN_FLGID))
93
94#ifdef TOPPERS_iniflg
95
96void initialize_eventflag(void)
97{
98 int_t i;
99
100 for(i = 0 ; i < tmax_flgid ; i++)
101 {
102 /* ƒrƒbƒgƒpƒ^[ƒ“‚̏‰Šú‰» */
103 flgcb_flgptn[i] = flginib_iflgptn[i];
104 }
105}
106
107#endif /* TOPPERS_iniflg */
108
109/*
110 * ƒCƒxƒ“ƒgƒtƒ‰ƒOðŒ‚ª¬—§‚µ‚Ä‚¢‚é‚©‚̃`ƒFƒbƒN
111 */
112Inline bool_t
113check_flg_cond(FLGPTN curptn , FLGPTN waiptn, MODE wfmode)
114{
115 bool_t flgset = false;
116
117 if ((wfmode & TWF_ORW) != 0U)
118 {
119 if((curptn & waiptn) != 0U)
120 {
121 flgset = true;
122 }
123 }
124 else /* (wfmode & TWF_ANDW) != 0U */
125 {
126 if((curptn & waiptn) == waiptn)
127 {
128 flgset = true;
129 }
130 }
131
132 return (flgset);
133}
134
135/*
136 * ƒCƒxƒ“ƒgƒtƒ‰ƒO‚̃Zƒbƒg
137 */
138#ifdef TOPPERS_set_flg
139
140ER
141set_flg(ID flgid, FLGPTN setptn)
142{
143 ER ercd;
144
145 LOG_SET_FLG_ENTER(flgid, setptn);
146 CHECK_TSKCTX_UNL();
147 CHECK_FLGID(flgid);
148
149 t_lock_cpu();
150 flgcb_flgptn[INDEX_FLG(flgid)] |= setptn;
151 ercd = E_OK;
152 t_unlock_cpu();
153
154 error_exit:
155 LOG_SET_FLG_LEAVE(ercd);
156 return(ercd);
157}
158
159
160#endif /* TOPPERS_set_flg */
161
162/*
163 * ƒCƒxƒ“ƒgƒtƒ‰ƒO‚̃Zƒbƒgi”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg—pj
164 */
165#ifdef TOPPERS_iset_flg
166
167ER
168iset_flg(ID flgid, FLGPTN setptn)
169{
170 ER ercd;
171
172 LOG_ISET_FLG_ENTER(flgid, setptn);
173 CHECK_INTCTX_UNL();
174 CHECK_FLGID(flgid);
175
176 i_lock_cpu();
177 flgcb_flgptn[INDEX_FLG(flgid)] |= setptn;
178 ercd = E_OK;
179 i_unlock_cpu();
180
181 error_exit:
182 LOG_ISET_FLG_LEAVE(ercd);
183 return(ercd);
184}
185
186#endif /* TOPPERS_iset_flg */
187
188/*
189 * ƒCƒxƒ“ƒgƒtƒ‰ƒO‚̃NƒŠƒA
190 */
191#ifdef TOPPERS_clr_flg
192
193ER
194clr_flg(ID flgid, FLGPTN clrptn)
195{
196 ER ercd;
197
198 LOG_CLR_FLG_ENTER(flgid, clrptn);
199 CHECK_TSKCTX_UNL();
200 CHECK_FLGID(flgid);
201
202 t_lock_cpu();
203 flgcb_flgptn[INDEX_FLG(flgid)] &= clrptn;
204 ercd = E_OK;
205 t_unlock_cpu();
206
207 error_exit:
208 LOG_CLR_FLG_LEAVE(ercd);
209 return(ercd);
210}
211
212#endif /* TOPPERS_clr_flg */
213
214
215/*
216 * ƒCƒxƒ“ƒgƒtƒ‰ƒO‘Ò‚¿iƒ|[ƒŠƒ“ƒOj
217 */
218#ifdef TOPPERS_pol_flg
219
220ER
221pol_flg(ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn)
222{
223 ER ercd;
224 int_t index;
225
226 LOG_POL_FLG_ENTER(flgid, waiptn, wfmode, p_flgptn);
227 CHECK_TSKCTX_UNL();
228 CHECK_FLGID(flgid);
229 CHECK_PAR(waiptn != 0U);
230 CHECK_PAR(wfmode == TWF_ORW || wfmode == TWF_ANDW);
231
232 t_lock_cpu();
233
234 index = INDEX_FLG(flgid);
235
236 if (check_flg_cond(flgcb_flgptn[index], waiptn, wfmode)) {
237 ercd = E_OK;
238 *p_flgptn = flgcb_flgptn[index];
239
240 if((flginib_atr[index] & TA_CLR) != 0U)
241 {
242 flgcb_flgptn[index] = 0U;
243 }
244 }
245 else {
246 ercd = E_TMOUT;
247 }
248 t_unlock_cpu();
249
250 error_exit:
251 LOG_POL_FLG_LEAVE(ercd, *p_flgptn);
252 return(ercd);
253}
254
255#endif /* TOPPERS_pol_flg */
256
257
Note: See TracBrowser for help on using the repository browser.