source: UsbWattMeter/trunk/asp_dcre/kernel/mailbox.c@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 7 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-csrc
File size: 11.3 KB
Line 
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: mailbox.c 164 2016-03-07 11:33:50Z coas-nagasima $
45 */
46
47/*
48 * ƒ[ƒ‹ƒ{ƒbƒNƒX‹@”\
49 */
50
51#include "kernel_impl.h"
52#include "check.h"
53#include "task.h"
54#include "wait.h"
55#include "mailbox.h"
56
57/*
58 * ƒgƒŒ[ƒXƒƒOƒ}ƒNƒ‚̃fƒtƒHƒ‹ƒg’è‹`
59 */
60#ifndef LOG_ACRE_MBX_ENTER
61#define LOG_ACRE_MBX_ENTER(pk_cmbx)
62#endif /* LOG_ACRE_MBX_ENTER */
63
64#ifndef LOG_ACRE_MBX_LEAVE
65#define LOG_ACRE_MBX_LEAVE(ercd)
66#endif /* LOG_ACRE_MBX_LEAVE */
67
68#ifndef LOG_DEL_MBX_ENTER
69#define LOG_DEL_MBX_ENTER(mbxid)
70#endif /* LOG_DEL_MBX_ENTER */
71
72#ifndef LOG_DEL_MBX_LEAVE
73#define LOG_DEL_MBX_LEAVE(ercd)
74#endif /* LOG_DEL_MBX_LEAVE */
75
76#ifndef LOG_SND_MBX_ENTER
77#define LOG_SND_MBX_ENTER(mbxid, pk_msg)
78#endif /* LOG_SND_MBX_ENTER */
79
80#ifndef LOG_SND_MBX_LEAVE
81#define LOG_SND_MBX_LEAVE(ercd)
82#endif /* LOG_SND_MBX_LEAVE */
83
84#ifndef LOG_RCV_MBX_ENTER
85#define LOG_RCV_MBX_ENTER(mbxid, ppk_msg)
86#endif /* LOG_RCV_MBX_ENTER */
87
88#ifndef LOG_RCV_MBX_LEAVE
89#define LOG_RCV_MBX_LEAVE(ercd, pk_msg)
90#endif /* LOG_RCV_MBX_LEAVE */
91
92#ifndef LOG_PRCV_MBX_ENTER
93#define LOG_PRCV_MBX_ENTER(mbxid, ppk_msg)
94#endif /* LOG_PRCV_MBX_ENTER */
95
96#ifndef LOG_PRCV_MBX_LEAVE
97#define LOG_PRCV_MBX_LEAVE(ercd, pk_msg)
98#endif /* LOG_PRCV_MBX_LEAVE */
99
100#ifndef LOG_TRCV_MBX_ENTER
101#define LOG_TRCV_MBX_ENTER(mbxid, ppk_msg, tmout)
102#endif /* LOG_TRCV_MBX_ENTER */
103
104#ifndef LOG_TRCV_MBX_LEAVE
105#define LOG_TRCV_MBX_LEAVE(ercd, pk_msg)
106#endif /* LOG_TRCV_MBX_LEAVE */
107
108#ifndef LOG_INI_MBX_ENTER
109#define LOG_INI_MBX_ENTER(mbxid)
110#endif /* LOG_INI_MBX_ENTER */
111
112#ifndef LOG_INI_MBX_LEAVE
113#define LOG_INI_MBX_LEAVE(ercd)
114#endif /* LOG_INI_MBX_LEAVE */
115
116#ifndef LOG_REF_MBX_ENTER
117#define LOG_REF_MBX_ENTER(mbxid, pk_rmbx)
118#endif /* LOG_REF_MBX_ENTER */
119
120#ifndef LOG_REF_MBX_LEAVE
121#define LOG_REF_MBX_LEAVE(ercd, pk_rmbx)
122#endif /* LOG_REF_MBX_LEAVE */
123
124/*
125 * ƒ[ƒ‹ƒ{ƒbƒNƒX‚̐”
126 */
127#define tnum_mbx ((uint_t)(tmax_mbxid - TMIN_MBXID + 1))
128#define tnum_smbx ((uint_t)(tmax_smbxid - TMIN_MBXID + 1))
129
130/*
131 * ƒ[ƒ‹ƒ{ƒbƒNƒXID‚©‚烁[ƒ‹ƒ{ƒbƒNƒXŠÇ—ƒuƒƒbƒN‚ðŽæ‚èo‚·‚½‚߂̃}ƒNƒ
132 */
133#define INDEX_MBX(mbxid) ((uint_t)((mbxid) - TMIN_MBXID))
134#define get_mbxcb(mbxid) (&(mbxcb_table[INDEX_MBX(mbxid)]))
135
136#ifdef TOPPERS_mbxini
137
138/*
139 * Žg—p‚µ‚Ä‚¢‚È‚¢ƒ[ƒ‹ƒ{ƒbƒNƒXŠÇ—ƒuƒƒbƒN‚̃ŠƒXƒg
140 */
141QUEUE free_mbxcb;
142
143/*
144 * ƒ[ƒ‹ƒ{ƒbƒNƒX‹@”\‚̏‰Šú‰»
145 */
146void
147initialize_mailbox(void)
148{
149 uint_t i, j;
150 MBXCB *p_mbxcb;
151 MBXINIB *p_mbxinib;
152
153 for (i = 0; i < tnum_smbx; i++) {
154 p_mbxcb = &(mbxcb_table[i]);
155 queue_initialize(&(p_mbxcb->wait_queue));
156 p_mbxcb->p_mbxinib = &(mbxinib_table[i]);
157 p_mbxcb->pk_head = NULL;
158 }
159 queue_initialize(&free_mbxcb);
160 for (j = 0; i < tnum_mbx; i++, j++) {
161 p_mbxcb = &(mbxcb_table[i]);
162 p_mbxinib = &(ambxinib_table[j]);
163 p_mbxinib->mbxatr = TA_NOEXS;
164 p_mbxcb->p_mbxinib = ((const MBXINIB *) p_mbxinib);
165 queue_insert_prev(&free_mbxcb, &(p_mbxcb->wait_queue));
166 }
167}
168
169#endif /* TOPPERS_mbxini */
170
171/*
172 * ƒƒbƒZ[ƒW—Dæ“x‚ÌŽæo‚µ
173 */
174#define MSGPRI(pk_msg) (((T_MSG_PRI *)(pk_msg))->msgpri)
175
176/*
177 * —Dæ“x‡ƒƒbƒZ[ƒWƒLƒ…
178[‚Ö‚Ì‘}“ü
179 */
180Inline void
181enqueue_msg_pri(T_MSG **ppk_prevmsg_next, T_MSG *pk_msg)
182{
183 T_MSG *pk_nextmsg;
184
185 while ((pk_nextmsg = *ppk_prevmsg_next) != NULL) {
186 if (MSGPRI(pk_nextmsg) > MSGPRI(pk_msg)) {
187 break;
188 }
189 ppk_prevmsg_next = &(pk_nextmsg->pk_next);
190 }
191 pk_msg->pk_next = pk_nextmsg;
192 *ppk_prevmsg_next = pk_msg;
193}
194
195/*
196 * ƒ[ƒ‹ƒ{ƒbƒNƒX‚̐¶¬
197 */
198#ifdef TOPPERS_acre_mbx
199
200ER_UINT
201acre_mbx(const T_CMBX *pk_cmbx)
202{
203 MBXCB *p_mbxcb;
204 MBXINIB *p_mbxinib;
205 ER ercd;
206
207 LOG_ACRE_MBX_ENTER(pk_cmbx);
208 CHECK_TSKCTX_UNL();
209 CHECK_RSATR(pk_cmbx->mbxatr, TA_TPRI|TA_MPRI);
210 CHECK_MPRI(pk_cmbx->maxmpri);
211 CHECK_NOSPT(pk_cmbx->mprihd == NULL);
212
213 t_lock_cpu();
214 if (tnum_mbx == 0 || queue_empty(&free_mbxcb)) {
215 ercd = E_NOID;
216 }
217 else {
218 p_mbxcb = ((MBXCB *) queue_delete_next(&free_mbxcb));
219 p_mbxinib = (MBXINIB *)(p_mbxcb->p_mbxinib);
220 p_mbxinib->mbxatr = pk_cmbx->mbxatr;
221 p_mbxinib->maxmpri = pk_cmbx->maxmpri;
222
223 queue_initialize(&(p_mbxcb->wait_queue));
224 p_mbxcb->pk_head = NULL;
225 ercd = MBXID(p_mbxcb);
226 }
227 t_unlock_cpu();
228
229 error_exit:
230 LOG_ACRE_MBX_LEAVE(ercd);
231 return(ercd);
232}
233
234#endif /* TOPPERS_acre_mbx */
235
236/*
237 * ƒ[ƒ‹ƒ{ƒbƒNƒX‚̍폜
238 */
239#ifdef TOPPERS_del_mbx
240
241ER
242del_mbx(ID mbxid)
243{
244 MBXCB *p_mbxcb;
245 MBXINIB *p_mbxinib;
246 bool_t dspreq;
247 ER ercd;
248
249 LOG_DEL_MBX_ENTER(mbxid);
250 CHECK_TSKCTX_UNL();
251 CHECK_MBXID(mbxid);
252 p_mbxcb = get_mbxcb(mbxid);
253
254 t_lock_cpu();
255 if (p_mbxcb->p_mbxinib->mbxatr == TA_NOEXS) {
256 ercd = E_NOEXS;
257 }
258 else if (MBXID(p_mbxcb) > tmax_smbxid) {
259 dspreq = init_wait_queue(&(p_mbxcb->wait_queue));
260 p_mbxinib = (MBXINIB *)(p_mbxcb->p_mbxinib);
261 p_mbxinib->mbxatr = TA_NOEXS;
262 queue_insert_prev(&free_mbxcb, &(p_mbxcb->wait_queue));
263 if (dspreq) {
264 dispatch();
265 }
266 ercd = E_OK;
267 }
268 else {
269 ercd = E_OBJ;
270 }
271 t_unlock_cpu();
272
273 error_exit:
274 LOG_DEL_MBX_LEAVE(ercd);
275 return(ercd);
276}
277
278#endif /* TOPPERS_del_mbx */
279
280/*
281 * ƒ[ƒ‹ƒ{ƒbƒNƒX‚Ö‚Ì‘—M
282 */
283#ifdef TOPPERS_snd_mbx
284
285ER
286snd_mbx(ID mbxid, T_MSG *pk_msg)
287{
288 MBXCB *p_mbxcb;
289 TCB *p_tcb;
290 ER ercd;
291
292 LOG_SND_MBX_ENTER(mbxid, pk_msg);
293 CHECK_TSKCTX_UNL();
294 CHECK_MBXID(mbxid);
295 p_mbxcb = get_mbxcb(mbxid);
296
297 t_lock_cpu();
298 if (p_mbxcb->p_mbxinib->mbxatr == TA_NOEXS) {
299 ercd = E_NOEXS;
300 }
301 else if (!((p_mbxcb->p_mbxinib->mbxatr & TA_MPRI) == 0U
302 || (TMIN_MPRI <= MSGPRI(pk_msg)
303 && MSGPRI(pk_msg) <= p_mbxcb->p_mbxinib->maxmpri))) {
304 ercd = E_PAR;
305 }
306 else if (!queue_empty(&(p_mbxcb->wait_queue))) {
307 p_tcb = (TCB *) queue_delete_next(&(p_mbxcb->wait_queue));
308 ((WINFO_MBX *)(p_tcb->p_winfo))->pk_msg = pk_msg;
309 if (wait_complete(p_tcb)) {
310 dispatch();
311 }
312 ercd = E_OK;
313 }
314 else if ((p_mbxcb->p_mbxinib->mbxatr & TA_MPRI) != 0U) {
315 enqueue_msg_pri(&(p_mbxcb->pk_head), pk_msg);
316 ercd = E_OK;
317 }
318 else {
319 pk_msg->pk_next = NULL;
320 if (p_mbxcb->pk_head != NULL) {
321 p_mbxcb->pk_last->pk_next = pk_msg;
322 }
323 else {
324 p_mbxcb->pk_head = pk_msg;
325 }
326 p_mbxcb->pk_last = pk_msg;
327 ercd = E_OK;
328 }
329 t_unlock_cpu();
330
331 error_exit:
332 LOG_SND_MBX_LEAVE(ercd);
333 return(ercd);
334}
335
336#endif /* TOPPERS_snd_mbx */
337
338/*
339 * ƒ[ƒ‹ƒ{ƒbƒNƒX‚©‚ç‚ÌŽóM
340 */
341#ifdef TOPPERS_rcv_mbx
342
343ER
344rcv_mbx(ID mbxid, T_MSG **ppk_msg)
345{
346 MBXCB *p_mbxcb;
347 WINFO_MBX winfo_mbx;
348 ER ercd;
349
350 LOG_RCV_MBX_ENTER(mbxid, ppk_msg);
351 CHECK_DISPATCH();
352 CHECK_MBXID(mbxid);
353 p_mbxcb = get_mbxcb(mbxid);
354
355 t_lock_cpu();
356 if (p_mbxcb->p_mbxinib->mbxatr == TA_NOEXS) {
357 ercd = E_NOEXS;
358 }
359 else if (p_mbxcb->pk_head != NULL) {
360 *ppk_msg = p_mbxcb->pk_head;
361 p_mbxcb->pk_head = (*ppk_msg)->pk_next;
362 ercd = E_OK;
363 }
364 else {
365 p_runtsk->tstat = (TS_WAITING | TS_WAIT_MBX);
366 wobj_make_wait((WOBJCB *) p_mbxcb, (WINFO_WOBJ *) &winfo_mbx);
367 dispatch();
368 ercd = winfo_mbx.winfo.wercd;
369 if (ercd == E_OK) {
370 *ppk_msg = winfo_mbx.pk_msg;
371 }
372 }
373 t_unlock_cpu();
374
375 error_exit:
376 LOG_RCV_MBX_LEAVE(ercd, *ppk_msg);
377 return(ercd);
378}
379
380#endif /* TOPPERS_rcv_mbx */
381
382/*
383 * ƒ[ƒ‹ƒ{ƒbƒNƒX‚©‚ç‚ÌŽóMiƒ|[ƒŠƒ“ƒOj
384 */
385#ifdef TOPPERS_prcv_mbx
386
387ER
388prcv_mbx(ID mbxid, T_MSG **ppk_msg)
389{
390 MBXCB *p_mbxcb;
391 ER ercd;
392
393 LOG_PRCV_MBX_ENTER(mbxid, ppk_msg);
394 CHECK_TSKCTX_UNL();
395 CHECK_MBXID(mbxid);
396 p_mbxcb = get_mbxcb(mbxid);
397
398 t_lock_cpu();
399 if (p_mbxcb->p_mbxinib->mbxatr == TA_NOEXS) {
400 ercd = E_NOEXS;
401 }
402 else if (p_mbxcb->pk_head != NULL) {
403 *ppk_msg = p_mbxcb->pk_head;
404 p_mbxcb->pk_head = (*ppk_msg)->pk_next;
405 ercd = E_OK;
406 }
407 else {
408 ercd = E_TMOUT;
409 }
410 t_unlock_cpu();
411
412 error_exit:
413 LOG_PRCV_MBX_LEAVE(ercd, *ppk_msg);
414 return(ercd);
415}
416
417#endif /* TOPPERS_prcv_mbx */
418
419/*
420 * ƒ[ƒ‹ƒ{ƒbƒNƒX‚©‚ç‚ÌŽóMiƒ^ƒCƒ€ƒAƒEƒg‚ ‚èj
421 */
422#ifdef TOPPERS_trcv_mbx
423
424ER
425trcv_mbx(ID mbxid, T_MSG **ppk_msg, TMO tmout)
426{
427 MBXCB *p_mbxcb;
428 WINFO_MBX winfo_mbx;
429 TMEVTB tmevtb;
430 ER ercd;
431
432 LOG_TRCV_MBX_ENTER(mbxid, ppk_msg, tmout);
433 CHECK_DISPATCH();
434 CHECK_MBXID(mbxid);
435 CHECK_TMOUT(tmout);
436 p_mbxcb = get_mbxcb(mbxid);
437
438 t_lock_cpu();
439 if (p_mbxcb->p_mbxinib->mbxatr == TA_NOEXS) {
440 ercd = E_NOEXS;
441 }
442 else if (p_mbxcb->pk_head != NULL) {
443 *ppk_msg = p_mbxcb->pk_head;
444 p_mbxcb->pk_head = (*ppk_msg)->pk_next;
445 ercd = E_OK;
446 }
447 else if (tmout == TMO_POL) {
448 ercd = E_TMOUT;
449 }
450 else {
451 p_runtsk->tstat = (TS_WAITING | TS_WAIT_MBX);
452 wobj_make_wait_tmout((WOBJCB *) p_mbxcb, (WINFO_WOBJ *) &winfo_mbx,
453 &tmevtb, tmout);
454 dispatch();
455 ercd = winfo_mbx.winfo.wercd;
456 if (ercd == E_OK) {
457 *ppk_msg = winfo_mbx.pk_msg;
458 }
459 }
460 t_unlock_cpu();
461
462 error_exit:
463 LOG_TRCV_MBX_LEAVE(ercd, *ppk_msg);
464 return(ercd);
465}
466
467#endif /* TOPPERS_trcv_mbx */
468
469/*
470 * ƒ[ƒ‹ƒ{ƒbƒNƒX‚̍ú‰»
471 */
472#ifdef TOPPERS_ini_mbx
473
474ER
475ini_mbx(ID mbxid)
476{
477 MBXCB *p_mbxcb;
478 bool_t dspreq;
479 ER ercd;
480
481 LOG_INI_MBX_ENTER(mbxid);
482 CHECK_TSKCTX_UNL();
483 CHECK_MBXID(mbxid);
484 p_mbxcb = get_mbxcb(mbxid);
485
486 t_lock_cpu();
487 if (p_mbxcb->p_mbxinib->mbxatr == TA_NOEXS) {
488 ercd = E_NOEXS;
489 }
490 else {
491 dspreq = init_wait_queue(&(p_mbxcb->wait_queue));
492 p_mbxcb->pk_head = NULL;
493 if (dspreq) {
494 dispatch();
495 }
496 ercd = E_OK;
497 }
498 t_unlock_cpu();
499
500 error_exit:
501 LOG_INI_MBX_LEAVE(ercd);
502 return(ercd);
503}
504
505#endif /* TOPPERS_ini_mbx */
506
507/*
508 * ƒ[ƒ‹ƒ{ƒbƒNƒX‚̏ó‘ÔŽQÆ
509 */
510#ifdef TOPPERS_ref_mbx
511
512ER
513ref_mbx(ID mbxid, T_RMBX *pk_rmbx)
514{
515 MBXCB *p_mbxcb;
516 ER ercd;
517
518 LOG_REF_MBX_ENTER(mbxid, pk_rmbx);
519 CHECK_TSKCTX_UNL();
520 CHECK_MBXID(mbxid);
521 p_mbxcb = get_mbxcb(mbxid);
522
523 t_lock_cpu();
524 if (p_mbxcb->p_mbxinib->mbxatr == TA_NOEXS) {
525 ercd = E_NOEXS;
526 }
527 else {
528 pk_rmbx->wtskid = wait_tskid(&(p_mbxcb->wait_queue));
529 pk_rmbx->pk_msg = p_mbxcb->pk_head;
530 ercd = E_OK;
531 }
532 t_unlock_cpu();
533
534 error_exit:
535 LOG_REF_MBX_LEAVE(ercd, pk_rmbx);
536 return(ercd);
537}
538
539#endif /* TOPPERS_ref_mbx */
Note: See TracBrowser for help on using the repository browser.