summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-11-17 15:24:11 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-11-17 15:24:11 +0000
commit5e96e917578509149814e300d56d2a7d47b7f268 (patch)
tree9d5057fdaa5b220839a7c7d6c426e207878949fd
parentCorrected spacing. (diff)
downloadrtems-5e96e917578509149814e300d56d2a7d47b7f268.tar.bz2
Updated Mailbox Manager submitted and split into multiple files.
-rw-r--r--c/src/exec/itron/include/itronsys/mbox.h22
-rw-r--r--c/src/exec/itron/include/rtems/itron/mbox.h18
-rw-r--r--c/src/exec/itron/src/cre_mbx.c100
-rw-r--r--c/src/exec/itron/src/del_mbx.c61
-rw-r--r--c/src/exec/itron/src/mbox.c332
-rw-r--r--c/src/exec/itron/src/mboxtranslatereturncode.c41
-rw-r--r--c/src/exec/itron/src/prcv_mbx.c26
-rw-r--r--c/src/exec/itron/src/rcv_mbx.c26
-rw-r--r--c/src/exec/itron/src/ref_mbx.c59
-rw-r--r--c/src/exec/itron/src/snd_mbx.c60
-rw-r--r--c/src/exec/itron/src/trcv_mbx.c69
-rw-r--r--cpukit/itron/include/itronsys/mbox.h22
-rw-r--r--cpukit/itron/include/rtems/itron/mbox.h18
-rw-r--r--cpukit/itron/src/cre_mbx.c100
-rw-r--r--cpukit/itron/src/del_mbx.c61
-rw-r--r--cpukit/itron/src/mbox.c332
-rw-r--r--cpukit/itron/src/mboxtranslatereturncode.c41
-rw-r--r--cpukit/itron/src/prcv_mbx.c26
-rw-r--r--cpukit/itron/src/rcv_mbx.c26
-rw-r--r--cpukit/itron/src/ref_mbx.c59
-rw-r--r--cpukit/itron/src/snd_mbx.c60
-rw-r--r--cpukit/itron/src/trcv_mbx.c69
22 files changed, 940 insertions, 688 deletions
diff --git a/c/src/exec/itron/include/itronsys/mbox.h b/c/src/exec/itron/include/itronsys/mbox.h
index ef0581d02e..4196035b2c 100644
--- a/c/src/exec/itron/include/itronsys/mbox.h
+++ b/c/src/exec/itron/include/itronsys/mbox.h
@@ -21,7 +21,7 @@ typedef struct t_cmbx {
VP exinf; /* extended information */
ATR mbxatr; /* mailbox attributes */
/* Following is implementation-dependent function */
- INT bufcnt; /* ring buffer size */
+ INT bufcnt; /* maximum number of messages to let pend */
/* additional information may be included depending on the implementation */
} T_CMBX;
@@ -38,7 +38,11 @@ typedef struct t_msg {
/*
* A region (header) reserved by the OS may be included first
* depending on the implementation.
+ *
+ * NOTE: The first two fields are RTEMS specific.
*/
+
+ INT msgpri; /* priority of each message */
/* VB msgcont[]; XXX */
unsigned8 msgcont[1];
} T_MSG;
@@ -63,8 +67,8 @@ typedef struct t_rmbx {
*/
ER cre_mbx(
- ID mbxid,
- T_CMBX* pk_cmbx
+ ID mbxid,
+ T_CMBX *pk_cmbx
);
/*
@@ -80,7 +84,7 @@ ER del_mbx(
*/
ER snd_msg(
- ID mbxid,
+ ID mbxid,
T_MSG *pk_msg
);
@@ -90,7 +94,7 @@ ER snd_msg(
ER rcv_msg(
T_MSG **ppk_msg,
- ID mbxid
+ ID mbxid
);
/*
@@ -99,7 +103,7 @@ ER rcv_msg(
ER prcv_msg(
T_MSG **ppk_msg,
- ID mbxid
+ ID mbxid
);
/*
@@ -108,8 +112,8 @@ ER prcv_msg(
ER trcv_msg(
T_MSG **ppk_msg,
- ID mbxid,
- TMO tmout
+ ID mbxid,
+ TMO tmout
);
/*
@@ -118,7 +122,7 @@ ER trcv_msg(
ER ref_mbx(
T_RMBX *pk_rmbx,
- ID mbxid
+ ID mbxid
);
diff --git a/c/src/exec/itron/include/rtems/itron/mbox.h b/c/src/exec/itron/include/rtems/itron/mbox.h
index 5ce4180643..c0e0d53ea1 100644
--- a/c/src/exec/itron/include/rtems/itron/mbox.h
+++ b/c/src/exec/itron/include/rtems/itron/mbox.h
@@ -14,14 +14,17 @@ extern "C" {
#endif
#include <rtems/itron/object.h>
+#include <rtems/score/coremsg.h>
/*
* The following defines the control block used to manage each mailbox.
*/
typedef struct {
- ITRON_Objects_Control Object;
- unsigned32 XXX_more_stuff_goes_here;
+ ITRON_Objects_Control Object;
+ unsigned32 count;
+ boolean do_message_priority;
+ CORE_message_queue_Control message_queue;
} ITRON_Mailbox_Control;
/*
@@ -44,9 +47,18 @@ void _ITRON_Mailbox_Manager_initialization(
);
/*
- * XXX insert private stuff here
+ * _ITRON_Mailbox_Translate_core_message_queue_return_code
+ *
+ * DESCRIPTION:
+ *
+ * This routine translates a core message queue object status
+ * into the appropriate ITRON status code.
*/
+ER _ITRON_Mailbox_Translate_core_message_queue_return_code(
+ CORE_message_queue_Status status
+);
+
#include <rtems/itron/mbox.inl>
#ifdef __cplusplus
diff --git a/c/src/exec/itron/src/cre_mbx.c b/c/src/exec/itron/src/cre_mbx.c
new file mode 100644
index 0000000000..7a5cb30170
--- /dev/null
+++ b/c/src/exec/itron/src/cre_mbx.c
@@ -0,0 +1,100 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * cre_mbx - Create Mailbox
+ *
+ * Creates a Mailbox according to the following spec:
+ *
+ * ------Parameters-------------------------
+ * ID mbxid MailboxID
+ * T_CMBX *pk_cmbx Packet to Create Mailbox
+ * -----------------------------------------
+ * -*pk_cmbx members*-
+ * VP exinf ExtendedInformation
+ * ATR mbxatr MailboxAttributes
+ * (the use of the following information
+ * is implementation dependent)
+ * INT bufcnt BufferMessageCount
+ * (CPU and/or implementation-dependent information
+ * may also be included)
+ *
+ * ----Return Parameters--------------------
+ * ER ercd ErrorCode
+ * -----------------------------------------
+ *
+ *
+ * ----C Language Interface-----------------
+ * ER ercd = cre_mbx ( ID mbxid, T_CMBX *pk_cmbx ) ;
+ * -----------------------------------------
+ *
+ */
+
+ER cre_mbx(
+ ID mbxid,
+ T_CMBX *pk_cmbx
+)
+{
+ register ITRON_Mailbox_Control *the_mailbox;
+ CORE_message_queue_Attributes the_mailbox_attributes;
+
+ if ( !pk_cmbx )
+ return E_PAR;
+
+ if ((pk_cmbx->mbxatr & (TA_TPRI | TA_MPRI)) != 0 )
+ return E_RSATR;
+
+ _Thread_Disable_dispatch(); /* protects object pointer */
+
+ the_mailbox = _ITRON_Mailbox_Allocate( mbxid );
+ if ( !the_mailbox ) {
+ _Thread_Enable_dispatch();
+ return _ITRON_Mailbox_Clarify_allocation_id_error( mbxid );
+ }
+
+ the_mailbox->count = pk_cmbx->bufcnt;
+ if (pk_cmbx->mbxatr & TA_MPRI)
+ the_mailbox->do_message_priority = TRUE;
+ else
+ the_mailbox->do_message_priority = FALSE;
+
+ if (pk_cmbx->mbxatr & TA_TPRI)
+ the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
+ else
+ the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
+
+ if ( !_CORE_message_queue_Initialize(
+ &the_mailbox->message_queue,
+ OBJECTS_ITRON_MAILBOXES,
+ &the_mailbox_attributes,
+ the_mailbox->count,
+ sizeof(T_MSG *),
+ NULL ) ) { /* Multiprocessing not supported */
+ _ITRON_Mailbox_Free(the_mailbox);
+ _ITRON_return_errorno( E_OBJ );
+ }
+
+ _ITRON_Objects_Open( &_ITRON_Mailbox_Information, &the_mailbox->Object );
+
+ /*
+ * If multiprocessing were supported, this is where we would announce
+ * the existence of the semaphore to the rest of the system.
+ */
+
+#if defined(RTEMS_MULTIPROCESSING)
+#endif
+
+ _ITRON_return_errorno( E_OK );
+}
diff --git a/c/src/exec/itron/src/del_mbx.c b/c/src/exec/itron/src/del_mbx.c
new file mode 100644
index 0000000000..9006e5f3b4
--- /dev/null
+++ b/c/src/exec/itron/src/del_mbx.c
@@ -0,0 +1,61 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * del_mbx - Delete Mailbox
+ *
+ *
+ * ------Parameters--------------
+ * ID mbxid The Mailbox's ID
+ * ------------------------------
+ *
+ * -----Return Parameters-------
+ * ER ercd Itron Error Code
+ * -----------------------------
+ *
+ * -----C Language Interface----
+ * ER ercd = del_mbx(ID mbxid);
+ * -----------------------------
+ *
+ */
+
+ER del_mbx(
+ ID mbxid
+)
+{
+ register ITRON_Mailbox_Control *the_mailbox;
+ Objects_Locations location;
+
+ the_mailbox= _ITRON_Mailbox_Get( mbxid, &location );
+ switch ( location ) {
+ case OBJECTS_ERROR:
+ case OBJECTS_REMOTE:
+ return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
+
+ case OBJECTS_LOCAL:
+ _Objects_Close( &_ITRON_Mailbox_Information, &the_mailbox->Object );
+
+ _CORE_message_queue_Close(
+ &the_mailbox->message_queue,
+ NULL, /* Multiprocessing not supported */
+ CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED
+ );
+
+ _ITRON_Mailbox_Free(the_mailbox);
+ break;
+ }
+
+ _ITRON_return_errorno( E_OK );
+}
diff --git a/c/src/exec/itron/src/mbox.c b/c/src/exec/itron/src/mbox.c
index 9a2f925429..ff1e0249ed 100644
--- a/c/src/exec/itron/src/mbox.c
+++ b/c/src/exec/itron/src/mbox.c
@@ -13,33 +13,6 @@
#include <rtems/itron/mbox.h>
#include <rtems/itron/task.h>
-/*
- * _ITRON_Mailbox_Translate_core_message_queue_return_code
- *
- * This routine translates a core message queue object status
- * into the appropriate ITRON status code.
- */
-
-ER _ITRON_Mailbox_Translate_core_message_queue_return_code(
- CORE_message_queue_Status status
-)
-{
- switch (status) {
- case CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL:
- return E_OK;
- case CORE_MESSAGE_QUEUE_STATUS_TOO_MANY:
- return E_TMOUT;
- case CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE:
- return E_PAR;
- case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT:
- return E_TMOUT;
- case CORE_MESSAGE_QUEUE_STATUS_TIMEOUT:
- return E_TMOUT;
- default:
- return E_ID;
- }
-}
-
/*
* _ITRON_Mailbox_Manager_initialization
*
@@ -76,308 +49,3 @@ void _ITRON_Mailbox_Manager_initialization(
*/
}
-
-
-/*
- * cre_mbx - Create Mailbox
- *
- * Creates a Mailbox according to the following spec:
- *
- * ------Parameters-------------------------
- * ID mbxid MailboxID
- * T_CMBX *pk_cmbx Packet to Create Mailbox
- * -----------------------------------------
- * -*pk_cmbx members*-
- * VP exinf ExtendedInformation
- * ATR mbxatr MailboxAttributes
- * (the use of the following information
- * is implementation dependent)
- * INT bufcnt BufferMessageCount
- * (CPU and/or implementation-dependent information
- * may also be included)
- *
- * ----Return Parameters--------------------
- * ER ercd ErrorCode
- * -----------------------------------------
- *
- *
- * ----C Language Interface-----------------
- * ER ercd = cre_mbx ( ID mbxid, T_CMBX *pk_cmbx ) ;
- * -----------------------------------------
- *
- */
-
-ER cre_mbx(
- ID mbxid,
- T_CMBX *pk_cmbx
-)
-{
- register ITRON_Mailbox_Control *the_mailbox;
- CORE_message_queue_Attributes the_mailbox_attributes;
-
- if ( !pk_cmbx )
- return E_PAR;
-
- if ((pk_cmbx->mbxatr & (TA_TPRI | TA_MPRI)) != 0 )
- return E_RSATR;
-
- _Thread_Disable_dispatch(); /* protects object pointer */
-
- the_mailbox = _ITRON_Mailbox_Allocate( mbxid );
- if ( !the_mailbox ) {
- _Thread_Enable_dispatch();
- return _ITRON_Mailbox_Clarify_allocation_id_error( mbxid );
- }
-
- the_mailbox->count = pk_cmbx->bufcnt;
- if (pk_cmbx->mbxatr & TA_MPRI)
- the_mailbox->do_message_priority = TRUE;
- else
- the_mailbox->do_message_priority = FALSE;
-
- if (pk_cmbx->mbxatr & TA_TPRI)
- the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
- else
- the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
-
- if ( !_CORE_message_queue_Initialize(
- &the_mailbox->message_queue,
- OBJECTS_ITRON_MAILBOXES,
- &the_mailbox_attributes,
- the_mailbox->count,
- sizeof(T_MSG *),
- NULL ) ) { /* Multiprocessing not supported */
- _ITRON_Mailbox_Free(the_mailbox);
- _ITRON_return_errorno( E_OBJ );
- }
-
- _ITRON_Objects_Open( &_ITRON_Mailbox_Information, &the_mailbox->Object );
-
- /*
- * If multiprocessing were supported, this is where we would announce
- * the existence of the semaphore to the rest of the system.
- */
-
-#if defined(RTEMS_MULTIPROCESSING)
-#endif
-
- _ITRON_return_errorno( E_OK );
-}
-
-/*
- * del_mbx - Delete Mailbox
- *
- *
- * ------Parameters--------------
- * ID mbxid The Mailbox's ID
- * ------------------------------
- *
- * -----Return Parameters-------
- * ER ercd Itron Error Code
- * -----------------------------
- *
- * -----C Language Interface----
- * ER ercd = del_mbx(ID mbxid);
- * -----------------------------
- *
- */
-
-ER del_mbx(
- ID mbxid
-)
-{
- register ITRON_Mailbox_Control *the_mailbox;
- Objects_Locations location;
-
- the_mailbox= _ITRON_Mailbox_Get( mbxid, &location );
- switch ( location ) {
- case OBJECTS_ERROR:
- case OBJECTS_REMOTE:
- return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
-
- case OBJECTS_LOCAL:
- _Objects_Close( &_ITRON_Mailbox_Information, &the_mailbox->Object );
-
- _CORE_message_queue_Close(
- &the_mailbox->message_queue,
- NULL, /* Multiprocessing not supported */
- CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED
- );
-
- _ITRON_Mailbox_Free(the_mailbox);
- break;
- }
-
- _ITRON_return_errorno( E_OK );
-}
-
-
-/*
- * snd_msg - Send Message to Mailbox
- */
-
-ER snd_msg(
- ID mbxid,
- T_MSG *pk_msg
-)
-{
- register ITRON_Mailbox_Control *the_mailbox;
- Objects_Locations location;
- CORE_message_queue_Status status = E_OK;
- unsigned32 message_priority;
- void *message_contents;
-
- if ( !pk_msg )
- return E_PAR;
-
- the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
- switch ( location ) {
- case OBJECTS_REMOTE:
- case OBJECTS_ERROR:
- return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
-
- case OBJECTS_LOCAL:
- if ( the_mailbox->do_message_priority )
- message_priority = pk_msg->msgpri;
- else
- message_priority = CORE_MESSAGE_QUEUE_SEND_REQUEST;
-
- message_contents = pk_msg;
- status = _CORE_message_queue_Submit(
- &the_mailbox->message_queue,
- &message_contents,
- sizeof(T_MSG *),
- the_mailbox->Object.id,
- NULL, /* multiprocessing not supported */
- message_priority
- );
- break;
- }
-
- _ITRON_return_errorno(
- _ITRON_Mailbox_Translate_core_message_queue_return_code(status) );
-}
-
-/*
- * rcv_msg - Receive Message from Mailbox
- */
-
-ER rcv_msg(
- T_MSG **ppk_msg,
- ID mbxid
-)
-{
- return trcv_msg( ppk_msg, mbxid, TMO_FEVR );
-}
-
-/*
- * prcv_msg - Poll and Receive Message from Mailbox
- */
-
-ER prcv_msg(
- T_MSG **ppk_msg,
- ID mbxid
-)
-{
- return trcv_msg( ppk_msg, mbxid, TMO_POL );
-}
-
-/*
- * trcv_msg - Receive Message from Mailbox with Timeout
- */
-
-ER trcv_msg(
- T_MSG **ppk_msg,
- ID mbxid,
- TMO tmout
-)
-{
- register ITRON_Mailbox_Control *the_mailbox;
- Watchdog_Interval interval;
- boolean wait;
- Objects_Locations location;
- unsigned32 size;
-
- if (!ppk_msg)
- return E_PAR;
-
- interval = 0;
- if ( tmout == TMO_POL ) {
- wait = FALSE;
- } else {
- wait = TRUE;
- if ( tmout != TMO_FEVR )
- interval = TOD_MILLISECONDS_TO_TICKS(tmout);
- }
-
- if ( wait && _ITRON_Is_in_non_task_state() )
- return E_CTX;
-
- the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
- switch ( location ) {
- case OBJECTS_REMOTE:
- case OBJECTS_ERROR:
- return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
-
- case OBJECTS_LOCAL:
-
- _CORE_message_queue_Seize(
- &the_mailbox->message_queue,
- the_mailbox->Object.id,
- ppk_msg,
- &size,
- wait,
- interval
- );
- break;
- }
-
- _ITRON_return_errorno(
- _ITRON_Mailbox_Translate_core_message_queue_return_code(
- _Thread_Executing->Wait.return_code ) );
-}
-
-/*
- * ref_mbx - Reference Mailbox Status
- */
-
-ER ref_mbx(
- T_RMBX *pk_rmbx,
- ID mbxid
-)
-{
- register ITRON_Mailbox_Control *the_mailbox;
- Objects_Locations location;
- Chain_Control *pending;
-
- if ( !pk_rmbx )
- return E_PAR;
-
- the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
- switch ( location ) {
- case OBJECTS_REMOTE:
- case OBJECTS_ERROR:
- return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
-
- case OBJECTS_LOCAL:
-
- pending = &the_mailbox->message_queue.Pending_messages;
- if ( _Chain_Is_empty( pending ) )
- pk_rmbx->pk_msg = NULL;
- else
- pk_rmbx->pk_msg = (T_MSG *) pending->first;
-
- /*
- * Fill in whether or not there is a waiting task
- */
-
- if ( !_Thread_queue_First( &the_mailbox->message_queue.Wait_queue ) )
- pk_rmbx->wtsk = FALSE;
- else
- pk_rmbx->wtsk = TRUE;
-
- break;
- }
- _ITRON_return_errorno( E_OK );
-}
-
diff --git a/c/src/exec/itron/src/mboxtranslatereturncode.c b/c/src/exec/itron/src/mboxtranslatereturncode.c
new file mode 100644
index 0000000000..7056afaa37
--- /dev/null
+++ b/c/src/exec/itron/src/mboxtranslatereturncode.c
@@ -0,0 +1,41 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * _ITRON_Mailbox_Translate_core_message_queue_return_code
+ *
+ * This routine translates a core message queue object status
+ * into the appropriate ITRON status code.
+ */
+
+ER _ITRON_Mailbox_Translate_core_message_queue_return_code(
+ CORE_message_queue_Status status
+)
+{
+ switch (status) {
+ case CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL:
+ return E_OK;
+ case CORE_MESSAGE_QUEUE_STATUS_TOO_MANY:
+ return E_TMOUT;
+ case CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE:
+ return E_PAR;
+ case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT:
+ return E_TMOUT;
+ case CORE_MESSAGE_QUEUE_STATUS_TIMEOUT:
+ return E_TMOUT;
+ default:
+ return E_ID;
+ }
+}
diff --git a/c/src/exec/itron/src/prcv_mbx.c b/c/src/exec/itron/src/prcv_mbx.c
new file mode 100644
index 0000000000..65b2b33707
--- /dev/null
+++ b/c/src/exec/itron/src/prcv_mbx.c
@@ -0,0 +1,26 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * prcv_msg - Poll and Receive Message from Mailbox
+ */
+
+ER prcv_msg(
+ T_MSG **ppk_msg,
+ ID mbxid
+)
+{
+ return trcv_msg( ppk_msg, mbxid, TMO_POL );
+}
diff --git a/c/src/exec/itron/src/rcv_mbx.c b/c/src/exec/itron/src/rcv_mbx.c
new file mode 100644
index 0000000000..411b4db6a5
--- /dev/null
+++ b/c/src/exec/itron/src/rcv_mbx.c
@@ -0,0 +1,26 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * rcv_msg - Receive Message from Mailbox
+ */
+
+ER rcv_msg(
+ T_MSG **ppk_msg,
+ ID mbxid
+)
+{
+ return trcv_msg( ppk_msg, mbxid, TMO_FEVR );
+}
diff --git a/c/src/exec/itron/src/ref_mbx.c b/c/src/exec/itron/src/ref_mbx.c
new file mode 100644
index 0000000000..ac148c89bf
--- /dev/null
+++ b/c/src/exec/itron/src/ref_mbx.c
@@ -0,0 +1,59 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * ref_mbx - Reference Mailbox Status
+ */
+
+ER ref_mbx(
+ T_RMBX *pk_rmbx,
+ ID mbxid
+)
+{
+ register ITRON_Mailbox_Control *the_mailbox;
+ Objects_Locations location;
+ Chain_Control *pending;
+
+ if ( !pk_rmbx )
+ return E_PAR;
+
+ the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
+ switch ( location ) {
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
+
+ case OBJECTS_LOCAL:
+
+ pending = &the_mailbox->message_queue.Pending_messages;
+ if ( _Chain_Is_empty( pending ) )
+ pk_rmbx->pk_msg = NULL;
+ else
+ pk_rmbx->pk_msg = (T_MSG *) pending->first;
+
+ /*
+ * Fill in whether or not there is a waiting task
+ */
+
+ if ( !_Thread_queue_First( &the_mailbox->message_queue.Wait_queue ) )
+ pk_rmbx->wtsk = FALSE;
+ else
+ pk_rmbx->wtsk = TRUE;
+
+ break;
+ }
+ _ITRON_return_errorno( E_OK );
+}
+
diff --git a/c/src/exec/itron/src/snd_mbx.c b/c/src/exec/itron/src/snd_mbx.c
new file mode 100644
index 0000000000..8d70c12315
--- /dev/null
+++ b/c/src/exec/itron/src/snd_mbx.c
@@ -0,0 +1,60 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * snd_msg - Send Message to Mailbox
+ */
+
+ER snd_msg(
+ ID mbxid,
+ T_MSG *pk_msg
+)
+{
+ register ITRON_Mailbox_Control *the_mailbox;
+ Objects_Locations location;
+ CORE_message_queue_Status status = E_OK;
+ unsigned32 message_priority;
+ void *message_contents;
+
+ if ( !pk_msg )
+ return E_PAR;
+
+ the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
+ switch ( location ) {
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
+
+ case OBJECTS_LOCAL:
+ if ( the_mailbox->do_message_priority )
+ message_priority = pk_msg->msgpri;
+ else
+ message_priority = CORE_MESSAGE_QUEUE_SEND_REQUEST;
+
+ message_contents = pk_msg;
+ status = _CORE_message_queue_Submit(
+ &the_mailbox->message_queue,
+ &message_contents,
+ sizeof(T_MSG *),
+ the_mailbox->Object.id,
+ NULL, /* multiprocessing not supported */
+ message_priority
+ );
+ break;
+ }
+
+ _ITRON_return_errorno(
+ _ITRON_Mailbox_Translate_core_message_queue_return_code(status) );
+}
diff --git a/c/src/exec/itron/src/trcv_mbx.c b/c/src/exec/itron/src/trcv_mbx.c
new file mode 100644
index 0000000000..39eecdf1de
--- /dev/null
+++ b/c/src/exec/itron/src/trcv_mbx.c
@@ -0,0 +1,69 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * trcv_msg - Receive Message from Mailbox with Timeout
+ */
+
+ER trcv_msg(
+ T_MSG **ppk_msg,
+ ID mbxid,
+ TMO tmout
+)
+{
+ register ITRON_Mailbox_Control *the_mailbox;
+ Watchdog_Interval interval;
+ boolean wait;
+ Objects_Locations location;
+ unsigned32 size;
+
+ if (!ppk_msg)
+ return E_PAR;
+
+ interval = 0;
+ if ( tmout == TMO_POL ) {
+ wait = FALSE;
+ } else {
+ wait = TRUE;
+ if ( tmout != TMO_FEVR )
+ interval = TOD_MILLISECONDS_TO_TICKS(tmout);
+ }
+
+ if ( wait && _ITRON_Is_in_non_task_state() )
+ return E_CTX;
+
+ the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
+ switch ( location ) {
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
+
+ case OBJECTS_LOCAL:
+
+ _CORE_message_queue_Seize(
+ &the_mailbox->message_queue,
+ the_mailbox->Object.id,
+ ppk_msg,
+ &size,
+ wait,
+ interval
+ );
+ break;
+ }
+
+ _ITRON_return_errorno(
+ _ITRON_Mailbox_Translate_core_message_queue_return_code(
+ _Thread_Executing->Wait.return_code ) );
+}
diff --git a/cpukit/itron/include/itronsys/mbox.h b/cpukit/itron/include/itronsys/mbox.h
index ef0581d02e..4196035b2c 100644
--- a/cpukit/itron/include/itronsys/mbox.h
+++ b/cpukit/itron/include/itronsys/mbox.h
@@ -21,7 +21,7 @@ typedef struct t_cmbx {
VP exinf; /* extended information */
ATR mbxatr; /* mailbox attributes */
/* Following is implementation-dependent function */
- INT bufcnt; /* ring buffer size */
+ INT bufcnt; /* maximum number of messages to let pend */
/* additional information may be included depending on the implementation */
} T_CMBX;
@@ -38,7 +38,11 @@ typedef struct t_msg {
/*
* A region (header) reserved by the OS may be included first
* depending on the implementation.
+ *
+ * NOTE: The first two fields are RTEMS specific.
*/
+
+ INT msgpri; /* priority of each message */
/* VB msgcont[]; XXX */
unsigned8 msgcont[1];
} T_MSG;
@@ -63,8 +67,8 @@ typedef struct t_rmbx {
*/
ER cre_mbx(
- ID mbxid,
- T_CMBX* pk_cmbx
+ ID mbxid,
+ T_CMBX *pk_cmbx
);
/*
@@ -80,7 +84,7 @@ ER del_mbx(
*/
ER snd_msg(
- ID mbxid,
+ ID mbxid,
T_MSG *pk_msg
);
@@ -90,7 +94,7 @@ ER snd_msg(
ER rcv_msg(
T_MSG **ppk_msg,
- ID mbxid
+ ID mbxid
);
/*
@@ -99,7 +103,7 @@ ER rcv_msg(
ER prcv_msg(
T_MSG **ppk_msg,
- ID mbxid
+ ID mbxid
);
/*
@@ -108,8 +112,8 @@ ER prcv_msg(
ER trcv_msg(
T_MSG **ppk_msg,
- ID mbxid,
- TMO tmout
+ ID mbxid,
+ TMO tmout
);
/*
@@ -118,7 +122,7 @@ ER trcv_msg(
ER ref_mbx(
T_RMBX *pk_rmbx,
- ID mbxid
+ ID mbxid
);
diff --git a/cpukit/itron/include/rtems/itron/mbox.h b/cpukit/itron/include/rtems/itron/mbox.h
index 5ce4180643..c0e0d53ea1 100644
--- a/cpukit/itron/include/rtems/itron/mbox.h
+++ b/cpukit/itron/include/rtems/itron/mbox.h
@@ -14,14 +14,17 @@ extern "C" {
#endif
#include <rtems/itron/object.h>
+#include <rtems/score/coremsg.h>
/*
* The following defines the control block used to manage each mailbox.
*/
typedef struct {
- ITRON_Objects_Control Object;
- unsigned32 XXX_more_stuff_goes_here;
+ ITRON_Objects_Control Object;
+ unsigned32 count;
+ boolean do_message_priority;
+ CORE_message_queue_Control message_queue;
} ITRON_Mailbox_Control;
/*
@@ -44,9 +47,18 @@ void _ITRON_Mailbox_Manager_initialization(
);
/*
- * XXX insert private stuff here
+ * _ITRON_Mailbox_Translate_core_message_queue_return_code
+ *
+ * DESCRIPTION:
+ *
+ * This routine translates a core message queue object status
+ * into the appropriate ITRON status code.
*/
+ER _ITRON_Mailbox_Translate_core_message_queue_return_code(
+ CORE_message_queue_Status status
+);
+
#include <rtems/itron/mbox.inl>
#ifdef __cplusplus
diff --git a/cpukit/itron/src/cre_mbx.c b/cpukit/itron/src/cre_mbx.c
new file mode 100644
index 0000000000..7a5cb30170
--- /dev/null
+++ b/cpukit/itron/src/cre_mbx.c
@@ -0,0 +1,100 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * cre_mbx - Create Mailbox
+ *
+ * Creates a Mailbox according to the following spec:
+ *
+ * ------Parameters-------------------------
+ * ID mbxid MailboxID
+ * T_CMBX *pk_cmbx Packet to Create Mailbox
+ * -----------------------------------------
+ * -*pk_cmbx members*-
+ * VP exinf ExtendedInformation
+ * ATR mbxatr MailboxAttributes
+ * (the use of the following information
+ * is implementation dependent)
+ * INT bufcnt BufferMessageCount
+ * (CPU and/or implementation-dependent information
+ * may also be included)
+ *
+ * ----Return Parameters--------------------
+ * ER ercd ErrorCode
+ * -----------------------------------------
+ *
+ *
+ * ----C Language Interface-----------------
+ * ER ercd = cre_mbx ( ID mbxid, T_CMBX *pk_cmbx ) ;
+ * -----------------------------------------
+ *
+ */
+
+ER cre_mbx(
+ ID mbxid,
+ T_CMBX *pk_cmbx
+)
+{
+ register ITRON_Mailbox_Control *the_mailbox;
+ CORE_message_queue_Attributes the_mailbox_attributes;
+
+ if ( !pk_cmbx )
+ return E_PAR;
+
+ if ((pk_cmbx->mbxatr & (TA_TPRI | TA_MPRI)) != 0 )
+ return E_RSATR;
+
+ _Thread_Disable_dispatch(); /* protects object pointer */
+
+ the_mailbox = _ITRON_Mailbox_Allocate( mbxid );
+ if ( !the_mailbox ) {
+ _Thread_Enable_dispatch();
+ return _ITRON_Mailbox_Clarify_allocation_id_error( mbxid );
+ }
+
+ the_mailbox->count = pk_cmbx->bufcnt;
+ if (pk_cmbx->mbxatr & TA_MPRI)
+ the_mailbox->do_message_priority = TRUE;
+ else
+ the_mailbox->do_message_priority = FALSE;
+
+ if (pk_cmbx->mbxatr & TA_TPRI)
+ the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
+ else
+ the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
+
+ if ( !_CORE_message_queue_Initialize(
+ &the_mailbox->message_queue,
+ OBJECTS_ITRON_MAILBOXES,
+ &the_mailbox_attributes,
+ the_mailbox->count,
+ sizeof(T_MSG *),
+ NULL ) ) { /* Multiprocessing not supported */
+ _ITRON_Mailbox_Free(the_mailbox);
+ _ITRON_return_errorno( E_OBJ );
+ }
+
+ _ITRON_Objects_Open( &_ITRON_Mailbox_Information, &the_mailbox->Object );
+
+ /*
+ * If multiprocessing were supported, this is where we would announce
+ * the existence of the semaphore to the rest of the system.
+ */
+
+#if defined(RTEMS_MULTIPROCESSING)
+#endif
+
+ _ITRON_return_errorno( E_OK );
+}
diff --git a/cpukit/itron/src/del_mbx.c b/cpukit/itron/src/del_mbx.c
new file mode 100644
index 0000000000..9006e5f3b4
--- /dev/null
+++ b/cpukit/itron/src/del_mbx.c
@@ -0,0 +1,61 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * del_mbx - Delete Mailbox
+ *
+ *
+ * ------Parameters--------------
+ * ID mbxid The Mailbox's ID
+ * ------------------------------
+ *
+ * -----Return Parameters-------
+ * ER ercd Itron Error Code
+ * -----------------------------
+ *
+ * -----C Language Interface----
+ * ER ercd = del_mbx(ID mbxid);
+ * -----------------------------
+ *
+ */
+
+ER del_mbx(
+ ID mbxid
+)
+{
+ register ITRON_Mailbox_Control *the_mailbox;
+ Objects_Locations location;
+
+ the_mailbox= _ITRON_Mailbox_Get( mbxid, &location );
+ switch ( location ) {
+ case OBJECTS_ERROR:
+ case OBJECTS_REMOTE:
+ return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
+
+ case OBJECTS_LOCAL:
+ _Objects_Close( &_ITRON_Mailbox_Information, &the_mailbox->Object );
+
+ _CORE_message_queue_Close(
+ &the_mailbox->message_queue,
+ NULL, /* Multiprocessing not supported */
+ CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED
+ );
+
+ _ITRON_Mailbox_Free(the_mailbox);
+ break;
+ }
+
+ _ITRON_return_errorno( E_OK );
+}
diff --git a/cpukit/itron/src/mbox.c b/cpukit/itron/src/mbox.c
index 9a2f925429..ff1e0249ed 100644
--- a/cpukit/itron/src/mbox.c
+++ b/cpukit/itron/src/mbox.c
@@ -13,33 +13,6 @@
#include <rtems/itron/mbox.h>
#include <rtems/itron/task.h>
-/*
- * _ITRON_Mailbox_Translate_core_message_queue_return_code
- *
- * This routine translates a core message queue object status
- * into the appropriate ITRON status code.
- */
-
-ER _ITRON_Mailbox_Translate_core_message_queue_return_code(
- CORE_message_queue_Status status
-)
-{
- switch (status) {
- case CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL:
- return E_OK;
- case CORE_MESSAGE_QUEUE_STATUS_TOO_MANY:
- return E_TMOUT;
- case CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE:
- return E_PAR;
- case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT:
- return E_TMOUT;
- case CORE_MESSAGE_QUEUE_STATUS_TIMEOUT:
- return E_TMOUT;
- default:
- return E_ID;
- }
-}
-
/*
* _ITRON_Mailbox_Manager_initialization
*
@@ -76,308 +49,3 @@ void _ITRON_Mailbox_Manager_initialization(
*/
}
-
-
-/*
- * cre_mbx - Create Mailbox
- *
- * Creates a Mailbox according to the following spec:
- *
- * ------Parameters-------------------------
- * ID mbxid MailboxID
- * T_CMBX *pk_cmbx Packet to Create Mailbox
- * -----------------------------------------
- * -*pk_cmbx members*-
- * VP exinf ExtendedInformation
- * ATR mbxatr MailboxAttributes
- * (the use of the following information
- * is implementation dependent)
- * INT bufcnt BufferMessageCount
- * (CPU and/or implementation-dependent information
- * may also be included)
- *
- * ----Return Parameters--------------------
- * ER ercd ErrorCode
- * -----------------------------------------
- *
- *
- * ----C Language Interface-----------------
- * ER ercd = cre_mbx ( ID mbxid, T_CMBX *pk_cmbx ) ;
- * -----------------------------------------
- *
- */
-
-ER cre_mbx(
- ID mbxid,
- T_CMBX *pk_cmbx
-)
-{
- register ITRON_Mailbox_Control *the_mailbox;
- CORE_message_queue_Attributes the_mailbox_attributes;
-
- if ( !pk_cmbx )
- return E_PAR;
-
- if ((pk_cmbx->mbxatr & (TA_TPRI | TA_MPRI)) != 0 )
- return E_RSATR;
-
- _Thread_Disable_dispatch(); /* protects object pointer */
-
- the_mailbox = _ITRON_Mailbox_Allocate( mbxid );
- if ( !the_mailbox ) {
- _Thread_Enable_dispatch();
- return _ITRON_Mailbox_Clarify_allocation_id_error( mbxid );
- }
-
- the_mailbox->count = pk_cmbx->bufcnt;
- if (pk_cmbx->mbxatr & TA_MPRI)
- the_mailbox->do_message_priority = TRUE;
- else
- the_mailbox->do_message_priority = FALSE;
-
- if (pk_cmbx->mbxatr & TA_TPRI)
- the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
- else
- the_mailbox_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
-
- if ( !_CORE_message_queue_Initialize(
- &the_mailbox->message_queue,
- OBJECTS_ITRON_MAILBOXES,
- &the_mailbox_attributes,
- the_mailbox->count,
- sizeof(T_MSG *),
- NULL ) ) { /* Multiprocessing not supported */
- _ITRON_Mailbox_Free(the_mailbox);
- _ITRON_return_errorno( E_OBJ );
- }
-
- _ITRON_Objects_Open( &_ITRON_Mailbox_Information, &the_mailbox->Object );
-
- /*
- * If multiprocessing were supported, this is where we would announce
- * the existence of the semaphore to the rest of the system.
- */
-
-#if defined(RTEMS_MULTIPROCESSING)
-#endif
-
- _ITRON_return_errorno( E_OK );
-}
-
-/*
- * del_mbx - Delete Mailbox
- *
- *
- * ------Parameters--------------
- * ID mbxid The Mailbox's ID
- * ------------------------------
- *
- * -----Return Parameters-------
- * ER ercd Itron Error Code
- * -----------------------------
- *
- * -----C Language Interface----
- * ER ercd = del_mbx(ID mbxid);
- * -----------------------------
- *
- */
-
-ER del_mbx(
- ID mbxid
-)
-{
- register ITRON_Mailbox_Control *the_mailbox;
- Objects_Locations location;
-
- the_mailbox= _ITRON_Mailbox_Get( mbxid, &location );
- switch ( location ) {
- case OBJECTS_ERROR:
- case OBJECTS_REMOTE:
- return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
-
- case OBJECTS_LOCAL:
- _Objects_Close( &_ITRON_Mailbox_Information, &the_mailbox->Object );
-
- _CORE_message_queue_Close(
- &the_mailbox->message_queue,
- NULL, /* Multiprocessing not supported */
- CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED
- );
-
- _ITRON_Mailbox_Free(the_mailbox);
- break;
- }
-
- _ITRON_return_errorno( E_OK );
-}
-
-
-/*
- * snd_msg - Send Message to Mailbox
- */
-
-ER snd_msg(
- ID mbxid,
- T_MSG *pk_msg
-)
-{
- register ITRON_Mailbox_Control *the_mailbox;
- Objects_Locations location;
- CORE_message_queue_Status status = E_OK;
- unsigned32 message_priority;
- void *message_contents;
-
- if ( !pk_msg )
- return E_PAR;
-
- the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
- switch ( location ) {
- case OBJECTS_REMOTE:
- case OBJECTS_ERROR:
- return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
-
- case OBJECTS_LOCAL:
- if ( the_mailbox->do_message_priority )
- message_priority = pk_msg->msgpri;
- else
- message_priority = CORE_MESSAGE_QUEUE_SEND_REQUEST;
-
- message_contents = pk_msg;
- status = _CORE_message_queue_Submit(
- &the_mailbox->message_queue,
- &message_contents,
- sizeof(T_MSG *),
- the_mailbox->Object.id,
- NULL, /* multiprocessing not supported */
- message_priority
- );
- break;
- }
-
- _ITRON_return_errorno(
- _ITRON_Mailbox_Translate_core_message_queue_return_code(status) );
-}
-
-/*
- * rcv_msg - Receive Message from Mailbox
- */
-
-ER rcv_msg(
- T_MSG **ppk_msg,
- ID mbxid
-)
-{
- return trcv_msg( ppk_msg, mbxid, TMO_FEVR );
-}
-
-/*
- * prcv_msg - Poll and Receive Message from Mailbox
- */
-
-ER prcv_msg(
- T_MSG **ppk_msg,
- ID mbxid
-)
-{
- return trcv_msg( ppk_msg, mbxid, TMO_POL );
-}
-
-/*
- * trcv_msg - Receive Message from Mailbox with Timeout
- */
-
-ER trcv_msg(
- T_MSG **ppk_msg,
- ID mbxid,
- TMO tmout
-)
-{
- register ITRON_Mailbox_Control *the_mailbox;
- Watchdog_Interval interval;
- boolean wait;
- Objects_Locations location;
- unsigned32 size;
-
- if (!ppk_msg)
- return E_PAR;
-
- interval = 0;
- if ( tmout == TMO_POL ) {
- wait = FALSE;
- } else {
- wait = TRUE;
- if ( tmout != TMO_FEVR )
- interval = TOD_MILLISECONDS_TO_TICKS(tmout);
- }
-
- if ( wait && _ITRON_Is_in_non_task_state() )
- return E_CTX;
-
- the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
- switch ( location ) {
- case OBJECTS_REMOTE:
- case OBJECTS_ERROR:
- return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
-
- case OBJECTS_LOCAL:
-
- _CORE_message_queue_Seize(
- &the_mailbox->message_queue,
- the_mailbox->Object.id,
- ppk_msg,
- &size,
- wait,
- interval
- );
- break;
- }
-
- _ITRON_return_errorno(
- _ITRON_Mailbox_Translate_core_message_queue_return_code(
- _Thread_Executing->Wait.return_code ) );
-}
-
-/*
- * ref_mbx - Reference Mailbox Status
- */
-
-ER ref_mbx(
- T_RMBX *pk_rmbx,
- ID mbxid
-)
-{
- register ITRON_Mailbox_Control *the_mailbox;
- Objects_Locations location;
- Chain_Control *pending;
-
- if ( !pk_rmbx )
- return E_PAR;
-
- the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
- switch ( location ) {
- case OBJECTS_REMOTE:
- case OBJECTS_ERROR:
- return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
-
- case OBJECTS_LOCAL:
-
- pending = &the_mailbox->message_queue.Pending_messages;
- if ( _Chain_Is_empty( pending ) )
- pk_rmbx->pk_msg = NULL;
- else
- pk_rmbx->pk_msg = (T_MSG *) pending->first;
-
- /*
- * Fill in whether or not there is a waiting task
- */
-
- if ( !_Thread_queue_First( &the_mailbox->message_queue.Wait_queue ) )
- pk_rmbx->wtsk = FALSE;
- else
- pk_rmbx->wtsk = TRUE;
-
- break;
- }
- _ITRON_return_errorno( E_OK );
-}
-
diff --git a/cpukit/itron/src/mboxtranslatereturncode.c b/cpukit/itron/src/mboxtranslatereturncode.c
new file mode 100644
index 0000000000..7056afaa37
--- /dev/null
+++ b/cpukit/itron/src/mboxtranslatereturncode.c
@@ -0,0 +1,41 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * _ITRON_Mailbox_Translate_core_message_queue_return_code
+ *
+ * This routine translates a core message queue object status
+ * into the appropriate ITRON status code.
+ */
+
+ER _ITRON_Mailbox_Translate_core_message_queue_return_code(
+ CORE_message_queue_Status status
+)
+{
+ switch (status) {
+ case CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL:
+ return E_OK;
+ case CORE_MESSAGE_QUEUE_STATUS_TOO_MANY:
+ return E_TMOUT;
+ case CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE:
+ return E_PAR;
+ case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT:
+ return E_TMOUT;
+ case CORE_MESSAGE_QUEUE_STATUS_TIMEOUT:
+ return E_TMOUT;
+ default:
+ return E_ID;
+ }
+}
diff --git a/cpukit/itron/src/prcv_mbx.c b/cpukit/itron/src/prcv_mbx.c
new file mode 100644
index 0000000000..65b2b33707
--- /dev/null
+++ b/cpukit/itron/src/prcv_mbx.c
@@ -0,0 +1,26 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * prcv_msg - Poll and Receive Message from Mailbox
+ */
+
+ER prcv_msg(
+ T_MSG **ppk_msg,
+ ID mbxid
+)
+{
+ return trcv_msg( ppk_msg, mbxid, TMO_POL );
+}
diff --git a/cpukit/itron/src/rcv_mbx.c b/cpukit/itron/src/rcv_mbx.c
new file mode 100644
index 0000000000..411b4db6a5
--- /dev/null
+++ b/cpukit/itron/src/rcv_mbx.c
@@ -0,0 +1,26 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * rcv_msg - Receive Message from Mailbox
+ */
+
+ER rcv_msg(
+ T_MSG **ppk_msg,
+ ID mbxid
+)
+{
+ return trcv_msg( ppk_msg, mbxid, TMO_FEVR );
+}
diff --git a/cpukit/itron/src/ref_mbx.c b/cpukit/itron/src/ref_mbx.c
new file mode 100644
index 0000000000..ac148c89bf
--- /dev/null
+++ b/cpukit/itron/src/ref_mbx.c
@@ -0,0 +1,59 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * ref_mbx - Reference Mailbox Status
+ */
+
+ER ref_mbx(
+ T_RMBX *pk_rmbx,
+ ID mbxid
+)
+{
+ register ITRON_Mailbox_Control *the_mailbox;
+ Objects_Locations location;
+ Chain_Control *pending;
+
+ if ( !pk_rmbx )
+ return E_PAR;
+
+ the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
+ switch ( location ) {
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
+
+ case OBJECTS_LOCAL:
+
+ pending = &the_mailbox->message_queue.Pending_messages;
+ if ( _Chain_Is_empty( pending ) )
+ pk_rmbx->pk_msg = NULL;
+ else
+ pk_rmbx->pk_msg = (T_MSG *) pending->first;
+
+ /*
+ * Fill in whether or not there is a waiting task
+ */
+
+ if ( !_Thread_queue_First( &the_mailbox->message_queue.Wait_queue ) )
+ pk_rmbx->wtsk = FALSE;
+ else
+ pk_rmbx->wtsk = TRUE;
+
+ break;
+ }
+ _ITRON_return_errorno( E_OK );
+}
+
diff --git a/cpukit/itron/src/snd_mbx.c b/cpukit/itron/src/snd_mbx.c
new file mode 100644
index 0000000000..8d70c12315
--- /dev/null
+++ b/cpukit/itron/src/snd_mbx.c
@@ -0,0 +1,60 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * snd_msg - Send Message to Mailbox
+ */
+
+ER snd_msg(
+ ID mbxid,
+ T_MSG *pk_msg
+)
+{
+ register ITRON_Mailbox_Control *the_mailbox;
+ Objects_Locations location;
+ CORE_message_queue_Status status = E_OK;
+ unsigned32 message_priority;
+ void *message_contents;
+
+ if ( !pk_msg )
+ return E_PAR;
+
+ the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
+ switch ( location ) {
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
+
+ case OBJECTS_LOCAL:
+ if ( the_mailbox->do_message_priority )
+ message_priority = pk_msg->msgpri;
+ else
+ message_priority = CORE_MESSAGE_QUEUE_SEND_REQUEST;
+
+ message_contents = pk_msg;
+ status = _CORE_message_queue_Submit(
+ &the_mailbox->message_queue,
+ &message_contents,
+ sizeof(T_MSG *),
+ the_mailbox->Object.id,
+ NULL, /* multiprocessing not supported */
+ message_priority
+ );
+ break;
+ }
+
+ _ITRON_return_errorno(
+ _ITRON_Mailbox_Translate_core_message_queue_return_code(status) );
+}
diff --git a/cpukit/itron/src/trcv_mbx.c b/cpukit/itron/src/trcv_mbx.c
new file mode 100644
index 0000000000..39eecdf1de
--- /dev/null
+++ b/cpukit/itron/src/trcv_mbx.c
@@ -0,0 +1,69 @@
+/*
+ * ITRON 3.0 Mailbox Manager
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <itron.h>
+
+#include <rtems/itron/mbox.h>
+#include <rtems/itron/task.h>
+
+/*
+ * trcv_msg - Receive Message from Mailbox with Timeout
+ */
+
+ER trcv_msg(
+ T_MSG **ppk_msg,
+ ID mbxid,
+ TMO tmout
+)
+{
+ register ITRON_Mailbox_Control *the_mailbox;
+ Watchdog_Interval interval;
+ boolean wait;
+ Objects_Locations location;
+ unsigned32 size;
+
+ if (!ppk_msg)
+ return E_PAR;
+
+ interval = 0;
+ if ( tmout == TMO_POL ) {
+ wait = FALSE;
+ } else {
+ wait = TRUE;
+ if ( tmout != TMO_FEVR )
+ interval = TOD_MILLISECONDS_TO_TICKS(tmout);
+ }
+
+ if ( wait && _ITRON_Is_in_non_task_state() )
+ return E_CTX;
+
+ the_mailbox = _ITRON_Mailbox_Get( mbxid, &location );
+ switch ( location ) {
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return _ITRON_Mailbox_Clarify_get_id_error( mbxid );
+
+ case OBJECTS_LOCAL:
+
+ _CORE_message_queue_Seize(
+ &the_mailbox->message_queue,
+ the_mailbox->Object.id,
+ ppk_msg,
+ &size,
+ wait,
+ interval
+ );
+ break;
+ }
+
+ _ITRON_return_errorno(
+ _ITRON_Mailbox_Translate_core_message_queue_return_code(
+ _Thread_Executing->Wait.return_code ) );
+}