Changeset 9da0994 in rtems
- Timestamp:
- 11/15/99 17:15:58 (24 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- cb193710
- Parents:
- fb27af76
- Files:
-
- 20 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/itron/src/Makefile.in
rfb27af76 r9da0994 27 27 MAILBOX_C_PIECES = mbox 28 28 29 MSGBUFFER_C_PIECES = msgbuffer 29 MSGBUFFER_C_PIECES = msgbuffer msgbuffertranslatereturncode \ 30 cre_mbf del_mbf prcv_mbf psnd_mbf rcv_mbf ref_mbf snd_mbf trcv_mbf \ 31 tsnd_mbf 30 32 31 33 RENDEZVOUS_C_PIECES = port -
c/src/exec/itron/src/msgbuffer.c
rfb27af76 r9da0994 13 13 #include <rtems/itron/msgbuffer.h> 14 14 #include <rtems/itron/task.h> 15 16 ER _ITRON_Message_buffer_Translate_core_message_buffer_return_code(17 CORE_message_queue_Status status18 )19 {20 switch (status) {21 case CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL:22 return E_OK;23 case CORE_MESSAGE_QUEUE_STATUS_TOO_MANY:24 return E_TMOUT;25 case CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE:26 return E_PAR;27 case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT:28 return E_TMOUT;29 case CORE_MESSAGE_QUEUE_STATUS_TIMEOUT:30 return E_TMOUT;31 default:32 return E_ID;33 }34 }35 15 36 16 /* … … 73 53 } 74 54 75 /*76 * cre_mbf - Create MessageBuffer77 */78 79 ER cre_mbf(80 ID mbfid,81 T_CMBF *pk_cmbf82 )83 {84 CORE_message_queue_Attributes the_message_queue_attributes;85 ITRON_Message_buffer_Control *the_message_buffer;86 87 /*88 * Bad pointer to the attributes structure89 */90 91 if ( !pk_cmbf )92 return E_PAR;93 94 /*95 * Bits were set that were note defined.96 */97 98 if (pk_cmbf->mbfatr & ~(TA_TPRI))99 return E_RSATR;100 101 if (pk_cmbf->bufsz < 0 || pk_cmbf->maxmsz < 0)102 return E_PAR;103 104 if (pk_cmbf->bufsz < pk_cmbf->maxmsz)105 return E_PAR;106 107 _Thread_Disable_dispatch(); /* prevents deletion */108 109 the_message_buffer = _ITRON_Message_buffer_Allocate(mbfid);110 if ( !the_message_buffer ) {111 _Thread_Enable_dispatch();112 return _ITRON_Message_buffer_Clarify_allocation_id_error(mbfid);113 }114 115 if ( pk_cmbf->mbfatr & TA_TPRI )116 the_message_queue_attributes.discipline =117 CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;118 else119 the_message_queue_attributes.discipline =120 CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;121 122 _CORE_message_queue_Initialize(123 &the_message_buffer->message_queue,124 OBJECTS_ITRON_MESSAGE_BUFFERS,125 &the_message_queue_attributes,126 pk_cmbf->bufsz / pk_cmbf->maxmsz,127 pk_cmbf->maxmsz,128 NULL /* Multiprocessing not supported */129 );130 131 _ITRON_Objects_Open( &_ITRON_Message_buffer_Information,132 &the_message_buffer->Object );133 134 /*135 * If multiprocessing were supported, this is where we would announce136 * the existence of the semaphore to the rest of the system.137 */138 139 #if defined(RTEMS_MULTIPROCESSING)140 #endif141 142 _Thread_Enable_dispatch();143 144 return E_OK;145 }146 147 /*148 * del_mbf - Delete MessageBuffer149 */150 151 ER del_mbf(152 ID mbfid153 )154 {155 ITRON_Message_buffer_Control *the_message_buffer;156 Objects_Locations location;157 158 the_message_buffer = _ITRON_Message_buffer_Get(mbfid, &location);159 switch (location) {160 case OBJECTS_REMOTE:161 case OBJECTS_ERROR: /* Multiprocessing not supported */162 return _ITRON_Message_buffer_Clarify_get_id_error(mbfid);163 164 case OBJECTS_LOCAL:165 _CORE_message_queue_Flush(&the_message_buffer->message_queue);166 _ITRON_Objects_Close( &_ITRON_Message_buffer_Information,167 &the_message_buffer->Object);168 _ITRON_Message_buffer_Free(the_message_buffer);169 170 /*171 * If multiprocessing were supported, this is where we would announce172 * the existence of the semaphore to the rest of the system.173 */174 175 #if defined(RTEMS_MULTIPROCESSING)176 #endif177 _Thread_Enable_dispatch();178 return E_OK;179 }180 181 return E_OK;182 }183 184 /*185 * snd_mbf - Send Message to MessageBuffer186 */187 188 ER snd_mbf(189 ID mbfid,190 VP msg,191 INT msgsz192 )193 {194 return E_OK;195 }196 197 /*198 * psnd_mbf - Poll and Send Message to MessageBuffer199 */200 201 ER psnd_mbf(202 ID mbfid,203 VP msg,204 INT msgsz205 )206 {207 ITRON_Message_buffer_Control *the_message_buffer;208 Objects_Locations location;209 CORE_message_queue_Status status;210 211 if (msgsz <= 0 || !msg)212 return E_PAR;213 214 the_message_buffer = _ITRON_Message_buffer_Get(mbfid, &location);215 switch (location) {216 case OBJECTS_REMOTE:217 case OBJECTS_ERROR: /* Multiprocessing not supported */218 return _ITRON_Message_buffer_Clarify_get_id_error(mbfid);219 220 case OBJECTS_LOCAL:221 status = _CORE_message_queue_Submit(222 &the_message_buffer->message_queue,223 msg,224 msgsz,225 the_message_buffer->Object.id,226 NULL,227 CORE_MESSAGE_QUEUE_SEND_REQUEST228 );229 _Thread_Enable_dispatch();230 return231 _ITRON_Message_buffer_Translate_core_message_buffer_return_code(status);232 }233 234 /*235 * If multiprocessing were supported, this is where we would announce236 * the existence of the semaphore to the rest of the system.237 */238 239 #if defined(RTEMS_MULTIPROCESSING)240 #endif241 242 return E_OK;243 }244 245 /*246 * tsnd_mbf - Send Message to MessageBuffer with Timeout247 */248 249 ER tsnd_mbf(250 ID mbfid,251 VP msg,252 INT msgsz,253 TMO tmout254 )255 {256 return E_OK;257 }258 259 /*260 * rcv_mbf - Receive Message from MessageBuffer261 */262 263 ER rcv_mbf(264 VP msg,265 INT *p_msgsz,266 ID mbfid267 )268 {269 return trcv_mbf(msg, p_msgsz, mbfid, TMO_FEVR);270 }271 272 /*273 * prcv_mbf - Poll and Receive Message from MessageBuffer274 */275 276 ER prcv_mbf(277 VP msg,278 INT *p_msgsz,279 ID mbfid280 )281 {282 return trcv_mbf(msg, p_msgsz, mbfid, TMO_POL);283 }284 285 /*286 * trcv_mbf - Receive Message from MessageBuffer with Timeout287 */288 289 ER trcv_mbf(290 VP msg,291 INT *p_msgsz,292 ID mbfid,293 TMO tmout294 )295 {296 ITRON_Message_buffer_Control *the_message_buffer;297 Objects_Locations location;298 CORE_message_queue_Status status;299 boolean wait;300 Watchdog_Interval interval;301 302 interval = 0;303 if (tmout == TMO_POL) {304 wait = FALSE;305 } else {306 wait = TRUE;307 if (tmout != TMO_FEVR)308 interval = TOD_MILLISECONDS_TO_TICKS(tmout);309 }310 311 if (wait && _ITRON_Is_in_non_task_state() )312 return E_CTX;313 314 if (!p_msgsz || !msg || tmout <= -2)315 return E_PAR;316 317 the_message_buffer = _ITRON_Message_buffer_Get(mbfid, &location);318 switch (location) {319 case OBJECTS_REMOTE:320 case OBJECTS_ERROR: /* Multiprocessing not supported */321 return _ITRON_Message_buffer_Clarify_get_id_error(mbfid);322 323 case OBJECTS_LOCAL:324 _CORE_message_queue_Seize(325 &the_message_buffer->message_queue,326 the_message_buffer->Object.id,327 msg,328 p_msgsz,329 wait,330 interval331 );332 _Thread_Enable_dispatch();333 status = (CORE_message_queue_Status)_Thread_Executing->Wait.return_code;334 return335 _ITRON_Message_buffer_Translate_core_message_buffer_return_code(status);336 }337 338 /*339 * If multiprocessing were supported, this is where we would announce340 * the existence of the semaphore to the rest of the system.341 */342 343 #if defined(RTEMS_MULTIPROCESSING)344 #endif345 return E_OK;346 }347 348 /*349 * ref_mbf - Reference MessageBuffer Status350 */351 352 ER ref_mbf(353 T_RMBF *pk_rmbf,354 ID mbfid355 )356 {357 ITRON_Message_buffer_Control *the_message_buffer;358 Objects_Locations location;359 CORE_message_queue_Control *the_core_msgq;360 361 if ( !pk_rmbf )362 return E_PAR; /* XXX check this error code */363 364 the_message_buffer = _ITRON_Message_buffer_Get( mbfid, &location );365 switch ( location ) {366 case OBJECTS_REMOTE: /* Multiprocessing not supported */367 case OBJECTS_ERROR:368 return _ITRON_Message_buffer_Clarify_get_id_error( mbfid );369 370 case OBJECTS_LOCAL:371 the_core_msgq = &the_message_buffer->message_queue;372 373 /*374 * Fill in the size of message to be sent375 */376 377 if (the_core_msgq->number_of_pending_messages == 0) {378 pk_rmbf->msgsz = 0;379 } else {380 pk_rmbf->msgsz = ((CORE_message_queue_Buffer_control *)381 the_core_msgq->Pending_messages.first)->Contents.size;382 }383 384 /*385 * Fill in the size of free buffer386 */387 388 pk_rmbf->frbufsz =389 (the_core_msgq->maximum_pending_messages -390 the_core_msgq->number_of_pending_messages) *391 the_core_msgq->maximum_message_size;392 393 394 /*395 * Fill in whether or not there is a waiting task396 */397 398 if ( !_Thread_queue_First(&the_core_msgq->Wait_queue ) )399 pk_rmbf->wtsk = FALSE;400 else401 pk_rmbf->wtsk = TRUE;402 403 pk_rmbf->stsk = FALSE;404 _Thread_Enable_dispatch();405 return E_OK;406 }407 return E_OK;408 } -
cpukit/itron/src/msgbuffer.c
rfb27af76 r9da0994 13 13 #include <rtems/itron/msgbuffer.h> 14 14 #include <rtems/itron/task.h> 15 16 ER _ITRON_Message_buffer_Translate_core_message_buffer_return_code(17 CORE_message_queue_Status status18 )19 {20 switch (status) {21 case CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL:22 return E_OK;23 case CORE_MESSAGE_QUEUE_STATUS_TOO_MANY:24 return E_TMOUT;25 case CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE:26 return E_PAR;27 case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT:28 return E_TMOUT;29 case CORE_MESSAGE_QUEUE_STATUS_TIMEOUT:30 return E_TMOUT;31 default:32 return E_ID;33 }34 }35 15 36 16 /* … … 73 53 } 74 54 75 /*76 * cre_mbf - Create MessageBuffer77 */78 79 ER cre_mbf(80 ID mbfid,81 T_CMBF *pk_cmbf82 )83 {84 CORE_message_queue_Attributes the_message_queue_attributes;85 ITRON_Message_buffer_Control *the_message_buffer;86 87 /*88 * Bad pointer to the attributes structure89 */90 91 if ( !pk_cmbf )92 return E_PAR;93 94 /*95 * Bits were set that were note defined.96 */97 98 if (pk_cmbf->mbfatr & ~(TA_TPRI))99 return E_RSATR;100 101 if (pk_cmbf->bufsz < 0 || pk_cmbf->maxmsz < 0)102 return E_PAR;103 104 if (pk_cmbf->bufsz < pk_cmbf->maxmsz)105 return E_PAR;106 107 _Thread_Disable_dispatch(); /* prevents deletion */108 109 the_message_buffer = _ITRON_Message_buffer_Allocate(mbfid);110 if ( !the_message_buffer ) {111 _Thread_Enable_dispatch();112 return _ITRON_Message_buffer_Clarify_allocation_id_error(mbfid);113 }114 115 if ( pk_cmbf->mbfatr & TA_TPRI )116 the_message_queue_attributes.discipline =117 CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;118 else119 the_message_queue_attributes.discipline =120 CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;121 122 _CORE_message_queue_Initialize(123 &the_message_buffer->message_queue,124 OBJECTS_ITRON_MESSAGE_BUFFERS,125 &the_message_queue_attributes,126 pk_cmbf->bufsz / pk_cmbf->maxmsz,127 pk_cmbf->maxmsz,128 NULL /* Multiprocessing not supported */129 );130 131 _ITRON_Objects_Open( &_ITRON_Message_buffer_Information,132 &the_message_buffer->Object );133 134 /*135 * If multiprocessing were supported, this is where we would announce136 * the existence of the semaphore to the rest of the system.137 */138 139 #if defined(RTEMS_MULTIPROCESSING)140 #endif141 142 _Thread_Enable_dispatch();143 144 return E_OK;145 }146 147 /*148 * del_mbf - Delete MessageBuffer149 */150 151 ER del_mbf(152 ID mbfid153 )154 {155 ITRON_Message_buffer_Control *the_message_buffer;156 Objects_Locations location;157 158 the_message_buffer = _ITRON_Message_buffer_Get(mbfid, &location);159 switch (location) {160 case OBJECTS_REMOTE:161 case OBJECTS_ERROR: /* Multiprocessing not supported */162 return _ITRON_Message_buffer_Clarify_get_id_error(mbfid);163 164 case OBJECTS_LOCAL:165 _CORE_message_queue_Flush(&the_message_buffer->message_queue);166 _ITRON_Objects_Close( &_ITRON_Message_buffer_Information,167 &the_message_buffer->Object);168 _ITRON_Message_buffer_Free(the_message_buffer);169 170 /*171 * If multiprocessing were supported, this is where we would announce172 * the existence of the semaphore to the rest of the system.173 */174 175 #if defined(RTEMS_MULTIPROCESSING)176 #endif177 _Thread_Enable_dispatch();178 return E_OK;179 }180 181 return E_OK;182 }183 184 /*185 * snd_mbf - Send Message to MessageBuffer186 */187 188 ER snd_mbf(189 ID mbfid,190 VP msg,191 INT msgsz192 )193 {194 return E_OK;195 }196 197 /*198 * psnd_mbf - Poll and Send Message to MessageBuffer199 */200 201 ER psnd_mbf(202 ID mbfid,203 VP msg,204 INT msgsz205 )206 {207 ITRON_Message_buffer_Control *the_message_buffer;208 Objects_Locations location;209 CORE_message_queue_Status status;210 211 if (msgsz <= 0 || !msg)212 return E_PAR;213 214 the_message_buffer = _ITRON_Message_buffer_Get(mbfid, &location);215 switch (location) {216 case OBJECTS_REMOTE:217 case OBJECTS_ERROR: /* Multiprocessing not supported */218 return _ITRON_Message_buffer_Clarify_get_id_error(mbfid);219 220 case OBJECTS_LOCAL:221 status = _CORE_message_queue_Submit(222 &the_message_buffer->message_queue,223 msg,224 msgsz,225 the_message_buffer->Object.id,226 NULL,227 CORE_MESSAGE_QUEUE_SEND_REQUEST228 );229 _Thread_Enable_dispatch();230 return231 _ITRON_Message_buffer_Translate_core_message_buffer_return_code(status);232 }233 234 /*235 * If multiprocessing were supported, this is where we would announce236 * the existence of the semaphore to the rest of the system.237 */238 239 #if defined(RTEMS_MULTIPROCESSING)240 #endif241 242 return E_OK;243 }244 245 /*246 * tsnd_mbf - Send Message to MessageBuffer with Timeout247 */248 249 ER tsnd_mbf(250 ID mbfid,251 VP msg,252 INT msgsz,253 TMO tmout254 )255 {256 return E_OK;257 }258 259 /*260 * rcv_mbf - Receive Message from MessageBuffer261 */262 263 ER rcv_mbf(264 VP msg,265 INT *p_msgsz,266 ID mbfid267 )268 {269 return trcv_mbf(msg, p_msgsz, mbfid, TMO_FEVR);270 }271 272 /*273 * prcv_mbf - Poll and Receive Message from MessageBuffer274 */275 276 ER prcv_mbf(277 VP msg,278 INT *p_msgsz,279 ID mbfid280 )281 {282 return trcv_mbf(msg, p_msgsz, mbfid, TMO_POL);283 }284 285 /*286 * trcv_mbf - Receive Message from MessageBuffer with Timeout287 */288 289 ER trcv_mbf(290 VP msg,291 INT *p_msgsz,292 ID mbfid,293 TMO tmout294 )295 {296 ITRON_Message_buffer_Control *the_message_buffer;297 Objects_Locations location;298 CORE_message_queue_Status status;299 boolean wait;300 Watchdog_Interval interval;301 302 interval = 0;303 if (tmout == TMO_POL) {304 wait = FALSE;305 } else {306 wait = TRUE;307 if (tmout != TMO_FEVR)308 interval = TOD_MILLISECONDS_TO_TICKS(tmout);309 }310 311 if (wait && _ITRON_Is_in_non_task_state() )312 return E_CTX;313 314 if (!p_msgsz || !msg || tmout <= -2)315 return E_PAR;316 317 the_message_buffer = _ITRON_Message_buffer_Get(mbfid, &location);318 switch (location) {319 case OBJECTS_REMOTE:320 case OBJECTS_ERROR: /* Multiprocessing not supported */321 return _ITRON_Message_buffer_Clarify_get_id_error(mbfid);322 323 case OBJECTS_LOCAL:324 _CORE_message_queue_Seize(325 &the_message_buffer->message_queue,326 the_message_buffer->Object.id,327 msg,328 p_msgsz,329 wait,330 interval331 );332 _Thread_Enable_dispatch();333 status = (CORE_message_queue_Status)_Thread_Executing->Wait.return_code;334 return335 _ITRON_Message_buffer_Translate_core_message_buffer_return_code(status);336 }337 338 /*339 * If multiprocessing were supported, this is where we would announce340 * the existence of the semaphore to the rest of the system.341 */342 343 #if defined(RTEMS_MULTIPROCESSING)344 #endif345 return E_OK;346 }347 348 /*349 * ref_mbf - Reference MessageBuffer Status350 */351 352 ER ref_mbf(353 T_RMBF *pk_rmbf,354 ID mbfid355 )356 {357 ITRON_Message_buffer_Control *the_message_buffer;358 Objects_Locations location;359 CORE_message_queue_Control *the_core_msgq;360 361 if ( !pk_rmbf )362 return E_PAR; /* XXX check this error code */363 364 the_message_buffer = _ITRON_Message_buffer_Get( mbfid, &location );365 switch ( location ) {366 case OBJECTS_REMOTE: /* Multiprocessing not supported */367 case OBJECTS_ERROR:368 return _ITRON_Message_buffer_Clarify_get_id_error( mbfid );369 370 case OBJECTS_LOCAL:371 the_core_msgq = &the_message_buffer->message_queue;372 373 /*374 * Fill in the size of message to be sent375 */376 377 if (the_core_msgq->number_of_pending_messages == 0) {378 pk_rmbf->msgsz = 0;379 } else {380 pk_rmbf->msgsz = ((CORE_message_queue_Buffer_control *)381 the_core_msgq->Pending_messages.first)->Contents.size;382 }383 384 /*385 * Fill in the size of free buffer386 */387 388 pk_rmbf->frbufsz =389 (the_core_msgq->maximum_pending_messages -390 the_core_msgq->number_of_pending_messages) *391 the_core_msgq->maximum_message_size;392 393 394 /*395 * Fill in whether or not there is a waiting task396 */397 398 if ( !_Thread_queue_First(&the_core_msgq->Wait_queue ) )399 pk_rmbf->wtsk = FALSE;400 else401 pk_rmbf->wtsk = TRUE;402 403 pk_rmbf->stsk = FALSE;404 _Thread_Enable_dispatch();405 return E_OK;406 }407 return E_OK;408 }
Note: See TracChangeset
for help on using the changeset viewer.