summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1995-09-19 14:53:29 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1995-09-19 14:53:29 +0000
commit3652ad356bf13abe0963c992cbbda96476d31609 (patch)
tree8ae01f1eec49c8fabc0a3db3d5b58b29a61428f2 /cpukit
parentInitial attempt at building HP PA-RISC using Solaris hosted tools. (diff)
downloadrtems-3652ad356bf13abe0963c992cbbda96476d31609.tar.bz2
Minor bug fixes to get all targets compilable and running. The
single biggest changes were the expansion of the workspace size macro to include other types of objects and the increase in the minimum stack size for most CPUs.
Diffstat (limited to '')
-rw-r--r--cpukit/libmisc/monitor/mon-object.c2
-rw-r--r--cpukit/libmisc/monitor/mon-queue.c6
-rw-r--r--cpukit/rtems/include/rtems/rtems/message.h217
-rw-r--r--cpukit/rtems/include/rtems/rtems/msgmp.h2
-rw-r--r--cpukit/rtems/inline/rtems/rtems/message.inl95
-rw-r--r--cpukit/rtems/macros/rtems/rtems/message.inl74
-rw-r--r--cpukit/rtems/src/msg.c524
-rw-r--r--cpukit/rtems/src/msgmp.c10
-rw-r--r--cpukit/rtems/src/sem.c99
-rw-r--r--cpukit/rtems/src/tasks.c27
-rw-r--r--cpukit/sapi/include/confdefs.h103
-rw-r--r--cpukit/score/cpu/hppa1.1/cpu.c9
-rw-r--r--cpukit/score/cpu/i386/cpu.c4
-rw-r--r--cpukit/score/cpu/unix/cpu.c85
-rw-r--r--cpukit/score/include/rtems/score/coremsg.h408
-rw-r--r--cpukit/score/inline/rtems/score/coremsg.inl186
-rw-r--r--cpukit/score/macros/rtems/score/coremsg.inl121
-rw-r--r--cpukit/score/src/coremsg.c436
18 files changed, 1628 insertions, 780 deletions
diff --git a/cpukit/libmisc/monitor/mon-object.c b/cpukit/libmisc/monitor/mon-object.c
index 2f92845586..7aef850141 100644
--- a/cpukit/libmisc/monitor/mon-object.c
+++ b/cpukit/libmisc/monitor/mon-object.c
@@ -130,7 +130,7 @@ rtems_monitor_id_fixup(
#else
#warning "TONY... FIX ME!!!!!"
#if defined(hppa1_1)
-#error "TONY... I SAID TO FIX ME!!!!! <HAHAHAHAHA>"
+#warning "TONY... I SAID TO FIX ME!!!!! <HAHAHAHAHA>"
#endif
id = _Objects_Build_id(0, default_node, rtems_get_index(id));
#endif
diff --git a/cpukit/libmisc/monitor/mon-queue.c b/cpukit/libmisc/monitor/mon-queue.c
index d09ac7a337..a72a371bff 100644
--- a/cpukit/libmisc/monitor/mon-queue.c
+++ b/cpukit/libmisc/monitor/mon-queue.c
@@ -18,9 +18,9 @@ rtems_monitor_queue_canonical(
Message_queue_Control *rtems_queue = (Message_queue_Control *) queue_void;
canonical_queue->attributes = rtems_queue->attribute_set;
- canonical_queue->maximum_message_size = rtems_queue->maximum_message_size;
- canonical_queue->maximum_pending_messages = rtems_queue->maximum_pending_messages;
- canonical_queue->number_of_pending_messages = rtems_queue->number_of_pending_messages;
+ canonical_queue->maximum_message_size = rtems_queue->message_queue.maximum_message_size;
+ canonical_queue->maximum_pending_messages = rtems_queue->message_queue.maximum_pending_messages;
+ canonical_queue->number_of_pending_messages = rtems_queue->message_queue.number_of_pending_messages;
}
void
diff --git a/cpukit/rtems/include/rtems/rtems/message.h b/cpukit/rtems/include/rtems/rtems/message.h
index 2ee910ac05..60592b5f3c 100644
--- a/cpukit/rtems/include/rtems/rtems/message.h
+++ b/cpukit/rtems/include/rtems/rtems/message.h
@@ -39,36 +39,18 @@ extern "C" {
#include <rtems/core/object.h>
#include <rtems/rtems/attr.h>
#include <rtems/core/threadq.h>
+#include <rtems/core/coremsg.h>
/*
- * The following defines the data types needed to manipulate
- * the contents of message buffers.
- * Since msgs are variable length we just make a ptr to 1.
- */
-
-typedef struct {
- unsigned32 size;
-
-#ifndef __cplusplus
- /* NOTE: [0] is gcc specific,
- * but specifically disallowed by ANSI STD C++
- * g++ warns about it, so we #ifdef it out to
- * get rid of warnings when compiled by g++.
- */
- unsigned32 buffer[0];
-#endif
-
-} Message_queue_Buffer;
-
-/*
- * The following records define the organization of a message
- * buffer.
+ * The following enumerated type details the modes in which a message
+ * may be submitted to a message queue. The message may be posted
+ * in a send or urgent fashion.
*/
-
-typedef struct {
- Chain_Node Node;
- Message_queue_Buffer Contents;
-} Message_queue_Buffer_control;
+
+typedef enum {
+ MESSAGE_QUEUE_SEND_REQUEST = 0,
+ MESSAGE_QUEUE_URGENT_REQUEST = 1
+} Message_queue_Submit_types;
/*
* The following records define the control block used to manage
@@ -76,15 +58,9 @@ typedef struct {
*/
typedef struct {
- Objects_Control Object;
- Thread_queue_Control Wait_queue;
- rtems_attribute attribute_set;
- unsigned32 maximum_pending_messages;
- unsigned32 number_of_pending_messages;
- unsigned32 maximum_message_size;
- Chain_Control Pending_messages;
- Message_queue_Buffer *message_buffers;
- Chain_Control Inactive_messages;
+ Objects_Control Object;
+ rtems_attribute attribute_set;
+ CORE_message_queue_Control message_queue;
} Message_queue_Control;
/*
@@ -95,17 +71,6 @@ typedef struct {
EXTERN Objects_Information _Message_queue_Information;
/*
- * The following enumerated type details the modes in which a message
- * may be submitted to a message queue. The message may be posted
- * in a send or urgent fashion.
- */
-
-typedef enum {
- MESSAGE_QUEUE_SEND_REQUEST = 0,
- MESSAGE_QUEUE_URGENT_REQUEST = 1
-} Message_queue_Submit_types;
-
-/*
* _Message_queue_Manager_initialization
*
* DESCRIPTION:
@@ -255,7 +220,7 @@ rtems_status_code rtems_message_queue_broadcast(
rtems_status_code rtems_message_queue_receive(
Objects_Id id,
void *buffer,
- unsigned32 *size_p,
+ unsigned32 *size,
unsigned32 option_set,
rtems_interval timeout
);
@@ -277,61 +242,18 @@ rtems_status_code rtems_message_queue_flush(
);
/*
- * _Message_queue_Copy_buffer
- *
- * DESCRIPTION:
- *
- * This routine copies the contents of the source message buffer
- * to the destination message buffer.
- */
-
-STATIC INLINE void _Message_queue_Copy_buffer (
- void *source,
- void *destination,
- unsigned32 size
-);
-
-/*
- * _Message_queue_Seize
- *
- * DESCRIPTION:
- *
- * This routine attempts to receive a message from the_message_queue.
- * If a message is available or if the RTEMS_NO_WAIT option is enabled in
- * option_set, then the routine returns. Otherwise, the calling task
- * is blocked until a message is available. If a message is returned
- * to the task, then buffer will contain its contents.
- */
-
-boolean _Message_queue_Seize(
- Message_queue_Control *the_message_queue,
- unsigned32 option_set,
- void *buffer,
- unsigned32 *size_p
-);
-
-/*
- * _Message_queue_Flush_support
- *
- * DESCRIPTION:
- *
- * This routine flushes all outstanding messages and returns
- * them to the inactive message chain.
- */
-
-unsigned32 _Message_queue_Flush_support(
- Message_queue_Control *the_message_queue
-);
-
-/*
* _Message_queue_Submit
*
* DESCRIPTION:
*
- * This routine provides the common foundation for the
- * rtems_message_queue_send and rtems_message_queue_urgent directives.
+ * 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.
*/
-
+
rtems_status_code _Message_queue_Submit(
Objects_Id id,
void *buffer,
@@ -340,76 +262,6 @@ rtems_status_code _Message_queue_Submit(
);
/*
- * _Message_queue_Allocate_message_buffer
- *
- * DESCRIPTION:
- *
- * This function allocates a message buffer from the inactive
- * message buffer chain.
- */
-
-STATIC INLINE Message_queue_Buffer_control *
- _Message_queue_Allocate_message_buffer (
- Message_queue_Control *the_message_queue
-);
-
-/*
- * _Message_queue_Free_message_buffer
- *
- * DESCRIPTION:
- *
- * This routine frees a message buffer to the inactive
- * message buffer chain.
- */
-
-STATIC INLINE void _Message_queue_Free_message_buffer (
- Message_queue_Control *the_message_queue,
- Message_queue_Buffer_control *the_message
-);
-
-/*
- * _Message_queue_Get_pending_message
- *
- * DESCRIPTION:
- *
- * This function removes the first message from the_message_queue
- * and returns a pointer to it.
- */
-
-STATIC INLINE
- Message_queue_Buffer_control *_Message_queue_Get_pending_message (
- Message_queue_Control *the_message_queue
-);
-
-/*
- * _Message_queue_Append
- *
- * DESCRIPTION:
- *
- * This routine places the_message at the rear of the outstanding
- * messages on the_message_queue.
- */
-
-STATIC INLINE void _Message_queue_Append (
- Message_queue_Control *the_message_queue,
- Message_queue_Buffer_control *the_message
-);
-
-/*
- * _Message_queue_Prepend
- *
- * DESCRIPTION:
- *
- * This routine places the_message at the rear of the outstanding
- * messages on the_message_queue.
- */
-
-STATIC INLINE void _Message_queue_Prepend (
- Message_queue_Control *the_message_queue,
- Message_queue_Buffer_control *the_message
-);
-
-/*
* _Message_queue_Is_null
*
* DESCRIPTION:
@@ -469,6 +321,35 @@ STATIC INLINE Message_queue_Control *_Message_queue_Get (
Objects_Locations *location
);
+/*
+ * _Message_queue_Translate_core_message_queue_return_code
+ *
+ * DESCRIPTION:
+ *
+ * This function returns a RTEMS status code based on the core message queue
+ * status code specified.
+ */
+
+rtems_status_code _Message_queue_Translate_core_message_queue_return_code (
+ unsigned32 the_message_queue_status
+);
+
+/*
+ *
+ * _Message_queue_Core_message_queue_mp_support
+ *
+ * Input parameters:
+ * the_thread - the remote thread the message was submitted to
+ * id - id of the message queue
+ *
+ * Output parameters: NONE
+ */
+
+void _Message_queue_Core_message_queue_mp_support (
+ Thread_Control *the_thread,
+ Objects_Id id
+);
+
#include <rtems/rtems/message.inl>
#include <rtems/rtems/msgmp.h>
diff --git a/cpukit/rtems/include/rtems/rtems/msgmp.h b/cpukit/rtems/include/rtems/rtems/msgmp.h
index 592328678b..2cc6bc1367 100644
--- a/cpukit/rtems/include/rtems/rtems/msgmp.h
+++ b/cpukit/rtems/include/rtems/rtems/msgmp.h
@@ -63,7 +63,7 @@ typedef struct {
unsigned32 count;
unsigned32 size;
unsigned32 pad0;
- Message_queue_Buffer Buffer;
+ CORE_message_queue_Buffer Buffer;
} Message_queue_MP_Packet;
/*
diff --git a/cpukit/rtems/inline/rtems/rtems/message.inl b/cpukit/rtems/inline/rtems/rtems/message.inl
index 5b34ce5a83..114781293c 100644
--- a/cpukit/rtems/inline/rtems/rtems/message.inl
+++ b/cpukit/rtems/inline/rtems/rtems/message.inl
@@ -21,96 +21,6 @@
/*PAGE
*
- * _Message_queue_Copy_buffer
- *
- */
-
-STATIC INLINE void _Message_queue_Copy_buffer (
- void *source,
- void *destination,
- unsigned32 size
-)
-{
- memcpy(destination, source, size);
-}
-
-/*PAGE
- *
- * _Message_queue_Allocate_message_buffer
- *
- */
-
-STATIC INLINE Message_queue_Buffer_control *
-_Message_queue_Allocate_message_buffer (
- Message_queue_Control *the_message_queue
-)
-{
- return (Message_queue_Buffer_control *)
- _Chain_Get( &the_message_queue->Inactive_messages );
-}
-
-/*PAGE
- *
- * _Message_queue_Free_message_buffer
- *
- */
-
-STATIC INLINE void _Message_queue_Free_message_buffer (
- Message_queue_Control *the_message_queue,
- Message_queue_Buffer_control *the_message
-)
-{
- _Chain_Append( &the_message_queue->Inactive_messages, &the_message->Node );
-}
-
-/*PAGE
- *
- * _Message_queue_Get_pending_message
- *
- */
-
-STATIC INLINE
- Message_queue_Buffer_control *_Message_queue_Get_pending_message (
- Message_queue_Control *the_message_queue
-)
-{
- return (Message_queue_Buffer_control *)
- _Chain_Get_unprotected( &the_message_queue->Pending_messages );
-}
-
-/*PAGE
- *
- * _Message_queue_Append
- *
- */
-
-STATIC INLINE void _Message_queue_Append (
- Message_queue_Control *the_message_queue,
- Message_queue_Buffer_control *the_message
-)
-{
- _Chain_Append( &the_message_queue->Pending_messages, &the_message->Node );
-}
-
-/*PAGE
- *
- * _Message_queue_Prepend
- *
- */
-
-STATIC INLINE void _Message_queue_Prepend (
- Message_queue_Control *the_message_queue,
- Message_queue_Buffer_control *the_message
-)
-{
- _Chain_Prepend(
- &the_message_queue->Pending_messages,
- &the_message->Node
- );
-}
-
-/*PAGE
- *
* _Message_queue_Is_null
*
*/
@@ -133,11 +43,6 @@ STATIC INLINE void _Message_queue_Free (
Message_queue_Control *the_message_queue
)
{
- if (the_message_queue->message_buffers) {
- _Workspace_Free((void *) the_message_queue->message_buffers);
- the_message_queue->message_buffers = 0;
- }
-
_Objects_Free( &_Message_queue_Information, &the_message_queue->Object );
}
diff --git a/cpukit/rtems/macros/rtems/rtems/message.inl b/cpukit/rtems/macros/rtems/rtems/message.inl
index ef694fb11a..62b6ac0ceb 100644
--- a/cpukit/rtems/macros/rtems/rtems/message.inl
+++ b/cpukit/rtems/macros/rtems/rtems/message.inl
@@ -19,66 +19,6 @@
/*PAGE
*
- * _Message_queue_Copy_buffer
- */
-
-#define _Message_queue_Copy_buffer( _source, _destination, _size ) \
- memcpy( _destination, _source, _size)
-
-/*PAGE
- *
- * _Message_queue_Allocate_message_buffer
- *
- */
-
-#define _Message_queue_Allocate_message_buffer( _the_message_queue ) \
- (Message_queue_Buffer_control *) \
- _Chain_Get( &(_the_message_queue)->Inactive_messages )
-
-/*PAGE
- *
- * _Message_queue_Free_message_buffer
- *
- */
-
-#define _Message_queue_Free_message_buffer( _the_message_queue, _the_message ) \
- _Chain_Append( \
- &(_the_message_queue)->Inactive_messages, \
- &(_the_message)->Node \
- )
-
-/*PAGE
- *
- * _Message_queue_Get_pending_message
- *
- */
-
-#define _Message_queue_Get_pending_message( _the_message_queue ) \
- (Message_queue_Buffer_control *) \
- _Chain_Get_unprotected( &(_the_message_queue)->Pending_messages )
-
-/*PAGE
- *
- * _Message_queue_Append
- *
- */
-
-#define _Message_queue_Append( _the_message_queue, _the_message ) \
- _Chain_Append( &(_the_message_queue)->Pending_messages, \
- &(_the_message)->Node )
-
-/*PAGE
- *
- * _Message_queue_Prepend
- *
- */
-
-#define _Message_queue_Prepend( _the_message_queue, _the_message ) \
- _Chain_Prepend( &(_the_message_queue)->Pending_messages, \
- &(_the_message)->Node )
-
-/*PAGE
- *
* _Message_queue_Is_null
*
*/
@@ -93,19 +33,7 @@
*/
#define _Message_queue_Free( _the_message_queue ) \
- do { \
- \
- if ( (_the_message_queue)->message_buffers ) { \
- _Workspace_Free((void *) (_the_message_queue)->message_buffers); \
- (_the_message_queue)->message_buffers = 0; \
- } \
- \
- _Objects_Free( \
- &_Message_queue_Information, \
- &(_the_message_queue)->Object \
- ); \
- } while ( 0 )
-
+ _Objects_Free( &_Message_queue_Information, &(_the_message_queue)->Object )
/*PAGE
*
diff --git a/cpukit/rtems/src/msg.c b/cpukit/rtems/src/msg.c
index a69ae777c6..36c6bd7a79 100644
--- a/cpukit/rtems/src/msg.c
+++ b/cpukit/rtems/src/msg.c
@@ -14,19 +14,20 @@
*/
#include <rtems/system.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/attr.h>
+#include <rtems/sysstate.h>
#include <rtems/core/chain.h>
#include <rtems/core/isr.h>
-#include <rtems/rtems/message.h>
+#include <rtems/core/coremsg.h>
#include <rtems/core/object.h>
-#include <rtems/rtems/options.h>
#include <rtems/core/states.h>
-#include <rtems/rtems/support.h>
#include <rtems/core/thread.h>
#include <rtems/core/wkspace.h>
#include <rtems/core/mpci.h>
-#include <rtems/sysstate.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/attr.h>
+#include <rtems/rtems/message.h>
+#include <rtems/rtems/options.h>
+#include <rtems/rtems/support.h>
/*PAGE
*
@@ -72,56 +73,24 @@ void _Message_queue_Manager_initialization(
* _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
+ unsigned32 count,
+ unsigned32 max_message_size
)
{
- Message_queue_Control *mq = 0;
- unsigned32 message_buffering_required;
- unsigned32 allocated_message_size;
-
- mq =
- (Message_queue_Control *)_Objects_Allocate(&_Message_queue_Information);
-
- if (mq == 0)
- goto failed;
-
- mq->maximum_message_size = max_message_size;
-
- /*
- * round size up to multiple of a ptr for chain init
- */
-
- allocated_message_size = max_message_size;
- if (allocated_message_size & (sizeof(unsigned32) - 1)) {
- allocated_message_size += sizeof(unsigned32);
- allocated_message_size &= ~(sizeof(unsigned32) - 1);
- }
-
- message_buffering_required =
- count * (allocated_message_size + sizeof(Message_queue_Buffer_control));
-
- mq->message_buffers =
- (Message_queue_Buffer *) _Workspace_Allocate(message_buffering_required);
-
- if (mq->message_buffers == 0)
- goto failed;
-
- _Chain_Initialize
- (&mq->Inactive_messages,
- mq->message_buffers,
- count,
- allocated_message_size + sizeof(Message_queue_Buffer_control)
- );
- return mq;
+ return
+ (Message_queue_Control *)_Objects_Allocate(&_Message_queue_Information);
-failed:
- if (mq)
- _Message_queue_Free(mq);
- return (Message_queue_Control *) 0;
}
/*PAGE
@@ -132,11 +101,11 @@ failed:
* a message queue data structure.
*
* Input parameters:
- * name - user defined queue name
- * count - maximum message and reserved buffer count
+ * 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
+ * attribute_set - process method
+ * id - pointer to queue
*
* Output parameters:
* id - queue id
@@ -153,11 +122,13 @@ rtems_status_code rtems_message_queue_create(
)
{
register Message_queue_Control *the_message_queue;
+ CORE_message_queue_Attributes the_message_queue_attributes;
+ boolean is_global;
if ( !rtems_is_name_valid( name ) )
return RTEMS_INVALID_NAME;
- if ( _Attributes_Is_global( attribute_set ) &&
+ if ( (is_global = _Attributes_Is_global( attribute_set ) ) &&
!_System_state_Is_multiprocessing )
return RTEMS_MP_NOT_CONFIGURED;
@@ -174,46 +145,52 @@ rtems_status_code rtems_message_queue_create(
* and then just send smaller msgs from remote (or all) nodes.
*/
- if ( _Attributes_Is_global( attribute_set ) &&
- (_MPCI_table->maximum_packet_size < max_message_size))
- {
- return RTEMS_INVALID_SIZE;
- }
+ if ( is_global && (_MPCI_table->maximum_packet_size < max_message_size) )
+ return RTEMS_INVALID_SIZE;
+
#endif
_Thread_Disable_dispatch(); /* protects object pointer */
- the_message_queue = _Message_queue_Allocate(count, max_message_size);
+ the_message_queue = _Message_queue_Allocate( count, max_message_size );
if ( !the_message_queue ) {
_Thread_Enable_dispatch();
return RTEMS_TOO_MANY;
}
- if ( _Attributes_Is_global( attribute_set ) &&
- !( _Objects_MP_Allocate_and_open( &_Message_queue_Information, name,
- the_message_queue->Object.id, FALSE ) ) ) {
+ 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;
}
- the_message_queue->maximum_pending_messages = count;
-
the_message_queue->attribute_set = attribute_set;
- the_message_queue->number_of_pending_messages = 0;
- _Chain_Initialize_empty( &the_message_queue->Pending_messages );
+ 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;
+
+ if ( ! _CORE_message_queue_Initialize(
+ &the_message_queue->message_queue,
+ OBJECTS_RTEMS_MESSAGE_QUEUES,
+ &the_message_queue_attributes,
+ count,
+ max_message_size,
+ _Message_queue_MP_Send_extract_proxy ) ) {
+ if ( is_global )
+ _Objects_MP_Close(
+ &_Message_queue_Information, the_message_queue->Object.id);
- _Thread_queue_Initialize(
- &the_message_queue->Wait_queue,
- OBJECTS_RTEMS_MESSAGE_QUEUES,
- _Attributes_Is_priority( attribute_set ) ?
- THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO,
- STATES_WAITING_FOR_MESSAGE,
- _Message_queue_MP_Send_extract_proxy,
- RTEMS_TIMEOUT
- );
+ _Message_queue_Free( the_message_queue );
+ _Thread_Enable_dispatch();
+ return RTEMS_TOO_MANY;
+ }
_Objects_Open(
&_Message_queue_Information,
@@ -223,7 +200,7 @@ rtems_status_code rtems_message_queue_create(
*id = the_message_queue->Object.id;
- if ( _Attributes_Is_global( attribute_set ) )
+ if ( is_global )
_Message_queue_MP_Send_process_packet(
MESSAGE_QUEUE_MP_ANNOUNCE_CREATE,
the_message_queue->Object.id,
@@ -304,14 +281,11 @@ rtems_status_code rtems_message_queue_delete(
_Objects_Close( &_Message_queue_Information,
&the_message_queue->Object );
- if ( the_message_queue->number_of_pending_messages != 0 )
- (void) _Message_queue_Flush_support( the_message_queue );
- else
- _Thread_queue_Flush(
- &the_message_queue->Wait_queue,
- _Message_queue_MP_Send_object_was_deleted,
- RTEMS_OBJECT_WAS_DELETED
- );
+ _CORE_message_queue_Close(
+ &the_message_queue->message_queue,
+ _Message_queue_MP_Send_object_was_deleted,
+ CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED
+ );
_Message_queue_Free( the_message_queue );
@@ -346,6 +320,7 @@ rtems_status_code rtems_message_queue_delete(
* 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
@@ -358,7 +333,7 @@ rtems_status_code rtems_message_queue_send(
unsigned32 size
)
{
- return _Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_SEND_REQUEST);
+ return( _Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_SEND_REQUEST) );
}
/*PAGE
@@ -371,10 +346,11 @@ rtems_status_code rtems_message_queue_send(
* 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
+ * error code - if unsuccessful
*/
rtems_status_code rtems_message_queue_urgent(
@@ -383,7 +359,7 @@ rtems_status_code rtems_message_queue_urgent(
unsigned32 size
)
{
- return _Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_URGENT_REQUEST);
+ return(_Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_URGENT_REQUEST));
}
/*PAGE
@@ -396,11 +372,12 @@ rtems_status_code rtems_message_queue_urgent(
* 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
+ * RTEMS_SUCCESSFUL - if successful
* error code - if unsuccessful
*/
@@ -413,8 +390,7 @@ rtems_status_code rtems_message_queue_broadcast(
{
register Message_queue_Control *the_message_queue;
Objects_Locations location;
- Thread_Control *the_thread;
- unsigned32 number_broadcasted;
+ CORE_message_queue_Status core_status;
the_message_queue = _Message_queue_Get( id, &location );
switch ( location ) {
@@ -434,44 +410,21 @@ rtems_status_code rtems_message_queue_broadcast(
);
case OBJECTS_LOCAL:
- {
- Thread_Wait_information *waitp;
- unsigned32 constrained_size;
-
- number_broadcasted = 0;
- while ( (the_thread =
- _Thread_queue_Dequeue(&the_message_queue->Wait_queue)) ) {
- waitp = &the_thread->Wait;
- number_broadcasted += 1;
-
- constrained_size = size;
- if (size > the_message_queue->maximum_message_size)
- constrained_size = the_message_queue->maximum_message_size;
-
- _Message_queue_Copy_buffer(buffer,
- waitp->return_argument,
- constrained_size);
-
- *(rtems_unsigned32 *)the_thread->Wait.return_argument_1 = size;
-
- if ( !_Objects_Is_local_id( the_thread->Object.id ) ) {
- the_thread->receive_packet->return_code = RTEMS_SUCCESSFUL;
-
- _Message_queue_MP_Send_response_packet(
- MESSAGE_QUEUE_MP_RECEIVE_RESPONSE,
- id,
- the_thread
- );
- }
- }
+ core_status = _CORE_message_queue_Broadcast(
+ &the_message_queue->message_queue,
+ buffer,
+ size,
+ id,
+ _Message_queue_Core_message_queue_mp_support,
+ count
+ );
+
_Thread_Enable_dispatch();
- *count = number_broadcasted;
- return RTEMS_SUCCESSFUL;
- }
+ return
+ _Message_queue_Translate_core_message_queue_return_code( core_status );
- default:
- return RTEMS_INTERNAL_ERROR;
}
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -484,24 +437,26 @@ rtems_status_code rtems_message_queue_broadcast(
* 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
+ * error code - if unsuccessful
*/
rtems_status_code rtems_message_queue_receive(
Objects_Id id,
void *buffer,
- unsigned32 *size_p,
+ 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 ) {
@@ -514,21 +469,29 @@ rtems_status_code rtems_message_queue_receive(
MESSAGE_QUEUE_MP_RECEIVE_REQUEST,
id,
buffer,
- size_p,
+ size,
option_set,
timeout
);
case OBJECTS_LOCAL:
- if ( ! _Message_queue_Seize(the_message_queue,
- option_set,
- buffer,
- size_p))
- {
- _Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout );
- }
+ 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 _Thread_Executing->Wait.return_code;
+ return( _Message_queue_Translate_core_message_queue_return_code(
+ _Thread_Executing->Wait.return_code ) );
+
}
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
@@ -572,16 +535,13 @@ rtems_status_code rtems_message_queue_flush(
MESSAGE_QUEUE_MP_FLUSH_REQUEST,
id,
0, /* buffer not used */
- 0, /* size_p */
+ 0, /* size */
0, /* option_set not used */
MPCI_DEFAULT_TIMEOUT
);
case OBJECTS_LOCAL:
- if ( the_message_queue->number_of_pending_messages != 0 )
- *count = _Message_queue_Flush_support( the_message_queue );
- else
- *count = 0;
+ *count = _CORE_message_queue_Flush( &the_message_queue->message_queue );
_Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL;
}
@@ -591,125 +551,14 @@ rtems_status_code rtems_message_queue_flush(
/*PAGE
*
- * _Message_queue_Seize
- *
- * This kernel routine dequeues a message, copies the message buffer to
- * a given destination buffer, and frees the message buffer to the
- * inactive message pool.
- *
- * Input parameters:
- * the_message_queue - pointer to message queue
- * option_set - options on receive
- * the_buffer - pointer to message buffer to be filled
- *
- * Output parameters:
- * TRUE - if message received or RTEMS_NO_WAIT and no message
- * FALSE - if thread is to block
- *
- * NOTE: Dependent on BUFFER_LENGTH
- *
- * INTERRUPT LATENCY:
- * available
- * wait
- */
-
-boolean _Message_queue_Seize(
- Message_queue_Control *the_message_queue,
- rtems_option option_set,
- void *buffer,
- unsigned32 *size_p
-)
-{
- ISR_Level level;
- Message_queue_Buffer_control *the_message;
- Thread_Control *executing;
-
- executing = _Thread_Executing;
- executing->Wait.return_code = RTEMS_SUCCESSFUL;
- _ISR_Disable( level );
- if ( the_message_queue->number_of_pending_messages != 0 ) {
- the_message_queue->number_of_pending_messages -= 1;
-
- the_message = _Message_queue_Get_pending_message( the_message_queue );
- _ISR_Enable( level );
- *size_p = the_message->Contents.size;
- _Message_queue_Copy_buffer( the_message->Contents.buffer, buffer, *size_p );
- _Message_queue_Free_message_buffer(the_message_queue, the_message );
- return( TRUE );
- }
-
- if ( _Options_Is_no_wait( option_set ) ) {
- _ISR_Enable( level );
- executing->Wait.return_code = RTEMS_UNSATISFIED;
- return( TRUE );
- }
-
- the_message_queue->Wait_queue.sync = TRUE;
- executing->Wait.queue = &the_message_queue->Wait_queue;
- executing->Wait.id = the_message_queue->Object.id;
- executing->Wait.option = option_set;
- executing->Wait.return_argument = (void *)buffer;
- executing->Wait.return_argument_1 = (void *)size_p;
- _ISR_Enable( level );
- return FALSE;
-}
-
-/*PAGE
- *
- * _Message_queue_Flush_support
- *
- * This message manager routine removes all messages from a message queue
- * and returns them to the inactive message pool.
- *
- * Input parameters:
- * the_message_queue - pointer to message queue
- *
- * Output parameters:
- * returns - number of messages placed on inactive chain
- *
- * INTERRUPT LATENCY:
- * only case
- */
-
-unsigned32 _Message_queue_Flush_support(
- Message_queue_Control *the_message_queue
-)
-{
- ISR_Level level;
- Chain_Node *inactive_first;
- Chain_Node *message_queue_first;
- Chain_Node *message_queue_last;
- unsigned32 count;
-
- _ISR_Disable( level );
- inactive_first = the_message_queue->Inactive_messages.first;
- message_queue_first = the_message_queue->Pending_messages.first;
- message_queue_last = the_message_queue->Pending_messages.last;
-
- the_message_queue->Inactive_messages.first = message_queue_first;
- message_queue_last->next = inactive_first;
- inactive_first->previous = message_queue_last;
- message_queue_first->previous =
- _Chain_Head( &the_message_queue->Inactive_messages );
-
- _Chain_Initialize_empty( &the_message_queue->Pending_messages );
-
- count = the_message_queue->number_of_pending_messages;
- the_message_queue->number_of_pending_messages = 0;
- _ISR_Enable( level );
- return count;
-}
-
-/*PAGE
- *
* _Message_queue_Submit
*
- * This routine implements the directives q_send and q_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.
+ * 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
@@ -729,10 +578,9 @@ rtems_status_code _Message_queue_Submit(
Message_queue_Submit_types submit_type
)
{
- register Message_queue_Control *the_message_queue;
- Objects_Locations location;
- Thread_Control *the_thread;
- Message_queue_Buffer_control *the_message;
+ 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 )
@@ -766,75 +614,101 @@ rtems_status_code _Message_queue_Submit(
}
case OBJECTS_LOCAL:
- if (size > the_message_queue->maximum_message_size)
- {
- _Thread_Enable_dispatch();
- return RTEMS_INVALID_SIZE;
- }
-
- /*
- * Is there a thread currently waiting on this message queue?
- */
-
- the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );
- if ( the_thread )
- {
- _Message_queue_Copy_buffer(
- buffer,
- the_thread->Wait.return_argument,
- size
- );
- *(rtems_unsigned32 *)the_thread->Wait.return_argument_1 = size;
-
- if ( !_Objects_Is_local_id( the_thread->Object.id ) ) {
- the_thread->receive_packet->return_code = RTEMS_SUCCESSFUL;
-
- _Message_queue_MP_Send_response_packet(
- MESSAGE_QUEUE_MP_RECEIVE_RESPONSE,
- id,
- the_thread
- );
-
- }
- _Thread_Enable_dispatch();
- return RTEMS_SUCCESSFUL;
- }
-
- /*
- * No one waiting on this one currently.
- * Allocate a message buffer and store it away
- */
-
- if ( the_message_queue->number_of_pending_messages ==
- the_message_queue->maximum_pending_messages ) {
- _Thread_Enable_dispatch();
- return RTEMS_TOO_MANY;
- }
-
- the_message = _Message_queue_Allocate_message_buffer(the_message_queue);
- if ( the_message == 0) {
- _Thread_Enable_dispatch();
- return RTEMS_UNSATISFIED;
- }
-
- _Message_queue_Copy_buffer( buffer, the_message->Contents.buffer, size );
- the_message->Contents.size = size;
-
- the_message_queue->number_of_pending_messages += 1;
-
switch ( submit_type ) {
case MESSAGE_QUEUE_SEND_REQUEST:
- _Message_queue_Append( the_message_queue, the_message );
+ core_status = _CORE_message_queue_Send(
+ &the_message_queue->message_queue,
+ buffer,
+ size,
+ id,
+ _Message_queue_Core_message_queue_mp_support
+ );
break;
case MESSAGE_QUEUE_URGENT_REQUEST:
- _Message_queue_Prepend( the_message_queue, the_message );
+ core_status = _CORE_message_queue_Urgent(
+ &the_message_queue->message_queue,
+ buffer,
+ size,
+ id,
+ _Message_queue_Core_message_queue_mp_support
+ );
break;
+ default:
+ core_status = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
+ return RTEMS_INTERNAL_ERROR; /* should never get here */
}
_Thread_Enable_dispatch();
- return RTEMS_SUCCESSFUL;
+ return _Message_queue_Translate_core_message_queue_return_code(
+ core_status );
- default:
- return RTEMS_INTERNAL_ERROR; /* And they were such nice boys, too! */
}
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
+}
+
+/*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 THREAD_STATUS_PROXY_BLOCKING;
+ }
+ _Internal_error_Occurred( /* XXX */
+ INTERNAL_ERROR_RTEMS_API,
+ TRUE,
+ the_message_queue_status
+ );
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
+}
+
+/*PAGE
+ *
+ * _Message_queue_Core_message_queue_mp_support
+ *
+ * Input parameters:
+ * the_thread - the remote thread the message was submitted to
+ * id - id of the message queue
+ *
+ * Output parameters: NONE
+ */
+
+void _Message_queue_Core_message_queue_mp_support (
+ Thread_Control *the_thread,
+ Objects_Id id
+)
+{
+ the_thread->receive_packet->return_code = RTEMS_SUCCESSFUL;
+
+ _Message_queue_MP_Send_response_packet(
+ MESSAGE_QUEUE_MP_RECEIVE_RESPONSE,
+ id,
+ the_thread
+ );
}
diff --git a/cpukit/rtems/src/msgmp.c b/cpukit/rtems/src/msgmp.c
index 06afd4eedc..092886d272 100644
--- a/cpukit/rtems/src/msgmp.c
+++ b/cpukit/rtems/src/msgmp.c
@@ -133,9 +133,11 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
if (buffer) {
the_packet->Buffer.size = *size_p;
- _Message_queue_Copy_buffer(buffer,
- the_packet->Buffer.buffer,
- *size_p);
+ _CORE_message_queue_Copy_buffer(
+ buffer,
+ the_packet->Buffer.buffer,
+ *size_p
+ );
}
return _MPCI_Send_request_packet(rtems_get_node(message_queue_id),
@@ -310,7 +312,7 @@ void _Message_queue_MP_Process_packet (
*(rtems_unsigned32 *)the_thread->Wait.return_argument_1 =
the_packet->size;
- _Message_queue_Copy_buffer(
+ _CORE_message_queue_Copy_buffer(
the_packet->Buffer.buffer,
the_thread->Wait.return_argument,
the_packet->size
diff --git a/cpukit/rtems/src/sem.c b/cpukit/rtems/src/sem.c
index 9ba1634164..ca77005137 100644
--- a/cpukit/rtems/src/sem.c
+++ b/cpukit/rtems/src/sem.c
@@ -116,26 +116,26 @@ rtems_status_code rtems_semaphore_create(
unsigned32 lock;
if ( !rtems_is_name_valid( name ) )
- return ( RTEMS_INVALID_NAME );
+ return RTEMS_INVALID_NAME;
if ( _Attributes_Is_global( attribute_set ) ) {
if ( !_System_state_Is_multiprocessing )
- return( RTEMS_MP_NOT_CONFIGURED );
+ return RTEMS_MP_NOT_CONFIGURED;
if ( _Attributes_Is_inherit_priority( attribute_set ) )
- return( RTEMS_NOT_DEFINED );
+ return RTEMS_NOT_DEFINED;
} else if ( _Attributes_Is_inherit_priority( attribute_set ) ) {
if ( ! ( _Attributes_Is_binary_semaphore( attribute_set ) &&
_Attributes_Is_priority( attribute_set ) ) )
- return( RTEMS_NOT_DEFINED );
+ return RTEMS_NOT_DEFINED;
}
if ( _Attributes_Is_binary_semaphore( attribute_set ) && ( count > 1 ) )
- return( RTEMS_INVALID_NUMBER );
+ return RTEMS_INVALID_NUMBER;
_Thread_Disable_dispatch(); /* prevents deletion */
@@ -143,7 +143,7 @@ rtems_status_code rtems_semaphore_create(
if ( !the_semaphore ) {
_Thread_Enable_dispatch();
- return( RTEMS_TOO_MANY );
+ return RTEMS_TOO_MANY;
}
if ( _Attributes_Is_global( attribute_set ) &&
@@ -151,7 +151,7 @@ rtems_status_code rtems_semaphore_create(
the_semaphore->Object.id, FALSE ) ) ) {
_Semaphore_Free( the_semaphore );
_Thread_Enable_dispatch();
- return( RTEMS_TOO_MANY );
+ return RTEMS_TOO_MANY;
}
the_semaphore->attribute_set = attribute_set;
@@ -210,7 +210,7 @@ rtems_status_code rtems_semaphore_create(
0 /* Not used */
);
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -270,15 +270,15 @@ rtems_status_code rtems_semaphore_delete(
the_semaphore = _Semaphore_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
_Thread_Dispatch();
- return( RTEMS_ILLEGAL_ON_REMOTE_OBJECT );
+ return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
case OBJECTS_LOCAL:
if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set) ) {
if ( _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex ) ) {
_Thread_Enable_dispatch();
- return( RTEMS_RESOURCE_IN_USE );
+ return RTEMS_RESOURCE_IN_USE;
}
else
_CORE_mutex_Flush(
@@ -310,10 +310,10 @@ rtems_status_code rtems_semaphore_delete(
);
}
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -345,7 +345,7 @@ rtems_status_code rtems_semaphore_obtain(
the_semaphore = _Semaphore_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
return _Semaphore_MP_Send_request_packet(
SEMAPHORE_MP_OBTAIN_REQUEST,
@@ -367,8 +367,8 @@ rtems_status_code rtems_semaphore_obtain(
timeout
);
_Thread_Enable_dispatch();
- return( _Semaphore_Translate_core_mutex_return_code(
- _Thread_Executing->Wait.return_code ) );
+ return _Semaphore_Translate_core_mutex_return_code(
+ _Thread_Executing->Wait.return_code );
} else {
_CORE_semaphore_Seize(
&the_semaphore->Core_control.semaphore,
@@ -377,12 +377,12 @@ rtems_status_code rtems_semaphore_obtain(
timeout
);
_Thread_Enable_dispatch();
- return( _Semaphore_Translate_core_semaphore_return_code(
- _Thread_Executing->Wait.return_code ) );
+ return _Semaphore_Translate_core_semaphore_return_code(
+ _Thread_Executing->Wait.return_code );
}
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -411,15 +411,13 @@ rtems_status_code rtems_semaphore_release(
the_semaphore = _Semaphore_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
- return(
- _Semaphore_MP_Send_request_packet(
- SEMAPHORE_MP_RELEASE_REQUEST,
- id,
- 0, /* Not used */
- MPCI_DEFAULT_TIMEOUT
- )
+ return _Semaphore_MP_Send_request_packet(
+ SEMAPHORE_MP_RELEASE_REQUEST,
+ id,
+ 0, /* Not used */
+ MPCI_DEFAULT_TIMEOUT
);
case OBJECTS_LOCAL:
if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set ) ) {
@@ -429,7 +427,7 @@ rtems_status_code rtems_semaphore_release(
_Semaphore_Core_mutex_mp_support
);
_Thread_Enable_dispatch();
- return( _Semaphore_Translate_core_mutex_return_code( mutex_status ) );
+ return _Semaphore_Translate_core_mutex_return_code( mutex_status );
}
else
semaphore_status = _CORE_semaphore_Surrender(
@@ -438,11 +436,11 @@ rtems_status_code rtems_semaphore_release(
_Semaphore_Core_semaphore_mp_support
);
_Thread_Enable_dispatch();
- return(
- _Semaphore_Translate_core_semaphore_return_code( semaphore_status ) );
+ return
+ _Semaphore_Translate_core_semaphore_return_code( semaphore_status );
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -463,26 +461,21 @@ rtems_status_code _Semaphore_Translate_core_mutex_return_code (
{
switch ( the_mutex_status ) {
case CORE_MUTEX_STATUS_SUCCESSFUL:
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
case CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT:
- return( RTEMS_UNSATISFIED );
+ return RTEMS_UNSATISFIED;
case CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED:
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE:
- return( RTEMS_NOT_OWNER_OF_RESOURCE );
+ return RTEMS_NOT_OWNER_OF_RESOURCE;
case CORE_MUTEX_WAS_DELETED:
- return( RTEMS_OBJECT_WAS_DELETED );
+ return RTEMS_OBJECT_WAS_DELETED;
case CORE_MUTEX_TIMEOUT:
- return( RTEMS_TIMEOUT );
+ return RTEMS_TIMEOUT;
case THREAD_STATUS_PROXY_BLOCKING:
- return( THREAD_STATUS_PROXY_BLOCKING );
+ return THREAD_STATUS_PROXY_BLOCKING;
}
- _Internal_error_Occurred(
- INTERNAL_ERROR_RTEMS_API,
- TRUE,
- the_mutex_status
- );
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -503,23 +496,17 @@ rtems_status_code _Semaphore_Translate_core_semaphore_return_code (
{
switch ( the_semaphore_status ) {
case CORE_SEMAPHORE_STATUS_SUCCESSFUL:
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
case CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT:
- return( RTEMS_UNSATISFIED );
+ return RTEMS_UNSATISFIED;
case CORE_SEMAPHORE_WAS_DELETED:
- return( RTEMS_OBJECT_WAS_DELETED );
+ return RTEMS_OBJECT_WAS_DELETED;
case CORE_SEMAPHORE_TIMEOUT:
- return( RTEMS_TIMEOUT );
+ return RTEMS_TIMEOUT;
case THREAD_STATUS_PROXY_BLOCKING:
- return( THREAD_STATUS_PROXY_BLOCKING );
+ return THREAD_STATUS_PROXY_BLOCKING;
}
- _Internal_error_Occurred(
- INTERNAL_ERROR_RTEMS_API,
- TRUE,
- the_semaphore_status
- );
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
diff --git a/cpukit/rtems/src/tasks.c b/cpukit/rtems/src/tasks.c
index 70ec7d6928..8906805164 100644
--- a/cpukit/rtems/src/tasks.c
+++ b/cpukit/rtems/src/tasks.c
@@ -114,26 +114,21 @@ User_extensions_routine _RTEMS_tasks_Switch_extension(
asr = &api->Signal;
_ISR_Disable( level );
-
- signal_set = asr->signals_posted;
-
- if ( signal_set ) {
- /* if ( _ASR_Are_signals_pending( asr ) ) {
-
- signal_set = asr->signals_posted; */
+ signal_set = asr->signals_posted;
asr->signals_posted = 0;
- _ISR_Enable( level );
+ _ISR_Enable( level );
- asr->nest_level += 1;
- rtems_task_mode( asr->mode_set, RTEMS_ALL_MODE_MASKS, &prev_mode );
- (*asr->handler)( signal_set );
+ if ( !signal_set ) /* similar to _ASR_Are_signals_pending( asr ) */
+ return;
- asr->nest_level -= 1;
- rtems_task_mode( prev_mode, RTEMS_ALL_MODE_MASKS, &prev_mode );
- }
- else
- _ISR_Enable( level );
+ asr->nest_level += 1;
+ rtems_task_mode( asr->mode_set, RTEMS_ALL_MODE_MASKS, &prev_mode );
+
+ (*asr->handler)( signal_set );
+
+ asr->nest_level -= 1;
+ rtems_task_mode( prev_mode, RTEMS_ALL_MODE_MASKS, &prev_mode );
}
diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 9939ba63ee..83f6c3ccd1 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -236,13 +236,108 @@ rtems_multiprocessing_table Multiprocessing_configuration = {
#define CONFIGURE_INITIAL_EXTENSIONS NULL
#endif
-/* Calculate the RAM size based on the maximum number of tasks configured */
+/*
+ * Calculate the RAM size based on the maximum number of objects configured.
+ * The model is to estimate the memory required for each configured item,
+ * sum the memory requirements and insure that there is at least 32K greater
+ * than that for things not directly addressed such as:
+ *
+ * + stacks greater than minimum size
+ * + FP contexts
+ * + API areas (should be optional)
+ * + messages
+ * + object name and local pointer table overhead
+ * + per node memory requirements
+ * + executive fixed requirements (including at least internal threads
+ * and the Ready chains)
+ *
+ * NOTE: Eventually this should take into account some of the above.
+ * Basically, this is a "back of the envelope" estimate for
+ * memory requirements. It could be more accurate.
+ */
#ifndef CONFIGURE_EXECUTIVE_RAM_SIZE
-#define CONFIGURE_MEMORY_REQUIRED(_tasks) \
- (_tasks) * ( (sizeof(Thread_Control) + CONTEXT_FP_SIZE + STACK_MINIMUM_SIZE))
+
+#define CONFIGURE_OBJECT_TABLE_STUFF \
+ ( sizeof(Objects_Control *) + sizeof(rtems_name *) + sizeof(rtems_name) )
+
+#define CONFIGURE_MEMORY_FOR_TASKS(_tasks) \
+ ((_tasks) * \
+ ((sizeof(Thread_Control) + CONTEXT_FP_SIZE + \
+ STACK_MINIMUM_SIZE + sizeof( RTEMS_API_Control ) + \
+ CONFIGURE_OBJECT_TABLE_STUFF)) \
+ )
+
+#define CONFIGURE_MEMORY_FOR_TIMERS(_timers) \
+ ((_timers) * ( sizeof(Timer_Control) + CONFIGURE_OBJECT_TABLE_STUFF ) )
+
+#define CONFIGURE_MEMORY_FOR_SEMAPHORES(_semaphores) \
+ ((_semaphores) * \
+ ( sizeof(Semaphore_Control) + CONFIGURE_OBJECT_TABLE_STUFF ) )
+
+#define CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(_queues) \
+ ( (_queues) * \
+ ( sizeof(Message_queue_Control) + CONFIGURE_OBJECT_TABLE_STUFF ) )
+
+#define CONFIGURE_MEMORY_FOR_PARTITIONS(_partitions) \
+ ( (_partitions) * \
+ ( sizeof(Partition_Control) + CONFIGURE_OBJECT_TABLE_STUFF ) )
+
+#define CONFIGURE_MEMORY_FOR_REGIONS(_regions) \
+ ( (_regions) * \
+ ( sizeof(Region_Control) + CONFIGURE_OBJECT_TABLE_STUFF ) )
+
+#define CONFIGURE_MEMORY_FOR_PORTS(_ports) \
+ ( (_ports) * \
+ ( sizeof(Dual_ported_memory_Control) + CONFIGURE_OBJECT_TABLE_STUFF ) )
+
+#define CONFIGURE_MEMORY_FOR_PERIODS(_periods) \
+ ( (_periods) * \
+ ( sizeof(Rate_monotonic_Control) + CONFIGURE_OBJECT_TABLE_STUFF ) )
+
+#define CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(_extensions) \
+ ( (_extensions) * \
+ ( sizeof(Extension_Control) + CONFIGURE_OBJECT_TABLE_STUFF ) )
+
+#define CONFIGURE_MEMORY_FOR_DEVICES(_devices) \
+ (((_devices) + 1) * ( sizeof(rtems_driver_name_t) ) )
+
+#ifdef CONFIGURE_MPTEST
+
+#ifndef CONFIGURE_HAS_OWN_MULTIPROCESING_TABLE
+
+#define CONFIGURE_MEMORY_FOR_PROXIES(_proxies) \
+ ( ((_proxies) + 1) * ( sizeof(Thread_Proxy_control) ) )
+
+#define CONFIGURE_MEMORY_FOR_GLOBAL_OBJECTS(_global_objects) \
+ ((_global_objects) * ( sizeof(Objects_MP_Control) ) )
+
+#define CONFIGURE_MEMORY_FOR_MP \
+ ( CONFIGURE_MEMORY_FOR_PROXIES(CONFIGURE_MP_MAXIMUM_PROXIES) + \
+ CONFIGURE_MEMORY_FOR_GLOBAL_OBJECTS(CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS) \
+ )
+
+#endif /* CONFIGURE_HAS_OWN_MULTIPROCESING_TABLE */
+
+#else
+
+#define CONFIGURE_MEMORY_FOR_MP 0
+
+#endif
#define CONFIGURE_EXECUTIVE_RAM_SIZE \
-( (CONFIGURE_MEMORY_REQUIRED(CONFIGURE_MAXIMUM_TASKS) + (128*1024)) &0xffff0000)
+(( CONFIGURE_MEMORY_FOR_TASKS(CONFIGURE_MAXIMUM_TASKS) + \
+ CONFIGURE_MEMORY_FOR_TIMERS(CONFIGURE_MAXIMUM_TIMERS) + \
+ CONFIGURE_MEMORY_FOR_SEMAPHORES(CONFIGURE_MAXIMUM_SEMAPHORES) + \
+ CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(CONFIGURE_MAXIMUM_MESSAGE_QUEUES) + \
+ CONFIGURE_MEMORY_FOR_PARTITIONS(CONFIGURE_MAXIMUM_PARTITIONS) + \
+ CONFIGURE_MEMORY_FOR_REGIONS(CONFIGURE_MAXIMUM_REGIONS) + \
+ CONFIGURE_MEMORY_FOR_PORTS(CONFIGURE_MAXIMUM_PORTS) + \
+ CONFIGURE_MEMORY_FOR_PERIODS(CONFIGURE_MAXIMUM_PERIODS) + \
+ CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(CONFIGURE_MAXIMUM_USER_EXTENSIONS) + \
+ CONFIGURE_MEMORY_FOR_DEVICES(CONFIGURE_MAXIMUM_DEVICES) + \
+ CONFIGURE_MEMORY_FOR_MP + \
+ (96*1024) \
+) & 0xffff8000)
#endif
#ifdef CONFIGURE_INIT
diff --git a/cpukit/score/cpu/hppa1.1/cpu.c b/cpukit/score/cpu/hppa1.1/cpu.c
index 6dee0c1225..ba70357a33 100644
--- a/cpukit/score/cpu/hppa1.1/cpu.c
+++ b/cpukit/score/cpu/hppa1.1/cpu.c
@@ -193,7 +193,7 @@ void _CPU_ISR_install_vector(
void
hppa_external_interrupt_initialize(void)
{
- hppa_rtems_isr_entry ignore;
+ hppa_rtems_isr_entry ignore = 0;
/* mark them all unused */
@@ -201,8 +201,11 @@ hppa_external_interrupt_initialize(void)
DISMISS(~0);
/* install the external interrupt handler */
- rtems_interrupt_catch((rtems_isr_entry) hppa_external_interrupt,
- HPPA_INTERRUPT_EXTERNAL_INTERRUPT, &ignore) ;
+ _CPU_ISR_install_vector(
+ HPPA_INTERRUPT_EXTERNAL_INTERRUPT,
+ (proc_ptr)hppa_external_interrupt,
+ (proc_ptr *)ignore
+ );
}
/*
diff --git a/cpukit/score/cpu/i386/cpu.c b/cpukit/score/cpu/i386/cpu.c
index 446515d6f9..73108e66d1 100644
--- a/cpukit/score/cpu/i386/cpu.c
+++ b/cpukit/score/cpu/i386/cpu.c
@@ -34,7 +34,7 @@ void _CPU_Initialize(
)
{
register unsigned16 fp_status asm ("ax");
- register unsigned8 *fp_context;
+ register void *fp_context;
_CPU_Table = *cpu_table;
@@ -56,7 +56,7 @@ void _CPU_Initialize(
if ( fp_status == 0 ) {
- fp_context = _CPU_Null_fp_context;
+ fp_context = &_CPU_Null_fp_context;
asm volatile( "fsave (%0)" : "=r" (fp_context)
: "0" (fp_context)
diff --git a/cpukit/score/cpu/unix/cpu.c b/cpukit/score/cpu/unix/cpu.c
index 339bb2a3ce..a1994da5ae 100644
--- a/cpukit/score/cpu/unix/cpu.c
+++ b/cpukit/score/cpu/unix/cpu.c
@@ -1,5 +1,5 @@
/*
- * HP PA-RISC CPU Dependent Source
+ * UNIX Simulator Dependent Source
*
*
* To anyone who acknowledges that this file is provided "AS IS"
@@ -18,6 +18,7 @@
#include <rtems/system.h>
#include <rtems/core/isr.h>
+#include <rtems/core/interr.h>
#include <stdio.h>
#include <stdlib.h>
@@ -169,21 +170,16 @@ void _CPU_Context_From_CPU_Init()
*/
_CPU_ISR_Set_level( 0 );
- setjmp( _CPU_Context_Default_with_ISRs_enabled.regs );
- sigprocmask(
- SIG_SETMASK, /* ignored when second arg is NULL */
- 0,
- &_CPU_Context_Default_with_ISRs_enabled.isr_level
+ _CPU_Context_switch(
+ &_CPU_Context_Default_with_ISRs_enabled,
+ &_CPU_Context_Default_with_ISRs_enabled
);
_CPU_ISR_Set_level( 1 );
- setjmp( _CPU_Context_Default_with_ISRs_disabled.regs );
- sigprocmask(
- SIG_SETMASK, /* ignored when second arg is NULL */
- 0,
- &_CPU_Context_Default_with_ISRs_disabled.isr_level
+ _CPU_Context_switch(
+ &_CPU_Context_Default_with_ISRs_disabled,
+ &_CPU_Context_Default_with_ISRs_disabled
);
-
}
/*PAGE
@@ -191,21 +187,21 @@ void _CPU_Context_From_CPU_Init()
* _CPU_ISR_Get_level
*/
+sigset_t GET_old_mask;
+
unsigned32 _CPU_ISR_Get_level( void )
{
- sigset_t sigset;
+/* sigset_t old_mask; */
+ unsigned32 old_level;
- sigprocmask( 0, 0, &sigset );
-
- /*
- * This is an educated guess based on ONLY ONE of the signals we
- * disable/enable to mask ISRs.
- */
+ sigprocmask(0, 0, &GET_old_mask);
+
+ if (memcmp((void *)&posix_empty_mask, (void *)&GET_old_mask, sizeof(sigset_t)))
+ old_level = 1;
+ else
+ old_level = 0;
- if ( sigismember( &sigset, SIGUSR1 ) )
- return 1;
- else
- return 0;
+ return old_level;
}
/* _CPU_Initialize
@@ -383,7 +379,7 @@ void _CPU_Context_Initialize(
else
source = _CPU_Context_Default_with_ISRs_disabled.regs;
- memcpy(_the_context, source, sizeof(jmp_buf));
+ memcpy(_the_context, source, sizeof(Context_Control) ); /* sizeof(jmp_buf)); */
addr = (unsigned32 *)_the_context;
@@ -470,15 +466,30 @@ void _CPU_Context_switch(
Context_Control *next
)
{
+ int status;
+
/*
* Switch levels in one operation
*/
- sigprocmask( SIG_SETMASK, &next->isr_level, &current->isr_level );
+ status = sigprocmask( SIG_SETMASK, &next->isr_level, &current->isr_level );
+ if ( status )
+ _Internal_error_Occurred(
+ INTERNAL_ERROR_CORE,
+ TRUE,
+ status
+ );
if (setjmp(current->regs) == 0) { /* Save the current context */
longjmp(next->regs, 0); /* Switch to the new context */
+ if ( status )
+ _Internal_error_Occurred(
+ INTERNAL_ERROR_CORE,
+ TRUE,
+ status
+ );
}
+
}
/*PAGE
@@ -510,11 +521,18 @@ void _CPU_Restore_float_context(
unsigned32 _CPU_ISR_Disable_support(void)
{
+ int status;
sigset_t old_mask;
- sigprocmask(SIG_BLOCK, &_CPU_Signal_mask, &old_mask);
+ status = sigprocmask(SIG_BLOCK, &_CPU_Signal_mask, &old_mask);
+ if ( status )
+ _Internal_error_Occurred(
+ INTERNAL_ERROR_CORE,
+ TRUE,
+ status
+ );
- if (memcmp((void *)&posix_empty_mask, (void *)&old_mask, sizeof(sigset_t)) != 0)
+ if (memcmp((void *)&posix_empty_mask, (void *)&old_mask, sizeof(sigset_t)))
return 1;
return 0;
@@ -529,10 +547,19 @@ void _CPU_ISR_Enable(
unsigned32 level
)
{
+ int status;
+
if (level == 0)
- sigprocmask(SIG_UNBLOCK, &_CPU_Signal_mask, 0);
+ status = sigprocmask(SIG_UNBLOCK, &_CPU_Signal_mask, 0);
else
- sigprocmask(SIG_BLOCK, &_CPU_Signal_mask, 0);
+ status = sigprocmask(SIG_BLOCK, &_CPU_Signal_mask, 0);
+
+ if ( status )
+ _Internal_error_Occurred(
+ INTERNAL_ERROR_CORE,
+ TRUE,
+ status
+ );
}
/*PAGE
diff --git a/cpukit/score/include/rtems/score/coremsg.h b/cpukit/score/include/rtems/score/coremsg.h
new file mode 100644
index 0000000000..109d792c78
--- /dev/null
+++ b/cpukit/score/include/rtems/score/coremsg.h
@@ -0,0 +1,408 @@
+/* coremsg.h
+ *
+ * This include file contains all the constants and structures associated
+ * with the Message queue Handler.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#ifndef __RTEMS_CORE_MESSAGE_QUEUE_h
+#define __RTEMS_CORE_MESSAGE_QUEUE_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/core/thread.h>
+#include <rtems/core/threadq.h>
+#include <rtems/core/priority.h>
+#include <rtems/core/watchdog.h>
+
+/*
+ * The following type defines the callout which the API provides
+ * to support global/multiprocessor operations on message_queues.
+ */
+
+typedef void ( *CORE_message_queue_API_mp_support_callout )(
+ Thread_Control *,
+ Objects_Id
+ );
+
+/*
+ * The following defines the data types needed to manipulate
+ * the contents of message buffers.
+ * Since msgs are variable length we just make a ptr to 1.
+ */
+
+typedef struct {
+ unsigned32 size;
+
+#ifndef __cplusplus
+ /* NOTE: [0] is gcc specific,
+ * but specifically disallowed by ANSI STD C++
+ * g++ warns about it, so we #ifdef it out to
+ * get rid of warnings when compiled by g++.
+ */
+ unsigned32 buffer[0];
+#endif
+
+} CORE_message_queue_Buffer;
+
+/*
+ * The following records define the organization of a message
+ * buffer.
+ */
+
+typedef struct {
+ Chain_Node Node;
+ CORE_message_queue_Buffer Contents;
+} CORE_message_queue_Buffer_control;
+
+/*
+ * Blocking disciplines for a message_queue.
+ */
+
+typedef enum {
+ CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO,
+ CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY
+} CORE_message_queue_Disciplines;
+
+/*
+ * The following enumerated type details the modes in which a message
+ * may be submitted to a message queue. The message may be posted
+ * in a send or urgent fashion.
+ */
+
+typedef enum {
+ CORE_MESSAGE_QUEUE_SEND_REQUEST = 0,
+ CORE_MESSAGE_QUEUE_URGENT_REQUEST = 1
+} CORE_message_queue_Submit_types;
+
+/*
+ * Core Message queue handler return statuses.
+ */
+
+typedef enum {
+ CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL,
+ CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE,
+ CORE_MESSAGE_QUEUE_STATUS_TOO_MANY,
+ CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED,
+ CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT,
+ CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED,
+ CORE_MESSAGE_QUEUE_STATUS_TIMEOUT
+} CORE_message_queue_Status;
+
+/*
+ * The following defines the control block used to manage the
+ * attributes of each message queue.
+ */
+
+typedef struct {
+ CORE_message_queue_Disciplines discipline;
+} CORE_message_queue_Attributes;
+
+/*
+ * The following defines the control block used to manage each
+ * counting message_queue.
+ */
+
+typedef struct {
+ Thread_queue_Control Wait_queue;
+ CORE_message_queue_Attributes Attributes;
+ unsigned32 maximum_pending_messages;
+ unsigned32 number_of_pending_messages;
+ unsigned32 maximum_message_size;
+ Chain_Control Pending_messages;
+ CORE_message_queue_Buffer *message_buffers;
+ Chain_Control Inactive_messages;
+} CORE_message_queue_Control;
+
+/*
+ * _CORE_message_queue_Initialize
+ *
+ * DESCRIPTION:
+ *
+ * This routine initializes the message_queue based on the parameters passed.
+ */
+
+boolean _CORE_message_queue_Initialize(
+ CORE_message_queue_Control *the_message_queue,
+ Objects_Classes the_class,
+ CORE_message_queue_Attributes *the_message_queue_attributes,
+ unsigned32 maximum_pending_messages,
+ unsigned32 maximum_message_size,
+ Thread_queue_Extract_callout proxy_extract_callout
+);
+
+/*
+ * _CORE_message_queue_Close
+ *
+ * DESCRIPTION:
+ *
+ * This function closes a message by returning all allocated space and
+ * flushing the message_queue's task wait queue.
+ */
+
+void _CORE_message_queue_Close(
+ CORE_message_queue_Control *the_message_queue,
+ Thread_queue_Flush_callout remote_extract_callout,
+ unsigned32 status
+);
+
+/*
+ *
+ * _CORE_message_queue_Flush
+ *
+ * DESCRIPTION:
+ *
+ * This function flushes the message_queue's task wait queue. The number
+ * messages flushed from the queue is returned.
+ *
+ */
+
+unsigned32 _CORE_message_queue_Flush(
+ CORE_message_queue_Control *the_message_queue
+);
+
+/*
+ * _CORE_message_queue_Flush_support
+ *
+ * DESCRIPTION:
+ *
+ * This routine flushes all outstanding messages and returns
+ * them to the inactive message chain.
+ */
+
+unsigned32 _CORE_message_queue_Flush_support(
+ CORE_message_queue_Control *the_message_queue
+);
+
+/*
+ * _CORE_message_queue_send
+ *
+ * DESCRIPTION:
+ *
+ * This routine sends a message to the end of the specified message queue.
+ *
+ */
+
+STATIC INLINE CORE_message_queue_Status _CORE_message_queue_Send(
+ CORE_message_queue_Control *the_message_queue,
+ void *buffer,
+ unsigned32 size,
+ Objects_Id id,
+ CORE_message_queue_API_mp_support_callout api_message_queue_mp_support
+);
+
+/*
+ *
+ * _CORE_message_queue_Urgent
+ *
+ * DESCRIPTION:
+ *
+ * This routine sends a message to the front of the specified message queue.
+ *
+ */
+
+STATIC INLINE CORE_message_queue_Status _CORE_message_queue_Urgent(
+ CORE_message_queue_Control *the_message_queue,
+ void *buffer,
+ unsigned32 size,
+ Objects_Id id,
+ CORE_message_queue_API_mp_support_callout api_message_queue_mp_support
+);
+
+/*
+ *
+ * _CORE_message_queue_Broadcast
+ *
+ * DESCRIPTION:
+ *
+ * This function sends a message for every thread waiting on the queue and
+ * returns the number of threads made ready by the message.
+ *
+ */
+
+CORE_message_queue_Status _CORE_message_queue_Broadcast(
+ CORE_message_queue_Control *the_message_queue,
+ void *buffer,
+ unsigned32 size,
+ Objects_Id id,
+ CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
+ unsigned32 *count
+);
+
+/*
+ *
+ * _CORE_message_queue_Submit
+ *
+ * DESCRIPTION:
+ *
+ * This routine implements the send and urgent message functions. It
+ * processes a message that is to be submitted to the designated
+ * message queue. The message will either be processed as a
+ * 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.
+ *
+ */
+
+CORE_message_queue_Status _CORE_message_queue_Submit(
+ CORE_message_queue_Control *the_message_queue,
+ void *buffer,
+ unsigned32 size,
+ Objects_Id id,
+ CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
+ CORE_message_queue_Submit_types submit_type
+);
+
+/*
+ *
+ * _CORE_message_queue_Seize
+ *
+ * DESCRIPTION:
+ *
+ * This kernel routine dequeues a message, copies the message buffer to
+ * a given destination buffer, and frees the message buffer to the
+ * inactive message pool. The thread will be blocked if wait is TRUE,
+ * otherwise an error will be given to the thread if no messages are available.
+ *
+ */
+
+void _CORE_message_queue_Seize(
+ CORE_message_queue_Control *the_message_queue,
+ Objects_Id id,
+ void *buffer,
+ unsigned32 *size,
+ boolean wait,
+ Watchdog_Interval timeout
+);
+
+/*
+ * _CORE_message_queue_Allocate_message_buffer
+ *
+ * DESCRIPTION:
+ *
+ * This function allocates a message buffer from the inactive
+ * message buffer chain.
+ */
+
+STATIC INLINE CORE_message_queue_Buffer_control *
+ _CORE_message_queue_Allocate_message_buffer (
+ CORE_message_queue_Control *the_message_queue
+);
+
+/*
+ * _CORE_message_queue_Free_message_buffer
+ *
+ * DESCRIPTION:
+ *
+ * This routine frees a message buffer to the inactive
+ * message buffer chain.
+ */
+
+STATIC INLINE void _CORE_message_queue_Free_message_buffer (
+ CORE_message_queue_Control *the_message_queue,
+ CORE_message_queue_Buffer_control *the_message
+);
+
+/*
+ * _CORE_message_queue_Copy_buffer
+ *
+ * DESCRIPTION:
+ *
+ * This routine copies the contents of the source message buffer
+ * to the destination message buffer.
+ */
+
+STATIC INLINE void _CORE_message_queue_Copy_buffer (
+ void *source,
+ void *destination,
+ unsigned32 size
+);
+
+/*
+ * _CORE_message_queue_Get_pending_message
+ *
+ * DESCRIPTION:
+ *
+ * This function removes the first message from the_message_queue
+ * and returns a pointer to it.
+ */
+
+STATIC INLINE
+ CORE_message_queue_Buffer_control *_CORE_message_queue_Get_pending_message (
+ CORE_message_queue_Control *the_message_queue
+);
+
+/*
+ * _CORE_message_queue_Is_priority
+ *
+ * DESCRIPTION:
+ *
+ * This function returns TRUE if the priority attribute is
+ * enabled in the attribute_set and FALSE otherwise.
+ */
+
+STATIC INLINE boolean _CORE_message_queue_Is_priority(
+ CORE_message_queue_Attributes *the_attribute
+);
+
+/*
+ * _CORE_message_queue_Append
+ *
+ * DESCRIPTION:
+ *
+ * This routine places the_message at the rear of the outstanding
+ * messages on the_message_queue.
+ */
+
+STATIC INLINE void _CORE_message_queue_Append (
+ CORE_message_queue_Control *the_message_queue,
+ CORE_message_queue_Buffer_control *the_message
+);
+
+/*
+ * _CORE_message_queue_Prepend
+ *
+ * DESCRIPTION:
+ *
+ * This routine places the_message at the rear of the outstanding
+ * messages on the_message_queue.
+ */
+
+STATIC INLINE void _CORE_message_queue_Prepend (
+ CORE_message_queue_Control *the_message_queue,
+ CORE_message_queue_Buffer_control *the_message
+);
+
+/*
+ * _CORE_message_queue_Is_null
+ *
+ * DESCRIPTION:
+ *
+ * This function places the_message at the rear of the outstanding
+ * messages on the_message_queue.
+ */
+
+STATIC INLINE boolean _CORE_message_queue_Is_null (
+ CORE_message_queue_Control *the_message_queue
+);
+
+#include <rtems/core/coremsg.inl>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
+
diff --git a/cpukit/score/inline/rtems/score/coremsg.inl b/cpukit/score/inline/rtems/score/coremsg.inl
new file mode 100644
index 0000000000..d1b5429947
--- /dev/null
+++ b/cpukit/score/inline/rtems/score/coremsg.inl
@@ -0,0 +1,186 @@
+/* coremsg.inl
+ *
+ * This include file contains the static inline implementation of all
+ * inlined routines in the Core Message Handler.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#ifndef __CORE_MESSAGE_QUEUE_inl
+#define __CORE_MESSAGE_QUEUE_inl
+
+/*PAGE
+ *
+ * _CORE_message_queue_Send
+ *
+ */
+
+STATIC INLINE CORE_message_queue_Status _CORE_message_queue_Send(
+ CORE_message_queue_Control *the_message_queue,
+ void *buffer,
+ unsigned32 size,
+ Objects_Id id,
+ CORE_message_queue_API_mp_support_callout api_message_queue_mp_support
+)
+{
+ return _CORE_message_queue_Submit(
+ the_message_queue,
+ buffer,
+ size,
+ id,
+ api_message_queue_mp_support,
+ CORE_MESSAGE_QUEUE_SEND_REQUEST
+ );
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Urgent
+ *
+ */
+
+STATIC INLINE CORE_message_queue_Status _CORE_message_queue_Urgent(
+ CORE_message_queue_Control *the_message_queue,
+ void *buffer,
+ unsigned32 size,
+ Objects_Id id,
+ CORE_message_queue_API_mp_support_callout api_message_queue_mp_support
+)
+{
+ return _CORE_message_queue_Submit(
+ the_message_queue,
+ buffer,
+ size,
+ id,
+ api_message_queue_mp_support,
+ CORE_MESSAGE_QUEUE_URGENT_REQUEST
+ );
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Copy_buffer
+ *
+ */
+
+STATIC INLINE void _CORE_message_queue_Copy_buffer (
+ void *source,
+ void *destination,
+ unsigned32 size
+)
+{
+ memcpy(destination, source, size);
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Allocate_message_buffer
+ *
+ */
+
+STATIC INLINE CORE_message_queue_Buffer_control *
+_CORE_message_queue_Allocate_message_buffer (
+ CORE_message_queue_Control *the_message_queue
+)
+{
+ return (CORE_message_queue_Buffer_control *)
+ _Chain_Get( &the_message_queue->Inactive_messages );
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Free_message_buffer
+ *
+ */
+
+STATIC INLINE void _CORE_message_queue_Free_message_buffer (
+ CORE_message_queue_Control *the_message_queue,
+ CORE_message_queue_Buffer_control *the_message
+)
+{
+ _Chain_Append( &the_message_queue->Inactive_messages, &the_message->Node );
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Get_pending_message
+ *
+ */
+
+STATIC INLINE
+ CORE_message_queue_Buffer_control *_CORE_message_queue_Get_pending_message (
+ CORE_message_queue_Control *the_message_queue
+)
+{
+ return (CORE_message_queue_Buffer_control *)
+ _Chain_Get_unprotected( &the_message_queue->Pending_messages );
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Is_priority
+ *
+ */
+
+STATIC INLINE boolean _CORE_message_queue_Is_priority(
+ CORE_message_queue_Attributes *the_attribute
+)
+{
+ return (the_attribute->discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY);
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Append
+ *
+ */
+
+STATIC INLINE void _CORE_message_queue_Append (
+ CORE_message_queue_Control *the_message_queue,
+ CORE_message_queue_Buffer_control *the_message
+)
+{
+ _Chain_Append( &the_message_queue->Pending_messages, &the_message->Node );
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Prepend
+ *
+ */
+
+STATIC INLINE void _CORE_message_queue_Prepend (
+ CORE_message_queue_Control *the_message_queue,
+ CORE_message_queue_Buffer_control *the_message
+)
+{
+ _Chain_Prepend(
+ &the_message_queue->Pending_messages,
+ &the_message->Node
+ );
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Is_null
+ *
+ */
+
+STATIC INLINE boolean _CORE_message_queue_Is_null (
+ CORE_message_queue_Control *the_message_queue
+)
+{
+ return ( the_message_queue == NULL );
+}
+
+
+#endif
+/* end of include file */
diff --git a/cpukit/score/macros/rtems/score/coremsg.inl b/cpukit/score/macros/rtems/score/coremsg.inl
new file mode 100644
index 0000000000..877d737afd
--- /dev/null
+++ b/cpukit/score/macros/rtems/score/coremsg.inl
@@ -0,0 +1,121 @@
+/* coremsg.inl
+ *
+ * This include file contains the macro implementation of all
+ * inlined routines in the Core Message Handler.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#ifndef __CORE_MESSAGE_QUEUE_inl
+#define __CORE_MESSAGE_QUEUE_inl
+
+/*PAGE
+ *
+ * _CORE_message_queue_Send
+ *
+ */
+
+#define _CORE_message_queue_Send( _the_message_queue, _buffer, _size, \
+_id, _api_message_queue_mp_support ) \
+ _CORE_message_queue_Submit( (_the_message_queue), (_buffer), (_size), \
+ (_id), (_api_message_queue_mp_support), CORE_MESSAGE_QUEUE_SEND_REQUEST )
+
+/*PAGE
+ *
+ * _CORE_message_queue_Urgent
+ *
+ */
+
+#define _CORE_message_queue_Urgent( _the_message_queue, _buffer, _size, \
+_id, _api_message_queue_mp_support ) \
+ _CORE_message_queue_Submit( (_the_message_queue), (_buffer), (_size), \
+ (_id), (_api_message_queue_mp_support), CORE_MESSAGE_QUEUE_URGENT_REQUEST )
+
+/*PAGE
+ *
+ * _CORE_message_queue_Copy_buffer
+ */
+
+#define _CORE_message_queue_Copy_buffer( _source, _destination, _size ) \
+ memcpy( _destination, _source, _size)
+
+/*PAGE
+ *
+ * _CORE_message_queue_Allocate_message_buffer
+ *
+ */
+
+#define _CORE_message_queue_Allocate_message_buffer( _the_message_queue ) \
+ (CORE_message_queue_Buffer_control *) \
+ _Chain_Get( &(_the_message_queue)->Inactive_messages )
+
+/*PAGE
+ *
+ * _CORE_message_queue_Free_message_buffer
+ *
+ */
+
+#define _CORE_message_queue_Free_message_buffer( _the_message_queue, _the_message ) \
+ _Chain_Append( \
+ &(_the_message_queue)->Inactive_messages, \
+ &(_the_message)->Node \
+ )
+
+/*PAGE
+ *
+ * _CORE_message_queue_Is_priority
+ *
+ */
+
+#define _CORE_message_queue_Is_priority( _the_attribute ) \
+ ((_the_attribute)->discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY)
+
+/*PAGE
+ *
+ * _CORE_message_queue_Get_pending_message
+ *
+ */
+
+#define _CORE_message_queue_Get_pending_message( _the_message_queue ) \
+ (CORE_message_queue_Buffer_control *) \
+ _Chain_Get_unprotected( &(_the_message_queue)->Pending_messages )
+
+/*PAGE
+ *
+ * _CORE_message_queue_Append
+ *
+ */
+
+#define _CORE_message_queue_Append( _the_message_queue, _the_message ) \
+ _Chain_Append( &(_the_message_queue)->Pending_messages, \
+ &(_the_message)->Node )
+
+/*PAGE
+ *
+ * _CORE_message_queue_Prepend
+ *
+ */
+
+#define _CORE_message_queue_Prepend( _the_message_queue, _the_message ) \
+ _Chain_Prepend( &(_the_message_queue)->Pending_messages, \
+ &(_the_message)->Node )
+
+/*PAGE
+ *
+ * _CORE_message_queue_Is_null
+ *
+ */
+
+#define _CORE_message_queue_Is_null( _the_message_queue ) \
+ ( (_the_message_queue) == NULL )
+
+#endif
+/* end of include file */
diff --git a/cpukit/score/src/coremsg.c b/cpukit/score/src/coremsg.c
new file mode 100644
index 0000000000..2ce0587b5f
--- /dev/null
+++ b/cpukit/score/src/coremsg.c
@@ -0,0 +1,436 @@
+/*
+ * CORE Message Queue Handler
+ *
+ * DESCRIPTION:
+ *
+ * This package is the implementation of the CORE Message Queue Handler.
+ * This core object provides task synchronization and communication functions
+ * via messages passed to queue objects.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems/system.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/attr.h>
+#include <rtems/core/chain.h>
+#include <rtems/core/isr.h>
+#include <rtems/rtems/message.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/options.h>
+#include <rtems/core/states.h>
+#include <rtems/rtems/support.h>
+#include <rtems/core/thread.h>
+#include <rtems/core/wkspace.h>
+#include <rtems/core/mpci.h>
+#include <rtems/sysstate.h>
+
+/*PAGE
+ *
+ * _CORE_message_queue_Initialize
+ *
+ * This routine initializes a newly created message queue based on the
+ * specified data.
+ *
+ * Input parameters:
+ * the_message_queue - the message queue to initialize
+ * the_class - the API specific object class
+ * the_message_queue_attributes - the message queue's attributes
+ * maximum_pending_messages - maximum message and reserved buffer count
+ * maximum_message_size - maximum size of each message
+ * proxy_extract_callout - remote extract support
+ *
+ * Output parameters:
+ * TRUE - if the message queue is initialized
+ * FALSE - if the message queue is NOT initialized
+ */
+
+boolean _CORE_message_queue_Initialize(
+ CORE_message_queue_Control *the_message_queue,
+ Objects_Classes the_class,
+ CORE_message_queue_Attributes *the_message_queue_attributes,
+ unsigned32 maximum_pending_messages,
+ unsigned32 maximum_message_size,
+ Thread_queue_Extract_callout proxy_extract_callout
+)
+{
+ unsigned32 message_buffering_required;
+ unsigned32 allocated_message_size;
+
+ the_message_queue->maximum_pending_messages = maximum_pending_messages;
+ the_message_queue->number_of_pending_messages = 0;
+ the_message_queue->maximum_message_size = maximum_message_size;
+
+ /*
+ * round size up to multiple of a ptr for chain init
+ */
+
+ allocated_message_size = maximum_message_size;
+ if (allocated_message_size & (sizeof(unsigned32) - 1)) {
+ allocated_message_size += sizeof(unsigned32);
+ allocated_message_size &= ~(sizeof(unsigned32) - 1);
+ }
+
+ message_buffering_required = maximum_pending_messages *
+ (allocated_message_size + sizeof(CORE_message_queue_Buffer_control));
+
+ the_message_queue->message_buffers = (CORE_message_queue_Buffer *)
+ _Workspace_Allocate( message_buffering_required );
+
+ if (the_message_queue->message_buffers == 0)
+ return FALSE;
+
+ _Chain_Initialize (
+ &the_message_queue->Inactive_messages,
+ the_message_queue->message_buffers,
+ maximum_pending_messages,
+ allocated_message_size + sizeof( CORE_message_queue_Buffer_control )
+ );
+
+ _Chain_Initialize_empty( &the_message_queue->Pending_messages );
+
+ _Thread_queue_Initialize(
+ &the_message_queue->Wait_queue,
+ the_class,
+ _CORE_message_queue_Is_priority( the_message_queue_attributes ) ?
+ THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO,
+ STATES_WAITING_FOR_MESSAGE,
+ proxy_extract_callout,
+ CORE_MESSAGE_QUEUE_STATUS_TIMEOUT
+ );
+
+ return TRUE;
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Close
+ *
+ * This function closes a message by returning all allocated space and
+ * flushing the message_queue's task wait queue.
+ *
+ * Input parameters:
+ * the_message_queue - the message_queue to be flushed
+ * remote_extract_callout - function to invoke remotely
+ * status - status to pass to thread
+ *
+ * Output parameters: NONE
+ */
+
+void _CORE_message_queue_Close(
+ CORE_message_queue_Control *the_message_queue,
+ Thread_queue_Flush_callout remote_extract_callout,
+ unsigned32 status
+)
+{
+
+ if ( the_message_queue->number_of_pending_messages != 0 )
+ (void) _CORE_message_queue_Flush_support( the_message_queue );
+ else
+ _Thread_queue_Flush(
+ &the_message_queue->Wait_queue,
+ remote_extract_callout,
+ status
+ );
+
+ (void) _Workspace_Free( the_message_queue->message_buffers );
+
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Flush
+ *
+ * This function flushes the message_queue's task wait queue. The number
+ * of messages flushed from the queue is returned.
+ *
+ * Input parameters:
+ * the_message_queue - the message_queue to be flushed
+ *
+ * Output parameters:
+ * returns - the number of messages flushed from the queue
+ */
+
+unsigned32 _CORE_message_queue_Flush(
+ CORE_message_queue_Control *the_message_queue
+)
+{
+ if ( the_message_queue->number_of_pending_messages != 0 )
+ return _CORE_message_queue_Flush_support( the_message_queue );
+ else
+ return 0;
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Broadcast
+ *
+ * This function sends a message for every thread waiting on the queue and
+ * returns the number of threads made ready by the message.
+ *
+ * Input parameters:
+ * the_message_queue - message is submitted to this message queue
+ * buffer - pointer to message buffer
+ * size - size in bytes of message to send
+ * id - id of message queue
+ * api_message_queue_mp_support - api specific mp support callout
+ * count - area to store number of threads made ready
+ *
+ * Output parameters:
+ * count - number of threads made ready
+ * CORE_MESSAGE_QUEUE_SUCCESSFUL - if successful
+ * error code - if unsuccessful
+ */
+
+CORE_message_queue_Status _CORE_message_queue_Broadcast(
+ CORE_message_queue_Control *the_message_queue,
+ void *buffer,
+ unsigned32 size,
+ Objects_Id id,
+ CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
+ unsigned32 *count
+)
+{
+ Thread_Control *the_thread;
+ unsigned32 number_broadcasted;
+ Thread_Wait_information *waitp;
+ unsigned32 constrained_size;
+
+ number_broadcasted = 0;
+ while ((the_thread = _Thread_queue_Dequeue(&the_message_queue->Wait_queue))) {
+ waitp = &the_thread->Wait;
+ number_broadcasted += 1;
+
+ constrained_size = size;
+ if ( size > the_message_queue->maximum_message_size )
+ constrained_size = the_message_queue->maximum_message_size;
+
+ _CORE_message_queue_Copy_buffer(
+ buffer,
+ waitp->return_argument,
+ constrained_size
+ );
+
+ *(rtems_unsigned32 *)the_thread->Wait.return_argument_1 = size;
+
+ if ( !_Objects_Is_local_id( the_thread->Object.id ) )
+ (*api_message_queue_mp_support) ( the_thread, id );
+
+ }
+ *count = number_broadcasted;
+ return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Seize
+ *
+ * This kernel routine dequeues a message, copies the message buffer to
+ * a given destination buffer, and frees the message buffer to the
+ * inactive message pool. The thread will be blocked if wait is TRUE,
+ * otherwise an error will be given to the thread if no messages are available.
+ *
+ * Input parameters:
+ * the_message_queue - pointer to message queue
+ * id - id of object we are waitig on
+ * buffer - pointer to message buffer to be filled
+ * size - pointer to the size of buffer to be filled
+ * wait - TRUE if wait is allowed, FALSE otherwise
+ * timeout - time to wait for a message
+ *
+ * Output parameters: NONE
+ *
+ * NOTE: Dependent on BUFFER_LENGTH
+ *
+ * INTERRUPT LATENCY:
+ * available
+ * wait
+ */
+
+void _CORE_message_queue_Seize(
+ CORE_message_queue_Control *the_message_queue,
+ Objects_Id id,
+ void *buffer,
+ unsigned32 *size,
+ boolean wait,
+ Watchdog_Interval timeout
+)
+{
+ ISR_Level level;
+ CORE_message_queue_Buffer_control *the_message;
+ Thread_Control *executing;
+
+ executing = _Thread_Executing;
+ executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
+ _ISR_Disable( level );
+ if ( the_message_queue->number_of_pending_messages != 0 ) {
+ the_message_queue->number_of_pending_messages -= 1;
+
+ the_message = _CORE_message_queue_Get_pending_message( the_message_queue );
+ _ISR_Enable( level );
+ *size = the_message->Contents.size;
+ _CORE_message_queue_Copy_buffer(the_message->Contents.buffer,buffer,*size );
+ _CORE_message_queue_Free_message_buffer(the_message_queue, the_message );
+ return;
+ }
+
+ if ( !wait ) {
+ _ISR_Enable( level );
+ executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT;
+ return;
+ }
+
+ the_message_queue->Wait_queue.sync = TRUE;
+ executing->Wait.queue = &the_message_queue->Wait_queue;
+ executing->Wait.id = id;
+ executing->Wait.return_argument = (void *)buffer;
+ executing->Wait.return_argument_1 = (void *)size;
+ _ISR_Enable( level );
+
+ _Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout );
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Flush_support
+ *
+ * This message handler routine removes all messages from a message queue
+ * and returns them to the inactive message pool. The number of messages
+ * flushed from the queue is returned
+ *
+ * Input parameters:
+ * the_message_queue - pointer to message queue
+ *
+ * Output parameters:
+ * returns - number of messages placed on inactive chain
+ *
+ * INTERRUPT LATENCY:
+ * only case
+ */
+
+unsigned32 _CORE_message_queue_Flush_support(
+ CORE_message_queue_Control *the_message_queue
+)
+{
+ ISR_Level level;
+ Chain_Node *inactive_first;
+ Chain_Node *message_queue_first;
+ Chain_Node *message_queue_last;
+ unsigned32 count;
+
+ _ISR_Disable( level );
+ inactive_first = the_message_queue->Inactive_messages.first;
+ message_queue_first = the_message_queue->Pending_messages.first;
+ message_queue_last = the_message_queue->Pending_messages.last;
+
+ the_message_queue->Inactive_messages.first = message_queue_first;
+ message_queue_last->next = inactive_first;
+ inactive_first->previous = message_queue_last;
+ message_queue_first->previous =
+ _Chain_Head( &the_message_queue->Inactive_messages );
+
+ _Chain_Initialize_empty( &the_message_queue->Pending_messages );
+
+ count = the_message_queue->number_of_pending_messages;
+ the_message_queue->number_of_pending_messages = 0;
+ _ISR_Enable( level );
+ return count;
+}
+
+/*PAGE
+ *
+ * _CORE_message_queue_Submit
+ *
+ * This routine implements the send and urgent message functions. It
+ * processes a message that is to be submitted to the designated
+ * message queue. The message will either be processed as a
+ * 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:
+ * the_message_queue - message is submitted to this message queue
+ * buffer - pointer to message buffer
+ * size - size in bytes of message to send
+ * id - id of message queue
+ * api_message_queue_mp_support - api specific mp support callout
+ * submit_type - send or urgent message
+ *
+ * Output parameters:
+ * CORE_MESSAGE_QUEUE_SUCCESSFUL - if successful
+ * error code - if unsuccessful
+ */
+
+CORE_message_queue_Status _CORE_message_queue_Submit(
+ CORE_message_queue_Control *the_message_queue,
+ void *buffer,
+ unsigned32 size,
+ Objects_Id id,
+ CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
+ CORE_message_queue_Submit_types submit_type
+)
+{
+ CORE_message_queue_Buffer_control *the_message;
+ Thread_Control *the_thread;
+
+ if ( size > the_message_queue->maximum_message_size )
+ return CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE;
+
+ /*
+ * Is there a thread currently waiting on this message queue?
+ */
+
+ the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );
+ if ( the_thread )
+ {
+ _CORE_message_queue_Copy_buffer(
+ buffer,
+ the_thread->Wait.return_argument,
+ size
+ );
+ *(rtems_unsigned32 *)the_thread->Wait.return_argument_1 = size;
+
+ if ( !_Objects_Is_local_id( the_thread->Object.id ) )
+ (*api_message_queue_mp_support) ( the_thread, id );
+
+ return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
+ }
+
+ /*
+ * No one waiting on this one currently.
+ * Allocate a message buffer and store it away
+ */
+
+ if ( the_message_queue->number_of_pending_messages ==
+ the_message_queue->maximum_pending_messages ) {
+ return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY;
+ }
+
+ the_message = _CORE_message_queue_Allocate_message_buffer(the_message_queue);
+ if ( the_message == 0)
+ return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED;
+
+ _CORE_message_queue_Copy_buffer( buffer, the_message->Contents.buffer, size );
+ the_message->Contents.size = size;
+
+ the_message_queue->number_of_pending_messages += 1;
+
+ switch ( submit_type ) {
+ case CORE_MESSAGE_QUEUE_SEND_REQUEST:
+ _CORE_message_queue_Append( the_message_queue, the_message );
+ break;
+ case CORE_MESSAGE_QUEUE_URGENT_REQUEST:
+ _CORE_message_queue_Prepend( the_message_queue, the_message );
+ break;
+ }
+
+ return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
+}