From 1e1b3e00d1d7dcf8ae674db66250fbccab293f4f Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 17 May 1999 22:52:59 +0000 Subject: Split Message Manager into one routine per file. --- cpukit/rtems/src/msgqallocate.c | 57 ++++++++++ cpukit/rtems/src/msgqbroadcast.c | 104 ++++++++++++++++++ cpukit/rtems/src/msgqcreate.c | 168 +++++++++++++++++++++++++++++ cpukit/rtems/src/msgqdelete.c | 105 ++++++++++++++++++ cpukit/rtems/src/msgqflush.c | 87 +++++++++++++++ cpukit/rtems/src/msgqgetnumberpending.c | 84 +++++++++++++++ cpukit/rtems/src/msgqident.c | 68 ++++++++++++ cpukit/rtems/src/msgqreceive.c | 104 ++++++++++++++++++ cpukit/rtems/src/msgqsend.c | 58 ++++++++++ cpukit/rtems/src/msgqsubmit.c | 138 ++++++++++++++++++++++++ cpukit/rtems/src/msgqtranslatereturncode.c | 74 +++++++++++++ cpukit/rtems/src/msgqurgent.c | 58 ++++++++++ 12 files changed, 1105 insertions(+) create mode 100644 cpukit/rtems/src/msgqallocate.c create mode 100644 cpukit/rtems/src/msgqbroadcast.c create mode 100644 cpukit/rtems/src/msgqcreate.c create mode 100644 cpukit/rtems/src/msgqdelete.c create mode 100644 cpukit/rtems/src/msgqflush.c create mode 100644 cpukit/rtems/src/msgqgetnumberpending.c create mode 100644 cpukit/rtems/src/msgqident.c create mode 100644 cpukit/rtems/src/msgqreceive.c create mode 100644 cpukit/rtems/src/msgqsend.c create mode 100644 cpukit/rtems/src/msgqsubmit.c create mode 100644 cpukit/rtems/src/msgqtranslatereturncode.c create mode 100644 cpukit/rtems/src/msgqurgent.c (limited to 'cpukit') diff --git a/cpukit/rtems/src/msgqallocate.c b/cpukit/rtems/src/msgqallocate.c new file mode 100644 index 0000000000..6a2cf65523 --- /dev/null +++ b/cpukit/rtems/src/msgqallocate.c @@ -0,0 +1,57 @@ +/* + * Message Queue Manager + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include + +/*PAGE + * + * _Message_queue_Allocate + * + * Allocate a message queue and the space for its messages + * + * Input parameters: + * the_message_queue - the message queue to allocate message buffers + * count - maximum message and reserved buffer count + * max_message_size - maximum size of each message + * + * Output parameters: + * the_message_queue - set if successful, NULL otherwise + */ + +Message_queue_Control *_Message_queue_Allocate ( + unsigned32 count, + unsigned32 max_message_size +) +{ + return + (Message_queue_Control *)_Objects_Allocate(&_Message_queue_Information); + +} diff --git a/cpukit/rtems/src/msgqbroadcast.c b/cpukit/rtems/src/msgqbroadcast.c new file mode 100644 index 0000000000..470be7d84e --- /dev/null +++ b/cpukit/rtems/src/msgqbroadcast.c @@ -0,0 +1,104 @@ +/* + * Message Queue Manager + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include + +/*PAGE + * + * rtems_message_queue_broadcast + * + * This directive sends a message for every thread waiting on the queue + * designated by id. + * + * Input parameters: + * id - pointer to message queue + * buffer - pointer to message buffer + * size - size of message to broadcast + * count - pointer to area to store number of threads made ready + * + * Output parameters: + * count - number of threads made ready + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + */ + +rtems_status_code rtems_message_queue_broadcast( + Objects_Id id, + void *buffer, + unsigned32 size, + unsigned32 *count +) +{ + register Message_queue_Control *the_message_queue; + Objects_Locations location; + CORE_message_queue_Status core_status; + + the_message_queue = _Message_queue_Get( id, &location ); + switch ( location ) { + case OBJECTS_REMOTE: +#if defined(RTEMS_MULTIPROCESSING) + _Thread_Executing->Wait.return_argument = count; + + return + _Message_queue_MP_Send_request_packet( + MESSAGE_QUEUE_MP_BROADCAST_REQUEST, + id, + buffer, + &size, + 0, /* option_set not used */ + MPCI_DEFAULT_TIMEOUT + ); +#endif + + case OBJECTS_ERROR: + return RTEMS_INVALID_ID; + + case OBJECTS_LOCAL: + core_status = _CORE_message_queue_Broadcast( + &the_message_queue->message_queue, + buffer, + size, + id, +#if defined(RTEMS_MULTIPROCESSING) + _Message_queue_Core_message_queue_mp_support, +#else + NULL, +#endif + count + ); + + _Thread_Enable_dispatch(); + return + _Message_queue_Translate_core_message_queue_return_code( core_status ); + + } + return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ +} diff --git a/cpukit/rtems/src/msgqcreate.c b/cpukit/rtems/src/msgqcreate.c new file mode 100644 index 0000000000..11d1e7d297 --- /dev/null +++ b/cpukit/rtems/src/msgqcreate.c @@ -0,0 +1,168 @@ +/* + * Message Queue Manager + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include + +/*PAGE + * + * rtems_message_queue_create + * + * This directive creates a message queue by allocating and initializing + * a message queue data structure. + * + * Input parameters: + * name - user defined queue name + * count - maximum message and reserved buffer count + * max_message_size - maximum size of each message + * attribute_set - process method + * id - pointer to queue + * + * Output parameters: + * id - queue id + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + */ + +rtems_status_code rtems_message_queue_create( + rtems_name name, + unsigned32 count, + unsigned32 max_message_size, + rtems_attribute attribute_set, + Objects_Id *id +) +{ + register Message_queue_Control *the_message_queue; + CORE_message_queue_Attributes the_message_queue_attributes; + void *handler; +#if defined(RTEMS_MULTIPROCESSING) + boolean is_global; +#endif + + if ( !rtems_is_name_valid( name ) ) + return RTEMS_INVALID_NAME; + +#if defined(RTEMS_MULTIPROCESSING) + if ( (is_global = _Attributes_Is_global( attribute_set ) ) && + !_System_state_Is_multiprocessing ) + return RTEMS_MP_NOT_CONFIGURED; +#endif + + if (count == 0) + return RTEMS_INVALID_NUMBER; + + if (max_message_size == 0) + return RTEMS_INVALID_SIZE; + +#if defined(RTEMS_MULTIPROCESSING) +#if 1 + /* + * I am not 100% sure this should be an error. + * It seems reasonable to create a que with a large max size, + * and then just send smaller msgs from remote (or all) nodes. + */ + + if ( is_global && (_MPCI_table->maximum_packet_size < max_message_size) ) + return RTEMS_INVALID_SIZE; +#endif +#endif + + _Thread_Disable_dispatch(); /* protects object pointer */ + + the_message_queue = _Message_queue_Allocate( count, max_message_size ); + + if ( !the_message_queue ) { + _Thread_Enable_dispatch(); + return RTEMS_TOO_MANY; + } + +#if defined(RTEMS_MULTIPROCESSING) + if ( is_global && + !( _Objects_MP_Allocate_and_open( &_Message_queue_Information, + name, the_message_queue->Object.id, FALSE ) ) ) { + _Message_queue_Free( the_message_queue ); + _Thread_Enable_dispatch(); + return RTEMS_TOO_MANY; + } +#endif + + the_message_queue->attribute_set = attribute_set; + + if (_Attributes_Is_priority( attribute_set ) ) + the_message_queue_attributes.discipline = + CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY; + else + the_message_queue_attributes.discipline = + CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO; + + handler = NULL; +#if defined(RTEMS_MULTIPROCESSING) + handler = _Message_queue_MP_Send_extract_proxy; +#endif + + if ( ! _CORE_message_queue_Initialize( + &the_message_queue->message_queue, + OBJECTS_RTEMS_MESSAGE_QUEUES, + &the_message_queue_attributes, + count, + max_message_size, + handler ) ) { +#if defined(RTEMS_MULTIPROCESSING) + if ( is_global ) + _Objects_MP_Close( + &_Message_queue_Information, the_message_queue->Object.id); +#endif + + _Message_queue_Free( the_message_queue ); + _Thread_Enable_dispatch(); + return RTEMS_TOO_MANY; + } + + _Objects_Open( + &_Message_queue_Information, + &the_message_queue->Object, + &name + ); + + *id = the_message_queue->Object.id; + +#if defined(RTEMS_MULTIPROCESSING) + if ( is_global ) + _Message_queue_MP_Send_process_packet( + MESSAGE_QUEUE_MP_ANNOUNCE_CREATE, + the_message_queue->Object.id, + name, + 0 + ); +#endif + + _Thread_Enable_dispatch(); + return RTEMS_SUCCESSFUL; +} diff --git a/cpukit/rtems/src/msgqdelete.c b/cpukit/rtems/src/msgqdelete.c new file mode 100644 index 0000000000..059cdeb6ea --- /dev/null +++ b/cpukit/rtems/src/msgqdelete.c @@ -0,0 +1,105 @@ +/* + * Message Queue Manager + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include + +/*PAGE + * + * rtems_message_queue_delete + * + * This directive allows a thread to delete the message queue specified + * by the given queue identifier. + * + * Input parameters: + * id - queue id + * + * Output parameters: + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + */ + +rtems_status_code rtems_message_queue_delete( + Objects_Id id +) +{ + register Message_queue_Control *the_message_queue; + Objects_Locations location; + + the_message_queue = _Message_queue_Get( id, &location ); + switch ( location ) { + + case OBJECTS_REMOTE: +#if defined(RTEMS_MULTIPROCESSING) + _Thread_Dispatch(); + return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; +#endif + + case OBJECTS_ERROR: + return RTEMS_INVALID_ID; + + case OBJECTS_LOCAL: + _Objects_Close( &_Message_queue_Information, + &the_message_queue->Object ); + + _CORE_message_queue_Close( + &the_message_queue->message_queue, +#if defined(RTEMS_MULTIPROCESSING) + _Message_queue_MP_Send_object_was_deleted, +#else + NULL, +#endif + CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED + ); + + _Message_queue_Free( the_message_queue ); + +#if defined(RTEMS_MULTIPROCESSING) + if ( _Attributes_Is_global( the_message_queue->attribute_set ) ) { + _Objects_MP_Close( + &_Message_queue_Information, + the_message_queue->Object.id + ); + + _Message_queue_MP_Send_process_packet( + MESSAGE_QUEUE_MP_ANNOUNCE_DELETE, + the_message_queue->Object.id, + 0, /* Not used */ + 0 + ); + } +#endif + + _Thread_Enable_dispatch(); + return RTEMS_SUCCESSFUL; + } + + return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ +} diff --git a/cpukit/rtems/src/msgqflush.c b/cpukit/rtems/src/msgqflush.c new file mode 100644 index 0000000000..969180e412 --- /dev/null +++ b/cpukit/rtems/src/msgqflush.c @@ -0,0 +1,87 @@ +/* + * Message Queue Manager + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include + +/*PAGE + * + * rtems_message_queue_flush + * + * This directive removes all pending messages from a queue and returns + * the number of messages removed. If no messages were present then + * a count of zero is returned. + * + * Input parameters: + * id - queue id + * count - return area for count + * + * Output parameters: + * count - number of messages removed ( 0 = empty queue ) + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + */ + +rtems_status_code rtems_message_queue_flush( + Objects_Id id, + unsigned32 *count +) +{ + register Message_queue_Control *the_message_queue; + Objects_Locations location; + + the_message_queue = _Message_queue_Get( id, &location ); + switch ( location ) { + case OBJECTS_REMOTE: +#if defined(RTEMS_MULTIPROCESSING) + _Thread_Executing->Wait.return_argument = count; + + return + _Message_queue_MP_Send_request_packet( + MESSAGE_QUEUE_MP_FLUSH_REQUEST, + id, + 0, /* buffer not used */ + 0, /* size */ + 0, /* option_set not used */ + MPCI_DEFAULT_TIMEOUT + ); +#endif + + case OBJECTS_ERROR: + return RTEMS_INVALID_ID; + + case OBJECTS_LOCAL: + *count = _CORE_message_queue_Flush( &the_message_queue->message_queue ); + _Thread_Enable_dispatch(); + return RTEMS_SUCCESSFUL; + } + + return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ +} diff --git a/cpukit/rtems/src/msgqgetnumberpending.c b/cpukit/rtems/src/msgqgetnumberpending.c new file mode 100644 index 0000000000..37a2bdf07d --- /dev/null +++ b/cpukit/rtems/src/msgqgetnumberpending.c @@ -0,0 +1,84 @@ +/* + * Message Queue Manager + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include + +/*PAGE + * + * rtems_message_queue_get_number_pending + * + * This directive returns the number of messages pending. + * + * Input parameters: + * id - queue id + * count - return area for count + * + * Output parameters: + * count - number of messages removed ( 0 = empty queue ) + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + */ + +rtems_status_code rtems_message_queue_get_number_pending( + Objects_Id id, + unsigned32 *count +) +{ + register Message_queue_Control *the_message_queue; + Objects_Locations location; + + the_message_queue = _Message_queue_Get( id, &location ); + switch ( location ) { + case OBJECTS_REMOTE: +#if defined(RTEMS_MULTIPROCESSING) + _Thread_Executing->Wait.return_argument = count; + + return _Message_queue_MP_Send_request_packet( + MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST, + id, + 0, /* buffer not used */ + 0, /* size */ + 0, /* option_set not used */ + MPCI_DEFAULT_TIMEOUT + ); +#endif + + case OBJECTS_ERROR: + return RTEMS_INVALID_ID; + + case OBJECTS_LOCAL: + *count = the_message_queue->message_queue.number_of_pending_messages; + _Thread_Enable_dispatch(); + return RTEMS_SUCCESSFUL; + } + + return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ +} diff --git a/cpukit/rtems/src/msgqident.c b/cpukit/rtems/src/msgqident.c new file mode 100644 index 0000000000..25d386bdf6 --- /dev/null +++ b/cpukit/rtems/src/msgqident.c @@ -0,0 +1,68 @@ +/* + * Message Queue Manager + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include + +/*PAGE + * + * rtems_message_queue_ident + * + * This directive returns the system ID associated with + * the message queue name. + * + * Input parameters: + * name - user defined message queue name + * node - node(s) to be searched + * id - pointer to message queue id + * + * Output parameters: + * *id - message queue id + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + */ + +rtems_status_code rtems_message_queue_ident( + rtems_name name, + unsigned32 node, + Objects_Id *id +) +{ + Objects_Name_to_id_errors status; + + status = _Objects_Name_to_id( + &_Message_queue_Information, + &name, + node, + id + ); + + return _Status_Object_name_errors_to_status[ status ]; +} diff --git a/cpukit/rtems/src/msgqreceive.c b/cpukit/rtems/src/msgqreceive.c new file mode 100644 index 0000000000..8883d501e0 --- /dev/null +++ b/cpukit/rtems/src/msgqreceive.c @@ -0,0 +1,104 @@ +/* + * Message Queue Manager + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include + +/*PAGE + * + * rtems_message_queue_receive + * + * This directive dequeues a message from the designated message queue + * and copies it into the requesting thread's buffer. + * + * Input parameters: + * id - queue id + * buffer - pointer to message buffer + * size - size of message receive + * option_set - options on receive + * timeout - number of ticks to wait + * + * Output parameters: + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + */ + +rtems_status_code rtems_message_queue_receive( + Objects_Id id, + void *buffer, + unsigned32 *size, + unsigned32 option_set, + rtems_interval timeout +) +{ + register Message_queue_Control *the_message_queue; + Objects_Locations location; + boolean wait; + + the_message_queue = _Message_queue_Get( id, &location ); + switch ( location ) { + + case OBJECTS_REMOTE: +#if defined(RTEMS_MULTIPROCESSING) + return _Message_queue_MP_Send_request_packet( + MESSAGE_QUEUE_MP_RECEIVE_REQUEST, + id, + buffer, + size, + option_set, + timeout + ); +#endif + + case OBJECTS_ERROR: + return RTEMS_INVALID_ID; + + case OBJECTS_LOCAL: + if ( _Options_Is_no_wait( option_set ) ) + wait = FALSE; + else + wait = TRUE; + + _CORE_message_queue_Seize( + &the_message_queue->message_queue, + the_message_queue->Object.id, + buffer, + size, + wait, + timeout + ); + _Thread_Enable_dispatch(); + return( _Message_queue_Translate_core_message_queue_return_code( + _Thread_Executing->Wait.return_code ) ); + + } + + return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ +} diff --git a/cpukit/rtems/src/msgqsend.c b/cpukit/rtems/src/msgqsend.c new file mode 100644 index 0000000000..c657a88a60 --- /dev/null +++ b/cpukit/rtems/src/msgqsend.c @@ -0,0 +1,58 @@ +/* + * Message Queue Manager + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include + +/*PAGE + * + * rtems_message_queue_send + * + * This routine implements the directives q_send. It sends a + * message to the specified message queue. + * + * Input parameters: + * id - pointer to message queue + * buffer - pointer to message buffer + * size - size of message to sent urgently + * + * Output parameters: + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + */ + +rtems_status_code rtems_message_queue_send( + Objects_Id id, + void *buffer, + unsigned32 size +) +{ + return( _Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_SEND_REQUEST) ); +} diff --git a/cpukit/rtems/src/msgqsubmit.c b/cpukit/rtems/src/msgqsubmit.c new file mode 100644 index 0000000000..97a19209fa --- /dev/null +++ b/cpukit/rtems/src/msgqsubmit.c @@ -0,0 +1,138 @@ +/* + * Message Queue Manager + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include + +/*PAGE + * + * _Message_queue_Submit + * + * This routine implements the directives rtems_message_queue_send + * and rtems_message_queue_urgent. It processes a message that is + * to be submitted to the designated message queue. The message will + * either be processed as a send send message which it will be inserted + * at the rear of the queue or it will be processed as an urgent message + * which will be inserted at the front of the queue. + * + * Input parameters: + * id - pointer to message queue + * buffer - pointer to message buffer + * size - size in bytes of message to send + * submit_type - send or urgent message + * + * Output parameters: + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + */ + +rtems_status_code _Message_queue_Submit( + Objects_Id id, + void *buffer, + unsigned32 size, + Message_queue_Submit_types submit_type +) +{ + register Message_queue_Control *the_message_queue; + Objects_Locations location; + CORE_message_queue_Status core_status; + + the_message_queue = _Message_queue_Get( id, &location ); + switch ( location ) + { + case OBJECTS_REMOTE: +#if defined(RTEMS_MULTIPROCESSING) + switch ( submit_type ) { + case MESSAGE_QUEUE_SEND_REQUEST: + return _Message_queue_MP_Send_request_packet( + MESSAGE_QUEUE_MP_SEND_REQUEST, + id, + buffer, + &size, + 0, /* option_set */ + MPCI_DEFAULT_TIMEOUT + ); + + case MESSAGE_QUEUE_URGENT_REQUEST: + return _Message_queue_MP_Send_request_packet( + MESSAGE_QUEUE_MP_URGENT_REQUEST, + id, + buffer, + &size, + 0, /* option_set */ + MPCI_DEFAULT_TIMEOUT + ); + } + break; +#endif + + case OBJECTS_ERROR: + return RTEMS_INVALID_ID; + + case OBJECTS_LOCAL: + switch ( submit_type ) { + case MESSAGE_QUEUE_SEND_REQUEST: + core_status = _CORE_message_queue_Send( + &the_message_queue->message_queue, + buffer, + size, + id, +#if defined(RTEMS_MULTIPROCESSING) + _Message_queue_Core_message_queue_mp_support, +#else + NULL, +#endif + ); + break; + case MESSAGE_QUEUE_URGENT_REQUEST: + core_status = _CORE_message_queue_Urgent( + &the_message_queue->message_queue, + buffer, + size, + id, +#if defined(RTEMS_MULTIPROCESSING) + _Message_queue_Core_message_queue_mp_support, +#else + NULL, +#endif + ); + break; + default: + core_status = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL; + return RTEMS_INTERNAL_ERROR; /* should never get here */ + } + + _Thread_Enable_dispatch(); + return _Message_queue_Translate_core_message_queue_return_code( + core_status ); + + } + return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ +} diff --git a/cpukit/rtems/src/msgqtranslatereturncode.c b/cpukit/rtems/src/msgqtranslatereturncode.c new file mode 100644 index 0000000000..b2246dc1b1 --- /dev/null +++ b/cpukit/rtems/src/msgqtranslatereturncode.c @@ -0,0 +1,74 @@ +/* + * Message Queue Manager + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include + +/*PAGE + * + * _Message_queue_Translate_core_message_queue_return_code + * + * Input parameters: + * the_message_queue_status - message_queue status code to translate + * + * Output parameters: + * rtems status code - translated RTEMS status code + * + */ + +rtems_status_code _Message_queue_Translate_core_message_queue_return_code ( + unsigned32 the_message_queue_status +) +{ + switch ( the_message_queue_status ) { + case CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL: + return RTEMS_SUCCESSFUL; + case CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE: + return RTEMS_INVALID_SIZE; + case CORE_MESSAGE_QUEUE_STATUS_TOO_MANY: + return RTEMS_TOO_MANY; + case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED: + return RTEMS_UNSATISFIED; + case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT: + return RTEMS_UNSATISFIED; + case CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED: + return RTEMS_OBJECT_WAS_DELETED; + case CORE_MESSAGE_QUEUE_STATUS_TIMEOUT: + return RTEMS_TIMEOUT; + case THREAD_STATUS_PROXY_BLOCKING: + return RTEMS_PROXY_BLOCKING; + } + _Internal_error_Occurred( /* XXX */ + INTERNAL_ERROR_RTEMS_API, + TRUE, + the_message_queue_status + ); + return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ +} diff --git a/cpukit/rtems/src/msgqurgent.c b/cpukit/rtems/src/msgqurgent.c new file mode 100644 index 0000000000..037e65938b --- /dev/null +++ b/cpukit/rtems/src/msgqurgent.c @@ -0,0 +1,58 @@ +/* + * Message Queue Manager + * + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include + +/*PAGE + * + * rtems_message_queue_urgent + * + * This routine implements the directives q_urgent. It urgents a + * message to the specified message queue. + * + * Input parameters: + * id - pointer to message queue + * buffer - pointer to message buffer + * size - size of message to sent urgently + * + * Output parameters: + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + */ + +rtems_status_code rtems_message_queue_urgent( + Objects_Id id, + void *buffer, + unsigned32 size +) +{ + return(_Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_URGENT_REQUEST)); +} -- cgit v1.2.3