Changeset 5e96e917 in rtems


Ignore:
Timestamp:
Nov 17, 1999, 3:24:11 PM (22 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
4ccd020
Parents:
c730be8f
Message:

Updated Mailbox Manager submitted and split into multiple files.

Files:
16 added
6 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/itron/include/itronsys/mbox.h

    rc730be8f r5e96e917  
    2222  ATR   mbxatr;   /* mailbox attributes */
    2323  /* Following is implementation-dependent function */
    24   INT   bufcnt;   /* ring buffer size */
     24  INT   bufcnt;   /* maximum number of messages to let pend */
    2525  /* additional information may be included depending on the implementation */
    2626} T_CMBX;
     
    3939   *  A region (header) reserved by the OS may be included first
    4040   *  depending on the implementation.
     41   *
     42   *  NOTE: The first two fields are RTEMS specific.
    4143   */
     44
     45  INT       msgpri;   /* priority of each message */
    4246  /* VB   msgcont[];  XXX */
    4347  unsigned8 msgcont[1];
     
    6468
    6569ER cre_mbx(
    66   ID mbxid,
    67   T_CMBX* pk_cmbx
     70  ID      mbxid,
     71  T_CMBX *pk_cmbx
    6872);
    6973
     
    8185
    8286ER snd_msg(
    83   ID mbxid,
     87  ID     mbxid,
    8488  T_MSG *pk_msg
    8589);
     
    9195ER rcv_msg(
    9296  T_MSG **ppk_msg,
    93   ID mbxid
     97  ID      mbxid
    9498);
    9599
     
    100104ER prcv_msg(
    101105  T_MSG **ppk_msg,
    102   ID mbxid
     106  ID      mbxid
    103107);
    104108
     
    109113ER trcv_msg(
    110114  T_MSG **ppk_msg,
    111   ID mbxid,
    112   TMO tmout
     115  ID      mbxid,
     116  TMO     tmout
    113117);
    114118
     
    119123ER ref_mbx(
    120124  T_RMBX *pk_rmbx,
    121   ID mbxid
     125  ID      mbxid
    122126);
    123127
  • c/src/exec/itron/include/rtems/itron/mbox.h

    rc730be8f r5e96e917  
    1515
    1616#include <rtems/itron/object.h>
     17#include <rtems/score/coremsg.h>
    1718
    1819/*
     
    2122
    2223typedef struct {
    23   ITRON_Objects_Control   Object;
    24   unsigned32              XXX_more_stuff_goes_here;
     24  ITRON_Objects_Control       Object;
     25  unsigned32                  count;
     26  boolean                     do_message_priority;
     27  CORE_message_queue_Control  message_queue;
    2528}   ITRON_Mailbox_Control;
    2629
     
    4548
    4649/*
    47  *  XXX insert private stuff here
     50 *  _ITRON_Mailbox_Translate_core_message_queue_return_code
     51 *
     52 *  DESCRIPTION:
     53 *
     54 *  This routine translates a core message queue object status
     55 *  into the appropriate ITRON status code.
    4856 */
     57
     58ER _ITRON_Mailbox_Translate_core_message_queue_return_code(
     59  CORE_message_queue_Status status
     60);
    4961
    5062#include <rtems/itron/mbox.inl>
  • c/src/exec/itron/src/mbox.c

    rc730be8f r5e96e917  
    1313#include <rtems/itron/mbox.h>
    1414#include <rtems/itron/task.h>
    15 
    16 /*
    17  *  _ITRON_Mailbox_Translate_core_message_queue_return_code
    18  *
    19  *  This routine translates a core message queue object status
    20  *  into the appropriate ITRON status code.
    21  */
    22 
    23 ER _ITRON_Mailbox_Translate_core_message_queue_return_code(
    24   CORE_message_queue_Status status
    25 )
    26 {
    27   switch (status) {
    28     case CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL:
    29       return E_OK;
    30     case CORE_MESSAGE_QUEUE_STATUS_TOO_MANY:
    31       return E_TMOUT;
    32     case CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE:
    33       return E_PAR;
    34     case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT:
    35       return E_TMOUT;
    36     case CORE_MESSAGE_QUEUE_STATUS_TIMEOUT:
    37       return E_TMOUT;
    38     default:
    39       return E_ID;
    40   }
    41 }
    4215
    4316/*   
     
    7750 
    7851}
    79 
    80 
    81 /*
    82  *  cre_mbx - Create Mailbox
    83  *
    84  *      Creates a Mailbox according to the following spec:
    85  *
    86  * ------Parameters-------------------------
    87  *  ID      mbxid   MailboxID
    88  *  T_CMBX *pk_cmbx Packet to Create Mailbox
    89  * -----------------------------------------
    90  *   -*pk_cmbx members*-
    91  *    VP                exinf   ExtendedInformation
    92  *    ATR               mbxatr  MailboxAttributes
    93  *                      (the use of the following information
    94  *                        is implementation dependent)
    95  *    INT               bufcnt  BufferMessageCount
    96  *                      (CPU and/or implementation-dependent information
    97  *                         may also be included)
    98  *
    99  * ----Return Parameters--------------------
    100  *  ER      ercd    ErrorCode
    101  * -----------------------------------------
    102  *
    103  *
    104  * ----C Language Interface-----------------
    105  *  ER ercd = cre_mbx ( ID mbxid, T_CMBX *pk_cmbx ) ;
    106  * -----------------------------------------
    107  *
    108  */
    109 
    110 ER cre_mbx(
    111   ID      mbxid,
    112   T_CMBX *pk_cmbx
    113 )
    114 {
    115   register ITRON_Mailbox_Control *the_mailbox;
    116   CORE_message_queue_Attributes   the_mailbox_attributes;
    117 
    118   if ( !pk_cmbx )
    119     return E_PAR;
    120 
    121   if ((pk_cmbx->mbxatr & (TA_TPRI | TA_MPRI)) != 0 )
    122     return E_RSATR;
    123 
    124   _Thread_Disable_dispatch();              /* protects object pointer */
    125 
    126   the_mailbox = _ITRON_Mailbox_Allocate( mbxid );
    127   if ( !the_mailbox ) {
    128     _Thread_Enable_dispatch();
    129     return _ITRON_Mailbox_Clarify_allocation_id_error( mbxid );
    130   }
    131 
    132   the_mailbox->count = pk_cmbx->bufcnt;
    133   if (pk_cmbx->mbxatr & TA_MPRI)
    134     the_mailbox->do_message_priority = TRUE;
    135   else
    136     the_mailbox->do_message_priority = FALSE;
    137 
    138   if (pk_cmbx->mbxatr & TA_TPRI)
    139     the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
    140   else
    141     the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
    142 
    143   if ( !_CORE_message_queue_Initialize(
    144            &the_mailbox->message_queue,
    145            OBJECTS_ITRON_MAILBOXES,
    146            &the_mailbox_attributes,
    147            the_mailbox->count,
    148            sizeof(T_MSG *),
    149            NULL ) ) {                      /* Multiprocessing not supported */
    150     _ITRON_Mailbox_Free(the_mailbox);
    151     _ITRON_return_errorno( E_OBJ );
    152   }
    153 
    154   _ITRON_Objects_Open( &_ITRON_Mailbox_Information, &the_mailbox->Object );
    155 
    156   /*
    157    *  If multiprocessing were supported, this is where we would announce
    158    *  the existence of the semaphore to the rest of the system.
    159    */
    160 
    161 #if defined(RTEMS_MULTIPROCESSING)
    162 #endif
    163 
    164   _ITRON_return_errorno( E_OK );
    165 }
    166 
    167 /*
    168  *  del_mbx - Delete Mailbox
    169  *
    170  *
    171  * ------Parameters--------------
    172  * ID mbxid      The Mailbox's ID
    173  * ------------------------------
    174  *
    175  * -----Return Parameters-------
    176  * ER ercd       Itron Error Code
    177  * -----------------------------
    178  *
    179  * -----C Language Interface----
    180  * ER ercd = del_mbx(ID mbxid);
    181  * -----------------------------
    182  *
    183  */
    184 
    185 ER del_mbx(
    186   ID mbxid
    187 )
    188 {
    189   register ITRON_Mailbox_Control *the_mailbox;
    190   Objects_Locations               location;
    191 
    192   the_mailbox= _ITRON_Mailbox_Get( mbxid, &location );
    193   switch ( location ) {
    194     case OBJECTS_ERROR:
    195     case OBJECTS_REMOTE:
    196       return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
    197 
    198     case OBJECTS_LOCAL:
    199       _Objects_Close( &_ITRON_Mailbox_Information, &the_mailbox->Object );
    200 
    201       _CORE_message_queue_Close(
    202         &the_mailbox->message_queue,
    203         NULL,                      /* Multiprocessing not supported */
    204         CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED
    205       );
    206 
    207       _ITRON_Mailbox_Free(the_mailbox);
    208       break;
    209   }
    210 
    211   _ITRON_return_errorno( E_OK );
    212 }
    213 
    214 
    215 /*
    216  *  snd_msg - Send Message to Mailbox
    217  */
    218 
    219 ER snd_msg(
    220   ID     mbxid,
    221   T_MSG *pk_msg
    222 )
    223 {
    224   register ITRON_Mailbox_Control *the_mailbox;
    225   Objects_Locations                location;
    226   CORE_message_queue_Status        status = E_OK;
    227   unsigned32                       message_priority;
    228   void                            *message_contents;
    229 
    230   if ( !pk_msg )
    231     return E_PAR;
    232 
    233   the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
    234   switch ( location ) {
    235     case OBJECTS_REMOTE:
    236     case OBJECTS_ERROR:
    237       return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
    238 
    239     case OBJECTS_LOCAL:
    240       if ( the_mailbox->do_message_priority )
    241         message_priority = pk_msg->msgpri;
    242       else
    243         message_priority = CORE_MESSAGE_QUEUE_SEND_REQUEST;
    244 
    245       message_contents = pk_msg;
    246       status = _CORE_message_queue_Submit(
    247         &the_mailbox->message_queue,
    248         &message_contents,
    249         sizeof(T_MSG *),
    250         the_mailbox->Object.id,
    251         NULL,          /* multiprocessing not supported */
    252         message_priority
    253      );
    254      break;
    255   }
    256 
    257   _ITRON_return_errorno(
    258      _ITRON_Mailbox_Translate_core_message_queue_return_code(status) );
    259 }
    260 
    261 /*
    262  *  rcv_msg - Receive Message from Mailbox
    263  */
    264 
    265 ER rcv_msg(
    266   T_MSG **ppk_msg,
    267   ID      mbxid
    268 )
    269 {
    270   return trcv_msg( ppk_msg, mbxid, TMO_FEVR );
    271 }
    272 
    273 /*
    274  *  prcv_msg - Poll and Receive Message from Mailbox
    275  */
    276 
    277 ER prcv_msg(
    278   T_MSG **ppk_msg,
    279   ID      mbxid
    280 )
    281 {
    282   return trcv_msg( ppk_msg, mbxid, TMO_POL );
    283 }
    284 
    285 /*
    286  *  trcv_msg - Receive Message from Mailbox with Timeout
    287  */
    288 
    289 ER trcv_msg(
    290   T_MSG **ppk_msg,
    291   ID      mbxid,
    292   TMO     tmout
    293 )
    294 {
    295   register ITRON_Mailbox_Control *the_mailbox;
    296   Watchdog_Interval               interval;
    297   boolean                         wait;
    298   Objects_Locations               location;
    299   unsigned32                      size;
    300 
    301   if (!ppk_msg)
    302     return E_PAR;
    303 
    304   interval = 0;
    305   if ( tmout == TMO_POL ) {
    306     wait = FALSE;
    307   } else {
    308     wait = TRUE;
    309     if ( tmout != TMO_FEVR )
    310       interval = TOD_MILLISECONDS_TO_TICKS(tmout);
    311   }
    312 
    313   if ( wait && _ITRON_Is_in_non_task_state() )
    314     return E_CTX;
    315 
    316   the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
    317   switch ( location ) {
    318     case OBJECTS_REMOTE:
    319     case OBJECTS_ERROR:
    320       return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
    321 
    322     case OBJECTS_LOCAL:
    323 
    324       _CORE_message_queue_Seize(
    325         &the_mailbox->message_queue,
    326         the_mailbox->Object.id,
    327         ppk_msg,
    328         &size,
    329         wait,
    330         interval
    331       );
    332       break;
    333   }
    334 
    335   _ITRON_return_errorno(
    336     _ITRON_Mailbox_Translate_core_message_queue_return_code(
    337         _Thread_Executing->Wait.return_code ) );
    338 }
    339 
    340 /*
    341  *  ref_mbx - Reference Mailbox Status
    342  */
    343 
    344 ER ref_mbx(
    345   T_RMBX *pk_rmbx,
    346   ID      mbxid
    347 )
    348 {
    349   register ITRON_Mailbox_Control *the_mailbox;
    350   Objects_Locations               location;
    351   Chain_Control                  *pending;
    352 
    353   if ( !pk_rmbx )
    354     return E_PAR;
    355 
    356   the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
    357   switch ( location ) {
    358     case OBJECTS_REMOTE:
    359     case OBJECTS_ERROR:
    360       return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
    361 
    362     case OBJECTS_LOCAL:
    363 
    364       pending = &the_mailbox->message_queue.Pending_messages;
    365       if ( _Chain_Is_empty( pending ) )
    366         pk_rmbx->pk_msg = NULL;
    367       else
    368         pk_rmbx->pk_msg = (T_MSG *) pending->first;
    369 
    370       /*
    371        *  Fill in whether or not there is a waiting task
    372        */
    373 
    374       if ( !_Thread_queue_First( &the_mailbox->message_queue.Wait_queue ) )
    375         pk_rmbx->wtsk = FALSE;
    376       else
    377         pk_rmbx->wtsk = TRUE;
    378 
    379       break;
    380   }
    381   _ITRON_return_errorno( E_OK );
    382 }
    383 
  • cpukit/itron/include/itronsys/mbox.h

    rc730be8f r5e96e917  
    2222  ATR   mbxatr;   /* mailbox attributes */
    2323  /* Following is implementation-dependent function */
    24   INT   bufcnt;   /* ring buffer size */
     24  INT   bufcnt;   /* maximum number of messages to let pend */
    2525  /* additional information may be included depending on the implementation */
    2626} T_CMBX;
     
    3939   *  A region (header) reserved by the OS may be included first
    4040   *  depending on the implementation.
     41   *
     42   *  NOTE: The first two fields are RTEMS specific.
    4143   */
     44
     45  INT       msgpri;   /* priority of each message */
    4246  /* VB   msgcont[];  XXX */
    4347  unsigned8 msgcont[1];
     
    6468
    6569ER cre_mbx(
    66   ID mbxid,
    67   T_CMBX* pk_cmbx
     70  ID      mbxid,
     71  T_CMBX *pk_cmbx
    6872);
    6973
     
    8185
    8286ER snd_msg(
    83   ID mbxid,
     87  ID     mbxid,
    8488  T_MSG *pk_msg
    8589);
     
    9195ER rcv_msg(
    9296  T_MSG **ppk_msg,
    93   ID mbxid
     97  ID      mbxid
    9498);
    9599
     
    100104ER prcv_msg(
    101105  T_MSG **ppk_msg,
    102   ID mbxid
     106  ID      mbxid
    103107);
    104108
     
    109113ER trcv_msg(
    110114  T_MSG **ppk_msg,
    111   ID mbxid,
    112   TMO tmout
     115  ID      mbxid,
     116  TMO     tmout
    113117);
    114118
     
    119123ER ref_mbx(
    120124  T_RMBX *pk_rmbx,
    121   ID mbxid
     125  ID      mbxid
    122126);
    123127
  • cpukit/itron/include/rtems/itron/mbox.h

    rc730be8f r5e96e917  
    1515
    1616#include <rtems/itron/object.h>
     17#include <rtems/score/coremsg.h>
    1718
    1819/*
     
    2122
    2223typedef struct {
    23   ITRON_Objects_Control   Object;
    24   unsigned32              XXX_more_stuff_goes_here;
     24  ITRON_Objects_Control       Object;
     25  unsigned32                  count;
     26  boolean                     do_message_priority;
     27  CORE_message_queue_Control  message_queue;
    2528}   ITRON_Mailbox_Control;
    2629
     
    4548
    4649/*
    47  *  XXX insert private stuff here
     50 *  _ITRON_Mailbox_Translate_core_message_queue_return_code
     51 *
     52 *  DESCRIPTION:
     53 *
     54 *  This routine translates a core message queue object status
     55 *  into the appropriate ITRON status code.
    4856 */
     57
     58ER _ITRON_Mailbox_Translate_core_message_queue_return_code(
     59  CORE_message_queue_Status status
     60);
    4961
    5062#include <rtems/itron/mbox.inl>
  • cpukit/itron/src/mbox.c

    rc730be8f r5e96e917  
    1313#include <rtems/itron/mbox.h>
    1414#include <rtems/itron/task.h>
    15 
    16 /*
    17  *  _ITRON_Mailbox_Translate_core_message_queue_return_code
    18  *
    19  *  This routine translates a core message queue object status
    20  *  into the appropriate ITRON status code.
    21  */
    22 
    23 ER _ITRON_Mailbox_Translate_core_message_queue_return_code(
    24   CORE_message_queue_Status status
    25 )
    26 {
    27   switch (status) {
    28     case CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL:
    29       return E_OK;
    30     case CORE_MESSAGE_QUEUE_STATUS_TOO_MANY:
    31       return E_TMOUT;
    32     case CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE:
    33       return E_PAR;
    34     case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT:
    35       return E_TMOUT;
    36     case CORE_MESSAGE_QUEUE_STATUS_TIMEOUT:
    37       return E_TMOUT;
    38     default:
    39       return E_ID;
    40   }
    41 }
    4215
    4316/*   
     
    7750 
    7851}
    79 
    80 
    81 /*
    82  *  cre_mbx - Create Mailbox
    83  *
    84  *      Creates a Mailbox according to the following spec:
    85  *
    86  * ------Parameters-------------------------
    87  *  ID      mbxid   MailboxID
    88  *  T_CMBX *pk_cmbx Packet to Create Mailbox
    89  * -----------------------------------------
    90  *   -*pk_cmbx members*-
    91  *    VP                exinf   ExtendedInformation
    92  *    ATR               mbxatr  MailboxAttributes
    93  *                      (the use of the following information
    94  *                        is implementation dependent)
    95  *    INT               bufcnt  BufferMessageCount
    96  *                      (CPU and/or implementation-dependent information
    97  *                         may also be included)
    98  *
    99  * ----Return Parameters--------------------
    100  *  ER      ercd    ErrorCode
    101  * -----------------------------------------
    102  *
    103  *
    104  * ----C Language Interface-----------------
    105  *  ER ercd = cre_mbx ( ID mbxid, T_CMBX *pk_cmbx ) ;
    106  * -----------------------------------------
    107  *
    108  */
    109 
    110 ER cre_mbx(
    111   ID      mbxid,
    112   T_CMBX *pk_cmbx
    113 )
    114 {
    115   register ITRON_Mailbox_Control *the_mailbox;
    116   CORE_message_queue_Attributes   the_mailbox_attributes;
    117 
    118   if ( !pk_cmbx )
    119     return E_PAR;
    120 
    121   if ((pk_cmbx->mbxatr & (TA_TPRI | TA_MPRI)) != 0 )
    122     return E_RSATR;
    123 
    124   _Thread_Disable_dispatch();              /* protects object pointer */
    125 
    126   the_mailbox = _ITRON_Mailbox_Allocate( mbxid );
    127   if ( !the_mailbox ) {
    128     _Thread_Enable_dispatch();
    129     return _ITRON_Mailbox_Clarify_allocation_id_error( mbxid );
    130   }
    131 
    132   the_mailbox->count = pk_cmbx->bufcnt;
    133   if (pk_cmbx->mbxatr & TA_MPRI)
    134     the_mailbox->do_message_priority = TRUE;
    135   else
    136     the_mailbox->do_message_priority = FALSE;
    137 
    138   if (pk_cmbx->mbxatr & TA_TPRI)
    139     the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
    140   else
    141     the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
    142 
    143   if ( !_CORE_message_queue_Initialize(
    144            &the_mailbox->message_queue,
    145            OBJECTS_ITRON_MAILBOXES,
    146            &the_mailbox_attributes,
    147            the_mailbox->count,
    148            sizeof(T_MSG *),
    149            NULL ) ) {                      /* Multiprocessing not supported */
    150     _ITRON_Mailbox_Free(the_mailbox);
    151     _ITRON_return_errorno( E_OBJ );
    152   }
    153 
    154   _ITRON_Objects_Open( &_ITRON_Mailbox_Information, &the_mailbox->Object );
    155 
    156   /*
    157    *  If multiprocessing were supported, this is where we would announce
    158    *  the existence of the semaphore to the rest of the system.
    159    */
    160 
    161 #if defined(RTEMS_MULTIPROCESSING)
    162 #endif
    163 
    164   _ITRON_return_errorno( E_OK );
    165 }
    166 
    167 /*
    168  *  del_mbx - Delete Mailbox
    169  *
    170  *
    171  * ------Parameters--------------
    172  * ID mbxid      The Mailbox's ID
    173  * ------------------------------
    174  *
    175  * -----Return Parameters-------
    176  * ER ercd       Itron Error Code
    177  * -----------------------------
    178  *
    179  * -----C Language Interface----
    180  * ER ercd = del_mbx(ID mbxid);
    181  * -----------------------------
    182  *
    183  */
    184 
    185 ER del_mbx(
    186   ID mbxid
    187 )
    188 {
    189   register ITRON_Mailbox_Control *the_mailbox;
    190   Objects_Locations               location;
    191 
    192   the_mailbox= _ITRON_Mailbox_Get( mbxid, &location );
    193   switch ( location ) {
    194     case OBJECTS_ERROR:
    195     case OBJECTS_REMOTE:
    196       return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
    197 
    198     case OBJECTS_LOCAL:
    199       _Objects_Close( &_ITRON_Mailbox_Information, &the_mailbox->Object );
    200 
    201       _CORE_message_queue_Close(
    202         &the_mailbox->message_queue,
    203         NULL,                      /* Multiprocessing not supported */
    204         CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED
    205       );
    206 
    207       _ITRON_Mailbox_Free(the_mailbox);
    208       break;
    209   }
    210 
    211   _ITRON_return_errorno( E_OK );
    212 }
    213 
    214 
    215 /*
    216  *  snd_msg - Send Message to Mailbox
    217  */
    218 
    219 ER snd_msg(
    220   ID     mbxid,
    221   T_MSG *pk_msg
    222 )
    223 {
    224   register ITRON_Mailbox_Control *the_mailbox;
    225   Objects_Locations                location;
    226   CORE_message_queue_Status        status = E_OK;
    227   unsigned32                       message_priority;
    228   void                            *message_contents;
    229 
    230   if ( !pk_msg )
    231     return E_PAR;
    232 
    233   the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
    234   switch ( location ) {
    235     case OBJECTS_REMOTE:
    236     case OBJECTS_ERROR:
    237       return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
    238 
    239     case OBJECTS_LOCAL:
    240       if ( the_mailbox->do_message_priority )
    241         message_priority = pk_msg->msgpri;
    242       else
    243         message_priority = CORE_MESSAGE_QUEUE_SEND_REQUEST;
    244 
    245       message_contents = pk_msg;
    246       status = _CORE_message_queue_Submit(
    247         &the_mailbox->message_queue,
    248         &message_contents,
    249         sizeof(T_MSG *),
    250         the_mailbox->Object.id,
    251         NULL,          /* multiprocessing not supported */
    252         message_priority
    253      );
    254      break;
    255   }
    256 
    257   _ITRON_return_errorno(
    258      _ITRON_Mailbox_Translate_core_message_queue_return_code(status) );
    259 }
    260 
    261 /*
    262  *  rcv_msg - Receive Message from Mailbox
    263  */
    264 
    265 ER rcv_msg(
    266   T_MSG **ppk_msg,
    267   ID      mbxid
    268 )
    269 {
    270   return trcv_msg( ppk_msg, mbxid, TMO_FEVR );
    271 }
    272 
    273 /*
    274  *  prcv_msg - Poll and Receive Message from Mailbox
    275  */
    276 
    277 ER prcv_msg(
    278   T_MSG **ppk_msg,
    279   ID      mbxid
    280 )
    281 {
    282   return trcv_msg( ppk_msg, mbxid, TMO_POL );
    283 }
    284 
    285 /*
    286  *  trcv_msg - Receive Message from Mailbox with Timeout
    287  */
    288 
    289 ER trcv_msg(
    290   T_MSG **ppk_msg,
    291   ID      mbxid,
    292   TMO     tmout
    293 )
    294 {
    295   register ITRON_Mailbox_Control *the_mailbox;
    296   Watchdog_Interval               interval;
    297   boolean                         wait;
    298   Objects_Locations               location;
    299   unsigned32                      size;
    300 
    301   if (!ppk_msg)
    302     return E_PAR;
    303 
    304   interval = 0;
    305   if ( tmout == TMO_POL ) {
    306     wait = FALSE;
    307   } else {
    308     wait = TRUE;
    309     if ( tmout != TMO_FEVR )
    310       interval = TOD_MILLISECONDS_TO_TICKS(tmout);
    311   }
    312 
    313   if ( wait && _ITRON_Is_in_non_task_state() )
    314     return E_CTX;
    315 
    316   the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
    317   switch ( location ) {
    318     case OBJECTS_REMOTE:
    319     case OBJECTS_ERROR:
    320       return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
    321 
    322     case OBJECTS_LOCAL:
    323 
    324       _CORE_message_queue_Seize(
    325         &the_mailbox->message_queue,
    326         the_mailbox->Object.id,
    327         ppk_msg,
    328         &size,
    329         wait,
    330         interval
    331       );
    332       break;
    333   }
    334 
    335   _ITRON_return_errorno(
    336     _ITRON_Mailbox_Translate_core_message_queue_return_code(
    337         _Thread_Executing->Wait.return_code ) );
    338 }
    339 
    340 /*
    341  *  ref_mbx - Reference Mailbox Status
    342  */
    343 
    344 ER ref_mbx(
    345   T_RMBX *pk_rmbx,
    346   ID      mbxid
    347 )
    348 {
    349   register ITRON_Mailbox_Control *the_mailbox;
    350   Objects_Locations               location;
    351   Chain_Control                  *pending;
    352 
    353   if ( !pk_rmbx )
    354     return E_PAR;
    355 
    356   the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
    357   switch ( location ) {
    358     case OBJECTS_REMOTE:
    359     case OBJECTS_ERROR:
    360       return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
    361 
    362     case OBJECTS_LOCAL:
    363 
    364       pending = &the_mailbox->message_queue.Pending_messages;
    365       if ( _Chain_Is_empty( pending ) )
    366         pk_rmbx->pk_msg = NULL;
    367       else
    368         pk_rmbx->pk_msg = (T_MSG *) pending->first;
    369 
    370       /*
    371        *  Fill in whether or not there is a waiting task
    372        */
    373 
    374       if ( !_Thread_queue_First( &the_mailbox->message_queue.Wait_queue ) )
    375         pk_rmbx->wtsk = FALSE;
    376       else
    377         pk_rmbx->wtsk = TRUE;
    378 
    379       break;
    380   }
    381   _ITRON_return_errorno( E_OK );
    382 }
    383 
Note: See TracChangeset for help on using the changeset viewer.