summaryrefslogtreecommitdiffstats
path: root/c/src/exec/rtems
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 /c/src/exec/rtems
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 'c/src/exec/rtems')
-rw-r--r--c/src/exec/rtems/headers/message.h217
-rw-r--r--c/src/exec/rtems/headers/msgmp.h2
-rw-r--r--c/src/exec/rtems/include/rtems/rtems/message.h217
-rw-r--r--c/src/exec/rtems/include/rtems/rtems/msgmp.h2
-rw-r--r--c/src/exec/rtems/inline/message.inl95
-rw-r--r--c/src/exec/rtems/inline/rtems/rtems/message.inl95
-rw-r--r--c/src/exec/rtems/macros/message.inl74
-rw-r--r--c/src/exec/rtems/macros/rtems/rtems/message.inl74
-rw-r--r--c/src/exec/rtems/src/msg.c524
-rw-r--r--c/src/exec/rtems/src/msgmp.c10
-rw-r--r--c/src/exec/rtems/src/sem.c99
-rw-r--r--c/src/exec/rtems/src/tasks.c27
12 files changed, 361 insertions, 1075 deletions
diff --git a/c/src/exec/rtems/headers/message.h b/c/src/exec/rtems/headers/message.h
index 2ee910ac05..60592b5f3c 100644
--- a/c/src/exec/rtems/headers/message.h
+++ b/c/src/exec/rtems/headers/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/c/src/exec/rtems/headers/msgmp.h b/c/src/exec/rtems/headers/msgmp.h
index 592328678b..2cc6bc1367 100644
--- a/c/src/exec/rtems/headers/msgmp.h
+++ b/c/src/exec/rtems/headers/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/c/src/exec/rtems/include/rtems/rtems/message.h b/c/src/exec/rtems/include/rtems/rtems/message.h
index 2ee910ac05..60592b5f3c 100644
--- a/c/src/exec/rtems/include/rtems/rtems/message.h
+++ b/c/src/exec/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/c/src/exec/rtems/include/rtems/rtems/msgmp.h b/c/src/exec/rtems/include/rtems/rtems/msgmp.h
index 592328678b..2cc6bc1367 100644
--- a/c/src/exec/rtems/include/rtems/rtems/msgmp.h
+++ b/c/src/exec/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/c/src/exec/rtems/inline/message.inl b/c/src/exec/rtems/inline/message.inl
index 5b34ce5a83..114781293c 100644
--- a/c/src/exec/rtems/inline/message.inl
+++ b/c/src/exec/rtems/inline/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/c/src/exec/rtems/inline/rtems/rtems/message.inl b/c/src/exec/rtems/inline/rtems/rtems/message.inl
index 5b34ce5a83..114781293c 100644
--- a/c/src/exec/rtems/inline/rtems/rtems/message.inl
+++ b/c/src/exec/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/c/src/exec/rtems/macros/message.inl b/c/src/exec/rtems/macros/message.inl
index ef694fb11a..62b6ac0ceb 100644
--- a/c/src/exec/rtems/macros/message.inl
+++ b/c/src/exec/rtems/macros/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/c/src/exec/rtems/macros/rtems/rtems/message.inl b/c/src/exec/rtems/macros/rtems/rtems/message.inl
index ef694fb11a..62b6ac0ceb 100644
--- a/c/src/exec/rtems/macros/rtems/rtems/message.inl
+++ b/c/src/exec/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/c/src/exec/rtems/src/msg.c b/c/src/exec/rtems/src/msg.c
index a69ae777c6..36c6bd7a79 100644
--- a/c/src/exec/rtems/src/msg.c
+++ b/c/src/exec/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/c/src/exec/rtems/src/msgmp.c b/c/src/exec/rtems/src/msgmp.c
index 06afd4eedc..092886d272 100644
--- a/c/src/exec/rtems/src/msgmp.c
+++ b/c/src/exec/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/c/src/exec/rtems/src/sem.c b/c/src/exec/rtems/src/sem.c
index 9ba1634164..ca77005137 100644
--- a/c/src/exec/rtems/src/sem.c
+++ b/c/src/exec/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/c/src/exec/rtems/src/tasks.c b/c/src/exec/rtems/src/tasks.c
index 70ec7d6928..8906805164 100644
--- a/c/src/exec/rtems/src/tasks.c
+++ b/c/src/exec/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 );
}