diff options
Diffstat (limited to '')
151 files changed, 4659 insertions, 2168 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 ); } diff --git a/c/src/exec/sapi/headers/confdefs.h b/c/src/exec/sapi/headers/confdefs.h index 9939ba63ee..83f6c3ccd1 100644 --- a/c/src/exec/sapi/headers/confdefs.h +++ b/c/src/exec/sapi/headers/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/c/src/exec/sapi/include/confdefs.h b/c/src/exec/sapi/include/confdefs.h index 9939ba63ee..83f6c3ccd1 100644 --- a/c/src/exec/sapi/include/confdefs.h +++ b/c/src/exec/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/c/src/exec/score/cpu/hppa1.1/cpu.c b/c/src/exec/score/cpu/hppa1.1/cpu.c index 6dee0c1225..ba70357a33 100644 --- a/c/src/exec/score/cpu/hppa1.1/cpu.c +++ b/c/src/exec/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/c/src/exec/score/cpu/hppa1.1/cpu_asm.s b/c/src/exec/score/cpu/hppa1.1/cpu_asm.s index 229efed42c..7b9e940b77 100644 --- a/c/src/exec/score/cpu/hppa1.1/cpu_asm.s +++ b/c/src/exec/score/cpu/hppa1.1/cpu_asm.s @@ -24,7 +24,7 @@ # Division Incorporated makes no representations about the # suitability of this software for any purpose. # - * $Id$ +# $Id$ # #include <rtems/core/hppa.h> diff --git a/c/src/exec/score/cpu/hppa1.1/hppa.h b/c/src/exec/score/cpu/hppa1.1/hppa.h index 60bb854357..801a2edca2 100644 --- a/c/src/exec/score/cpu/hppa1.1/hppa.h +++ b/c/src/exec/score/cpu/hppa1.1/hppa.h @@ -636,7 +636,7 @@ get_ ## name (void) \ } #define EMIT_SET_CONTROL(name, reg) \ -static __inline__ unsigned int \ +static __inline__ void \ set_ ## name (unsigned int new_value) \ { \ HPPA_ASM_MTCTL(new_value, reg); \ diff --git a/c/src/exec/score/cpu/hppa1.1/rtems.s b/c/src/exec/score/cpu/hppa1.1/rtems.s index 0e9305644e..e59be60201 100644 --- a/c/src/exec/score/cpu/hppa1.1/rtems.s +++ b/c/src/exec/score/cpu/hppa1.1/rtems.s @@ -14,7 +14,7 @@ * $Id$ */ -#include <rtems/hppa.h> +#include <rtems/core/hppa.h> #include <rtems/core/cpu_asm.h> .SPACE $PRIVATE$ diff --git a/c/src/exec/score/cpu/i386/cpu.c b/c/src/exec/score/cpu/i386/cpu.c index 446515d6f9..73108e66d1 100644 --- a/c/src/exec/score/cpu/i386/cpu.c +++ b/c/src/exec/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/c/src/exec/score/cpu/i386/cpu.h b/c/src/exec/score/cpu/i386/cpu.h index f3793cd443..f173d0cdc7 100644 --- a/c/src/exec/score/cpu/i386/cpu.h +++ b/c/src/exec/score/cpu/i386/cpu.h @@ -147,11 +147,9 @@ EXTERN void *_CPU_Interrupt_stack_high; /* * Minimum size of a thread's stack. - * - * NOTE: 256 bytes is probably too low in most cases. */ -#define CPU_STACK_MINIMUM_SIZE 256 +#define CPU_STACK_MINIMUM_SIZE 1024 /* * i386 is pretty tolerant of alignment. Just put things on 4 byte boundaries. @@ -232,8 +230,8 @@ unsigned32 _CPU_ISR_Get_level( void ); #define _CPU_Context_Initialize_fp( _fp_area ) \ { \ - unsigned32 *_source = (unsigned32 *) _CPU_Null_fp_context; \ - unsigned32 *_destination = (unsigned32 *) *(_fp_area); \ + unsigned32 *_source = (unsigned32 *) &_CPU_Null_fp_context; \ + unsigned32 *_destination = *(_fp_area); \ unsigned32 _index; \ \ for ( _index=0 ; _index < CPU_CONTEXT_FP_SIZE/4 ; _index++ ) \ diff --git a/c/src/exec/score/cpu/i386/i386.h b/c/src/exec/score/cpu/i386/i386.h index d43669ba53..1832d4142e 100644 --- a/c/src/exec/score/cpu/i386/i386.h +++ b/c/src/exec/score/cpu/i386/i386.h @@ -170,8 +170,8 @@ typedef struct { do { \ register unsigned32 _eflags = 0; \ \ - asm volatile ( "push %0 ; \ - popf " \ + asm volatile ( "pushf ; \ + pop %0" \ : "=r" ((_eflags)) : "0" ((_eflags)) \ ); \ \ diff --git a/c/src/exec/score/cpu/i960/cpu.h b/c/src/exec/score/cpu/i960/cpu.h index 3c4cb98ec8..f1b1ad399e 100644 --- a/c/src/exec/score/cpu/i960/cpu.h +++ b/c/src/exec/score/cpu/i960/cpu.h @@ -179,7 +179,7 @@ EXTERN void *_CPU_Interrupt_stack_high; */ #define CPU_SYSTEM_INITIALIZATION_THREAD_EXTRA_STACK \ - (4096 - CPU_STACK_MINIMUM_SIZE) + (CPU_STACK_MINIMUM_SIZE) /* * i960 family supports 256 distinct vectors. @@ -193,7 +193,7 @@ EXTERN void *_CPU_Interrupt_stack_high; * NOTE: See CPU_SYSTEM_INITIALIZATION_THREAD_EXTRA_STACK */ -#define CPU_STACK_MINIMUM_SIZE 1024 +#define CPU_STACK_MINIMUM_SIZE 2048 /* * i960 is pretty tolerant of alignment. Just put things on 4 byte boundaries. diff --git a/c/src/exec/score/cpu/m68k/cpu.h b/c/src/exec/score/cpu/m68k/cpu.h index 8379d47a00..a0aff66f4f 100644 --- a/c/src/exec/score/cpu/m68k/cpu.h +++ b/c/src/exec/score/cpu/m68k/cpu.h @@ -177,11 +177,9 @@ EXTERN void *_CPU_Interrupt_stack_high; /* * Minimum size of a thread's stack. - * - * NOTE: 256 bytes is probably too low in most cases. */ -#define CPU_STACK_MINIMUM_SIZE 256 +#define CPU_STACK_MINIMUM_SIZE 1024 /* * m68k is pretty tolerant of alignment. Just put things on 4 byte boundaries. diff --git a/c/src/exec/score/cpu/unix/cpu.c b/c/src/exec/score/cpu/unix/cpu.c index 339bb2a3ce..a1994da5ae 100644 --- a/c/src/exec/score/cpu/unix/cpu.c +++ b/c/src/exec/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, ¤t->isr_level ); + status = sigprocmask( SIG_SETMASK, &next->isr_level, ¤t->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/c/src/exec/score/headers/coremsg.h b/c/src/exec/score/headers/coremsg.h new file mode 100644 index 0000000000..109d792c78 --- /dev/null +++ b/c/src/exec/score/headers/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/c/src/exec/score/include/rtems/score/coremsg.h b/c/src/exec/score/include/rtems/score/coremsg.h new file mode 100644 index 0000000000..109d792c78 --- /dev/null +++ b/c/src/exec/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/c/src/exec/score/inline/coremsg.inl b/c/src/exec/score/inline/coremsg.inl new file mode 100644 index 0000000000..d1b5429947 --- /dev/null +++ b/c/src/exec/score/inline/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/c/src/exec/score/inline/rtems/score/coremsg.inl b/c/src/exec/score/inline/rtems/score/coremsg.inl new file mode 100644 index 0000000000..d1b5429947 --- /dev/null +++ b/c/src/exec/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/c/src/exec/score/macros/coremsg.inl b/c/src/exec/score/macros/coremsg.inl new file mode 100644 index 0000000000..877d737afd --- /dev/null +++ b/c/src/exec/score/macros/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/c/src/exec/score/macros/rtems/score/coremsg.inl b/c/src/exec/score/macros/rtems/score/coremsg.inl new file mode 100644 index 0000000000..877d737afd --- /dev/null +++ b/c/src/exec/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/c/src/exec/score/src/coremsg.c b/c/src/exec/score/src/coremsg.c new file mode 100644 index 0000000000..2ce0587b5f --- /dev/null +++ b/c/src/exec/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; +} diff --git a/c/src/lib/libbsp/hppa1.1/simhppa/startup/bspstart.c b/c/src/lib/libbsp/hppa1.1/simhppa/startup/bspstart.c index 2620d41df4..19a4e75568 100644 --- a/c/src/lib/libbsp/hppa1.1/simhppa/startup/bspstart.c +++ b/c/src/lib/libbsp/hppa1.1/simhppa/startup/bspstart.c @@ -29,6 +29,7 @@ #include <rtems.h> #include <bsp.h> #include <rtems/libio.h> +#include <rtems/core/intthrd.h> #include <libcsupport.h> @@ -85,9 +86,9 @@ fast_idle_switch_hook(rtems_tcb *current_task, * but its the best we could think of at the moment. */ - if (heir_task->name == rtems_build_name('I', 'D', 'L', 'E')) + if (heir_task == _Internal_threads_Idle_thread) CPU_HPPA_CLICKS_PER_TICK = fast_clock; - else if (current_task->name == rtems_build_name('I', 'D', 'L', 'E')) + else if (heir_task == _Internal_threads_Idle_thread) CPU_HPPA_CLICKS_PER_TICK = normal_clock; } @@ -211,7 +212,7 @@ bsp_pretasking_hook(void) memset(&fast_idle_extension, 0, sizeof(fast_idle_extension)); - fast_idle_extension.task_switch = fast_idle_switch_hook; + fast_idle_extension.thread_switch = fast_idle_switch_hook; rc = rtems_extension_create(rtems_build_name('F', 'D', 'L', 'E'), &fast_idle_extension, &extension_id); diff --git a/c/src/lib/libbsp/i386/force386/console/console.c b/c/src/lib/libbsp/i386/force386/console/console.c index 2b68f329c0..f3932150bf 100644 --- a/c/src/lib/libbsp/i386/force386/console/console.c +++ b/c/src/lib/libbsp/i386/force386/console/console.c @@ -266,7 +266,9 @@ rtems_device_driver console_write( } outbyte( buffer[ count ] ); } - return maximum; + + rw_args->bytes_moved = maximum; + return 0; } /* diff --git a/c/src/lib/libbsp/i386/force386/startup/bspstart.c b/c/src/lib/libbsp/i386/force386/startup/bspstart.c index 19cb28e450..1433e5e02a 100644 --- a/c/src/lib/libbsp/i386/force386/startup/bspstart.c +++ b/c/src/lib/libbsp/i386/force386/startup/bspstart.c @@ -74,16 +74,41 @@ void bsp_libc_init() libc_init(1); /* reentrant if possible */ else libc_init(0); /* non-reentrant */ +} +/* + * Function: bsp_pretasking_hook + * Created: 95/03/10 + * + * Description: + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + * + * NOTES: + * Must not use libc (to do io) from here, since drivers are + * not yet initialized. + * + */ + +void +bsp_pretasking_hook(void) +{ + bsp_libc_init(); + +#ifdef STACK_CHECKER_ON /* * Initialize the stack bounds checker + * We can either turn it on here or from the app. */ - -#ifdef STACK_CHECKER_ON + Stack_check_Initialize(); #endif - + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif } + /* * After drivers are setup, register some "filenames" @@ -135,9 +160,9 @@ int main( * we do not use the pretasking_hook. */ - Cpu_table.pretasking_hook = NULL; + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ - Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ + Cpu_table.predriver_hook = NULL; Cpu_table.postdriver_hook = bsp_postdriver_hook; diff --git a/c/src/lib/libbsp/i386/go32/console/console.c b/c/src/lib/libbsp/i386/go32/console/console.c index 3265f46de0..0649326846 100644 --- a/c/src/lib/libbsp/i386/go32/console/console.c +++ b/c/src/lib/libbsp/i386/go32/console/console.c @@ -237,7 +237,9 @@ rtems_device_driver console_write( } outbyte( buffer[ count ] ); } - return maximum; + + rw_args->bytes_moved = maximum; + return 0; } /* diff --git a/c/src/lib/libbsp/i386/go32/startup/bspstart.c b/c/src/lib/libbsp/i386/go32/startup/bspstart.c index 940c04270a..17a10b4193 100644 --- a/c/src/lib/libbsp/i386/go32/startup/bspstart.c +++ b/c/src/lib/libbsp/i386/go32/startup/bspstart.c @@ -81,17 +81,42 @@ void bsp_libc_init() libc_init(1); /* reentrant if possible */ else libc_init(0); /* non-reentrant */ - +} + +/* + * Function: bsp_pretasking_hook + * Created: 95/03/10 + * + * Description: + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + * + * NOTES: + * Must not use libc (to do io) from here, since drivers are + * not yet initialized. + * + */ + +void +bsp_pretasking_hook(void) +{ + bsp_libc_init(); + +#ifdef STACK_CHECKER_ON /* * Initialize the stack bounds checker + * We can either turn it on here or from the app. */ - -#ifdef STACK_CHECKER_ON + Stack_check_Initialize(); #endif - + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif } + /* * After drivers are setup, register some "filenames" * and open stdin, stdout, stderr files @@ -138,8 +163,8 @@ int main( else rtems_progname = "RTEMS"; - Cpu_table.pretasking_hook = NULL; - Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ + Cpu_table.predriver_hook = NULL; Cpu_table.postdriver_hook = bsp_postdriver_hook; Cpu_table.idle_task = NULL; /* do not override system IDLE task */ Cpu_table.do_zero_of_workspace = TRUE; diff --git a/c/src/lib/libbsp/i960/cvme961/console/console.c b/c/src/lib/libbsp/i960/cvme961/console/console.c index 192c7f2d16..f108fcbea5 100644 --- a/c/src/lib/libbsp/i960/cvme961/console/console.c +++ b/c/src/lib/libbsp/i960/cvme961/console/console.c @@ -192,7 +192,9 @@ rtems_device_driver console_write( } outbyte( buffer[ count ] ); } - return maximum; + + rw_args->bytes_moved = maximum; + return 0; } /* diff --git a/c/src/lib/libbsp/i960/cvme961/startup/bspstart.c b/c/src/lib/libbsp/i960/cvme961/startup/bspstart.c index 8298efcffe..ec4f8b601d 100644 --- a/c/src/lib/libbsp/i960/cvme961/startup/bspstart.c +++ b/c/src/lib/libbsp/i960/cvme961/startup/bspstart.c @@ -76,14 +76,41 @@ void bsp_libc_init() libc_init(1); /* reentrant if possible */ else libc_init(0); /* non-reentrant */ +} + +/* + * Function: bsp_pretasking_hook + * Created: 95/03/10 + * + * Description: + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + * + * NOTES: + * Must not use libc (to do io) from here, since drivers are + * not yet initialized. + * + */ + +void +bsp_pretasking_hook(void) +{ + bsp_libc_init(); + +#ifdef STACK_CHECKER_ON /* * Initialize the stack bounds checker + * We can either turn it on here or from the app. */ - -#ifdef STACK_CHECKER_ON + Stack_check_Initialize(); #endif + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif } + /* * After drivers are setup, register some "filenames" @@ -152,9 +179,9 @@ int main( * we do not use the pretasking_hook. */ - Cpu_table.pretasking_hook = NULL; + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ - Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ + Cpu_table.predriver_hook = NULL; Cpu_table.postdriver_hook = bsp_postdriver_hook; diff --git a/c/src/lib/libbsp/m68k/dmv152/console/console.c b/c/src/lib/libbsp/m68k/dmv152/console/console.c index ed0cd801c8..daa50f37f1 100644 --- a/c/src/lib/libbsp/m68k/dmv152/console/console.c +++ b/c/src/lib/libbsp/m68k/dmv152/console/console.c @@ -230,7 +230,9 @@ rtems_device_driver console_write( } outbyte( buffer[ count ] ); } - return maximum; + + rw_args->bytes_moved = maximum; + return 0; } /* diff --git a/c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c b/c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c index 4079ee4a8e..44ad6b6f7e 100644 --- a/c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c @@ -75,15 +75,41 @@ void bsp_libc_init() libc_init(1); /* reentrant if possible */ else libc_init(0); /* non-reentrant */ +} +/* + * Function: bsp_pretasking_hook + * Created: 95/03/10 + * + * Description: + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + * + * NOTES: + * Must not use libc (to do io) from here, since drivers are + * not yet initialized. + * + */ + +void +bsp_pretasking_hook(void) +{ + bsp_libc_init(); + +#ifdef STACK_CHECKER_ON /* * Initialize the stack bounds checker + * We can either turn it on here or from the app. */ - -#ifdef STACK_CHECKER_ON + Stack_check_Initialize(); #endif + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif } + /* * After drivers are setup, register some "filenames" @@ -158,9 +184,9 @@ int main( * we only use a hook to get the C library initialized. */ - Cpu_table.pretasking_hook = NULL; + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ - Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ + Cpu_table.predriver_hook = NULL; Cpu_table.postdriver_hook = bsp_postdriver_hook; diff --git a/c/src/lib/libbsp/m68k/gen68302/console/console.c b/c/src/lib/libbsp/m68k/gen68302/console/console.c index dd461e4557..04820bf579 100644 --- a/c/src/lib/libbsp/m68k/gen68302/console/console.c +++ b/c/src/lib/libbsp/m68k/gen68302/console/console.c @@ -285,7 +285,9 @@ rtems_device_driver console_write( } outbyte( buffer[ count ] ); } - return maximum; + + rw_args->bytes_moved = maximum; + return 0; } /* diff --git a/c/src/lib/libbsp/m68k/gen68302/startup/bspstart.c b/c/src/lib/libbsp/m68k/gen68302/startup/bspstart.c index 72e1656e04..94973ea4cc 100644 --- a/c/src/lib/libbsp/m68k/gen68302/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/gen68302/startup/bspstart.c @@ -82,15 +82,41 @@ void bsp_libc_init() libc_init(1); /* reentrant if possible */ else libc_init(0); /* non-reentrant */ +} +/* + * Function: bsp_pretasking_hook + * Created: 95/03/10 + * + * Description: + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + * + * NOTES: + * Must not use libc (to do io) from here, since drivers are + * not yet initialized. + * + */ + +void +bsp_pretasking_hook(void) +{ + bsp_libc_init(); + +#ifdef STACK_CHECKER_ON /* * Initialize the stack bounds checker + * We can either turn it on here or from the app. */ - -#ifdef STACK_CHECKER_ON + Stack_check_Initialize(); #endif + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif } + /* * After drivers are setup, register some "filenames" @@ -192,9 +218,9 @@ int main( * we do not use the pretasking_hook */ - Cpu_table.pretasking_hook = NULL; + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ - Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ + Cpu_table.predriver_hook = NULL; Cpu_table.postdriver_hook = bsp_postdriver_hook; diff --git a/c/src/lib/libbsp/m68k/idp/console/console.c b/c/src/lib/libbsp/m68k/idp/console/console.c index 5540d26fcd..cd64e27e84 100644 --- a/c/src/lib/libbsp/m68k/idp/console/console.c +++ b/c/src/lib/libbsp/m68k/idp/console/console.c @@ -265,7 +265,9 @@ rtems_device_driver console_write( } outbyte( buffer[ count ], minor ); } - return maximum; + + rw_args->bytes_moved = maximum; + return 0; } /* diff --git a/c/src/lib/libbsp/m68k/idp/startup/bspstart.c b/c/src/lib/libbsp/m68k/idp/startup/bspstart.c index 233449282e..b4f4928f7d 100644 --- a/c/src/lib/libbsp/m68k/idp/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/idp/startup/bspstart.c @@ -83,14 +83,39 @@ void bsp_libc_init() libc_init(1); /* reentrant if possible */ else libc_init(0); /* non-reentrant */ +} + +/* + * Function: bsp_pretasking_hook + * Created: 95/03/10 + * + * Description: + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + * + * NOTES: + * Must not use libc (to do io) from here, since drivers are + * not yet initialized. + * + */ + +void +bsp_pretasking_hook(void) +{ + bsp_libc_init(); +#ifdef STACK_CHECKER_ON /* * Initialize the stack bounds checker + * We can either turn it on here or from the app. */ -#ifdef STACK_CHECKER_ON Stack_check_Initialize(); #endif + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif } @@ -166,12 +191,12 @@ int main( * we only use a hook to get the C library initialized. */ - Cpu_table.pretasking_hook = NULL; - - Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ - + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ + + Cpu_table.predriver_hook = NULL; + Cpu_table.postdriver_hook = bsp_postdriver_hook; - + Cpu_table.idle_task = NULL; /* do not override system IDLE task */ Cpu_table.do_zero_of_workspace = TRUE; diff --git a/c/src/lib/libbsp/m68k/mvme136/console/console.c b/c/src/lib/libbsp/m68k/mvme136/console/console.c index e619fc1428..1c65707dc0 100644 --- a/c/src/lib/libbsp/m68k/mvme136/console/console.c +++ b/c/src/lib/libbsp/m68k/mvme136/console/console.c @@ -205,7 +205,9 @@ rtems_device_driver console_write( } outbyte( buffer[ count ] ); } - return maximum; + + rw_args->bytes_moved = maximum; + return 0; } /* diff --git a/c/src/lib/libbsp/m68k/mvme136/startup/bspstart.c b/c/src/lib/libbsp/m68k/mvme136/startup/bspstart.c index 5f822855e8..3465f72416 100644 --- a/c/src/lib/libbsp/m68k/mvme136/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/mvme136/startup/bspstart.c @@ -54,10 +54,6 @@ void bsp_libc_init() extern int end; rtems_unsigned32 heap_start; -#ifdef RTEMS_DEBUG - rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); -#endif - heap_start = (rtems_unsigned32) &end; if (heap_start & (CPU_ALIGNMENT-1)) heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); @@ -80,15 +76,41 @@ void bsp_libc_init() libc_init(1); /* reentrant if possible */ else libc_init(0); /* non-reentrant */ +} +/* + * Function: bsp_pretasking_hook + * Created: 95/03/10 + * + * Description: + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + * + * NOTES: + * Must not use libc (to do io) from here, since drivers are + * not yet initialized. + * + */ + +void +bsp_pretasking_hook(void) +{ + bsp_libc_init(); + +#ifdef STACK_CHECKER_ON /* * Initialize the stack bounds checker + * We can either turn it on here or from the app. */ - -#ifdef STACK_CHECKER_ON + Stack_check_Initialize(); #endif + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif } + /* * After drivers are setup, register some "filenames" @@ -152,9 +174,9 @@ int main( * we only use a hook to get the C library initialized. */ - Cpu_table.pretasking_hook = NULL; + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ - Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ + Cpu_table.predriver_hook = NULL; Cpu_table.postdriver_hook = bsp_postdriver_hook; diff --git a/c/src/lib/libbsp/m68k/mvme162/console/console.c b/c/src/lib/libbsp/m68k/mvme162/console/console.c index 72595f3bce..2e1b877f3b 100644 --- a/c/src/lib/libbsp/m68k/mvme162/console/console.c +++ b/c/src/lib/libbsp/m68k/mvme162/console/console.c @@ -237,7 +237,9 @@ rtems_device_driver console_write( } outbyte( buffer[ count ], minor ); } - return maximum; + + rw_args->bytes_moved = maximum; + return 0; } /* diff --git a/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c b/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c index 973a78a9f4..123cd413d2 100644 --- a/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c @@ -82,15 +82,41 @@ void bsp_libc_init() libc_init(1); /* reentrant if possible */ else libc_init(0); /* non-reentrant */ +} +/* + * Function: bsp_pretasking_hook + * Created: 95/03/10 + * + * Description: + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + * + * NOTES: + * Must not use libc (to do io) from here, since drivers are + * not yet initialized. + * + */ + +void +bsp_pretasking_hook(void) +{ + bsp_libc_init(); + +#ifdef STACK_CHECKER_ON /* * Initialize the stack bounds checker + * We can either turn it on here or from the app. */ - -#ifdef STACK_CHECKER_ON + Stack_check_Initialize(); #endif + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif } + /* * After drivers are setup, register some "filenames" @@ -165,9 +191,9 @@ int main( * we only use a hook to get the C library initialized. */ - Cpu_table.pretasking_hook = NULL; + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ - Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ + Cpu_table.predriver_hook = NULL; Cpu_table.postdriver_hook = bsp_postdriver_hook; diff --git a/c/src/lib/libbsp/no_cpu/no_bsp/console/console.c b/c/src/lib/libbsp/no_cpu/no_bsp/console/console.c index 4b1ca4a0e3..5b12e09532 100644 --- a/c/src/lib/libbsp/no_cpu/no_bsp/console/console.c +++ b/c/src/lib/libbsp/no_cpu/no_bsp/console/console.c @@ -204,7 +204,9 @@ rtems_device_driver console_write( } outbyte( buffer[ count ] ); } - return maximum; + + rw_args->bytes_moved = maximum; + return 0; } /* diff --git a/c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c b/c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c index 75739aa39b..e28e791503 100644 --- a/c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c +++ b/c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c @@ -83,15 +83,41 @@ void bsp_libc_init() libc_init(1); /* reentrant if possible */ else libc_init(0); /* non-reentrant */ +} +/* + * Function: bsp_pretasking_hook + * Created: 95/03/10 + * + * Description: + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + * + * NOTES: + * Must not use libc (to do io) from here, since drivers are + * not yet initialized. + * + */ + +void +bsp_pretasking_hook(void) +{ + bsp_libc_init(); + +#ifdef STACK_CHECKER_ON /* * Initialize the stack bounds checker + * We can either turn it on here or from the app. */ - -#ifdef STACK_CHECKER_ON + Stack_check_Initialize(); #endif + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif } + /* * After drivers are setup, register some "filenames" @@ -119,7 +145,7 @@ bsp_postdriver_hook(void) rtems_fatal_error_occurred('STIO'); } -int main( +int bsp_start( int argc, char **argv, char **environp @@ -196,9 +222,9 @@ int main( * we do not use the pretasking_hook */ - Cpu_table.pretasking_hook = NULL; + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ - Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ + Cpu_table.predriver_hook = NULL; Cpu_table.postdriver_hook = bsp_postdriver_hook; diff --git a/c/src/lib/libbsp/no_cpu/no_bsp/startup/main.c b/c/src/lib/libbsp/no_cpu/no_bsp/startup/main.c index 622edb1ad7..62126647e7 100644 --- a/c/src/lib/libbsp/no_cpu/no_bsp/startup/main.c +++ b/c/src/lib/libbsp/no_cpu/no_bsp/startup/main.c @@ -19,10 +19,11 @@ int main( int argc, - char **argv + char **argv, + char **environp ) { - bsp_start(); + bsp_start( argc, argv, environp ); /* * May be able to return to the "crt/start.s" code but also diff --git a/c/src/lib/libbsp/powerpc/papyrus/startup/bspstart.c b/c/src/lib/libbsp/powerpc/papyrus/startup/bspstart.c index 66ead73dae..65090a03ac 100644 --- a/c/src/lib/libbsp/powerpc/papyrus/startup/bspstart.c +++ b/c/src/lib/libbsp/powerpc/papyrus/startup/bspstart.c @@ -101,14 +101,41 @@ void bsp_libc_init() else libc_init(0); /* non-reentrant */ +} + +/* + * Function: bsp_pretasking_hook + * Created: 95/03/10 + * + * Description: + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + * + * NOTES: + * Must not use libc (to do io) from here, since drivers are + * not yet initialized. + * + */ + +void +bsp_pretasking_hook(void) +{ + bsp_libc_init(); + +#ifdef STACK_CHECKER_ON /* * Initialize the stack bounds checker + * We can either turn it on here or from the app. */ - -#ifdef STACK_CHECKER_ON + Stack_check_Initialize(); #endif + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif } + /* * After drivers are setup, register some "filenames" @@ -204,13 +231,9 @@ int main( * initialize the CPU table for this BSP */ - /* - * we do not use the pretasking_hook - */ - - Cpu_table.pretasking_hook = NULL; + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ - Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ + Cpu_table.predriver_hook = NULL; Cpu_table.postdriver_hook = bsp_postdriver_hook; diff --git a/c/src/lib/libmisc/monitor/mon-object.c b/c/src/lib/libmisc/monitor/mon-object.c index 2f92845586..7aef850141 100644 --- a/c/src/lib/libmisc/monitor/mon-object.c +++ b/c/src/lib/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/c/src/lib/libmisc/monitor/mon-queue.c b/c/src/lib/libmisc/monitor/mon-queue.c index d09ac7a337..a72a371bff 100644 --- a/c/src/lib/libmisc/monitor/mon-queue.c +++ b/c/src/lib/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/c/src/libmisc/monitor/mon-object.c b/c/src/libmisc/monitor/mon-object.c index 2f92845586..7aef850141 100644 --- a/c/src/libmisc/monitor/mon-object.c +++ b/c/src/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/c/src/libmisc/monitor/mon-queue.c b/c/src/libmisc/monitor/mon-queue.c index d09ac7a337..a72a371bff 100644 --- a/c/src/libmisc/monitor/mon-queue.c +++ b/c/src/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/c/src/tests/mptests/mp01/init.c b/c/src/tests/mptests/mp01/init.c index 1a4c9463e4..888151761f 100644 --- a/c/src/tests/mptests/mp01/init.c +++ b/c/src/tests/mptests/mp01/init.c @@ -53,7 +53,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_GLOBAL, &Task_id[ 1 ] @@ -64,7 +64,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Task_id[ 2 ] @@ -75,7 +75,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 3 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] diff --git a/c/src/tests/mptests/mp02/init.c b/c/src/tests/mptests/mp02/init.c index 22e145d6c6..723e4ff5cd 100644 --- a/c/src/tests/mptests/mp02/init.c +++ b/c/src/tests/mptests/mp02/init.c @@ -43,7 +43,7 @@ rtems_task Init( status = rtems_task_create( Task_name[Multiprocessing_configuration.node], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_NO_PREEMPT, RTEMS_GLOBAL, &Task_id[ 1 ] diff --git a/c/src/tests/mptests/mp03/init.c b/c/src/tests/mptests/mp03/init.c index 861a77ef2d..9be30fd92e 100644 --- a/c/src/tests/mptests/mp03/init.c +++ b/c/src/tests/mptests/mp03/init.c @@ -43,7 +43,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ Multiprocessing_configuration.node ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_NO_PREEMPT, RTEMS_GLOBAL, &Task_id[ 1 ] diff --git a/c/src/tests/mptests/mp04/init.c b/c/src/tests/mptests/mp04/init.c index adc21b9f0c..e3de164f09 100644 --- a/c/src/tests/mptests/mp04/init.c +++ b/c/src/tests/mptests/mp04/init.c @@ -43,7 +43,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ Multiprocessing_configuration.node ], Multiprocessing_configuration.node, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_GLOBAL, &Task_id[ 1 ] diff --git a/c/src/tests/mptests/mp05/init.c b/c/src/tests/mptests/mp05/init.c index b6338f9a5d..0732a85cfc 100644 --- a/c/src/tests/mptests/mp05/init.c +++ b/c/src/tests/mptests/mp05/init.c @@ -43,7 +43,7 @@ rtems_task Init( status = rtems_task_create( Task_name[Multiprocessing_configuration.node], 1, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Task_id[ 1 ] diff --git a/c/src/tests/mptests/mp06/init.c b/c/src/tests/mptests/mp06/init.c index 8639554703..f04f834956 100644 --- a/c/src/tests/mptests/mp06/init.c +++ b/c/src/tests/mptests/mp06/init.c @@ -43,7 +43,7 @@ rtems_task Init( status = rtems_task_create( Task_name[Multiprocessing_configuration.node], 1, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_GLOBAL, &Task_id[ 1 ] diff --git a/c/src/tests/mptests/mp07/init.c b/c/src/tests/mptests/mp07/init.c index 1d18eccd79..a732434ead 100644 --- a/c/src/tests/mptests/mp07/init.c +++ b/c/src/tests/mptests/mp07/init.c @@ -43,7 +43,7 @@ rtems_task Init( status = rtems_task_create( Task_name[Multiprocessing_configuration.node], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Task_id[ 1 ] diff --git a/c/src/tests/mptests/mp08/init.c b/c/src/tests/mptests/mp08/init.c index 229a47afef..b16585c99c 100644 --- a/c/src/tests/mptests/mp08/init.c +++ b/c/src/tests/mptests/mp08/init.c @@ -57,7 +57,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ Multiprocessing_configuration.node ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Task_id[ 1 ] diff --git a/c/src/tests/mptests/mp09/init.c b/c/src/tests/mptests/mp09/init.c index 95c837689a..b6f5195139 100644 --- a/c/src/tests/mptests/mp09/init.c +++ b/c/src/tests/mptests/mp09/init.c @@ -57,7 +57,7 @@ rtems_task Init( status = rtems_task_create( Task_name[Multiprocessing_configuration.node], 1, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] diff --git a/c/src/tests/mptests/mp10/init.c b/c/src/tests/mptests/mp10/init.c index b37be53a4c..1413c7b897 100644 --- a/c/src/tests/mptests/mp10/init.c +++ b/c/src/tests/mptests/mp10/init.c @@ -80,7 +80,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -95,7 +95,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 1, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -110,7 +110,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 3 ], 1, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] diff --git a/c/src/tests/mptests/mp11/init.c b/c/src/tests/mptests/mp11/init.c index 5e3da0d8d0..7c89be66c2 100644 --- a/c/src/tests/mptests/mp11/init.c +++ b/c/src/tests/mptests/mp11/init.c @@ -54,7 +54,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_GLOBAL, &junk_id diff --git a/c/src/tests/mptests/mp13/init.c b/c/src/tests/mptests/mp13/init.c index af618aed7c..1e96d5c69e 100644 --- a/c/src/tests/mptests/mp13/init.c +++ b/c/src/tests/mptests/mp13/init.c @@ -76,7 +76,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -91,7 +91,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 1, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] diff --git a/c/src/tests/mptests/mp14/init.c b/c/src/tests/mptests/mp14/init.c index 2b2070083b..4ec9c6a273 100644 --- a/c/src/tests/mptests/mp14/init.c +++ b/c/src/tests/mptests/mp14/init.c @@ -120,7 +120,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ Multiprocessing_configuration.node ], 2, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Event_task_id[ 1 ] @@ -135,7 +135,7 @@ rtems_task Init( status = rtems_task_create( Semaphore_task_name[ Multiprocessing_configuration.node ], 2, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Semaphore_task_id[ 1 ] @@ -150,7 +150,7 @@ rtems_task Init( status = rtems_task_create( Queue_task_name[ Multiprocessing_configuration.node ], 2, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Queue_task_id[ 1 ] @@ -166,7 +166,7 @@ rtems_task Init( status = rtems_task_create( Partition_task_name[ Multiprocessing_configuration.node ], 2, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_TIMESLICE, RTEMS_GLOBAL, &Partition_task_id[ 1 ] diff --git a/c/src/tests/samples/base_mp/init.c b/c/src/tests/samples/base_mp/init.c index 26c37ec849..1e73fd0e56 100644 --- a/c/src/tests/samples/base_mp/init.c +++ b/c/src/tests/samples/base_mp/init.c @@ -35,7 +35,7 @@ rtems_task Init( printf( "\n\n*** SAMPLE MULTIPROCESSOR APPLICATION ***\n" ); printf( "Creating and starting an application task\n" ); task_name = rtems_build_name( 'T', 'A', '1', ' ' ); - status = rtems_task_create( task_name, 1, 1024, + status = rtems_task_create( task_name, 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_INTERRUPT_LEVEL(0), RTEMS_DEFAULT_ATTRIBUTES, &tid ); status = rtems_task_start( tid, diff --git a/c/src/tests/samples/base_sp/init.c b/c/src/tests/samples/base_sp/init.c index d26787260c..e40d5e008a 100644 --- a/c/src/tests/samples/base_sp/init.c +++ b/c/src/tests/samples/base_sp/init.c @@ -39,7 +39,7 @@ rtems_task Init( task_name = rtems_build_name( 'T', 'A', '1', ' ' ); - status = rtems_task_create( task_name, 1, 1024, + status = rtems_task_create( task_name, 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_INTERRUPT_LEVEL(0), RTEMS_DEFAULT_ATTRIBUTES, &tid ); status = rtems_task_start( tid, Application_task, ARGUMENT ); diff --git a/c/src/tests/samples/ticker/init.c b/c/src/tests/samples/ticker/init.c index c023a25801..d4d1f0176a 100644 --- a/c/src/tests/samples/ticker/init.c +++ b/c/src/tests/samples/ticker/init.c @@ -40,12 +40,18 @@ rtems_task Init( Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); - status = rtems_task_create( Task_name[ 1 ], 1, 1024, RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] ); - status = rtems_task_create( Task_name[ 2 ], 1, 1024, RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] ); - status = rtems_task_create( Task_name[ 3 ], 1, 1024, RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] ); + status = rtems_task_create( + Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] + ); + status = rtems_task_create( + Task_name[ 2 ], 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] + ); + status = rtems_task_create( + Task_name[ 3 ], 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] + ); status = rtems_task_start( Task_id[ 1 ], Test_task, 1 ); status = rtems_task_start( Task_id[ 2 ], Test_task, 2 ); diff --git a/c/src/tests/sptests/sp01/init.c b/c/src/tests/sptests/sp01/init.c index 6823108bea..894cc3e890 100644 --- a/c/src/tests/sptests/sp01/init.c +++ b/c/src/tests/sptests/sp01/init.c @@ -45,7 +45,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 2 * 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_INTERRUPT_LEVEL(31), RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -55,7 +55,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 1, - 2 * 1024, + RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -65,7 +65,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 3 ], 1, - 2 * 1024, + RTEMS_MINIMUM_STACK_SIZE * 3, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] diff --git a/c/src/tests/sptests/sp02/init.c b/c/src/tests/sptests/sp02/init.c index 6571eb275a..9333b6acf7 100644 --- a/c/src/tests/sptests/sp02/init.c +++ b/c/src/tests/sptests/sp02/init.c @@ -38,7 +38,7 @@ rtems_task Init( status = rtems_task_create( Preempt_task_name, 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Preempt_task_id @@ -59,7 +59,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 3, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -69,7 +69,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 3, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -79,7 +79,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 3 ], 3, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] @@ -111,7 +111,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -121,7 +121,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 3, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -131,7 +131,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 3 ], 3, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] diff --git a/c/src/tests/sptests/sp03/init.c b/c/src/tests/sptests/sp03/init.c index 733a9c4ad4..0de15f689c 100644 --- a/c/src/tests/sptests/sp03/init.c +++ b/c/src/tests/sptests/sp03/init.c @@ -39,7 +39,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -49,7 +49,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] diff --git a/c/src/tests/sptests/sp04/init.c b/c/src/tests/sptests/sp04/init.c index 0bec318a88..954a3fbe12 100644 --- a/c/src/tests/sptests/sp04/init.c +++ b/c/src/tests/sptests/sp04/init.c @@ -70,7 +70,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_TIMESLICE, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -80,7 +80,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_TIMESLICE, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -90,7 +90,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 3 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_TIMESLICE, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] diff --git a/c/src/tests/sptests/sp05/init.c b/c/src/tests/sptests/sp05/init.c index 78a7ba5030..5c1dbc0236 100644 --- a/c/src/tests/sptests/sp05/init.c +++ b/c/src/tests/sptests/sp05/init.c @@ -40,7 +40,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -50,7 +50,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -60,7 +60,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 3 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] diff --git a/c/src/tests/sptests/sp06/init.c b/c/src/tests/sptests/sp06/init.c index 70d5284651..6d8af5f01d 100644 --- a/c/src/tests/sptests/sp06/init.c +++ b/c/src/tests/sptests/sp06/init.c @@ -44,7 +44,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -54,7 +54,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -64,7 +64,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 3 ], 10, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] diff --git a/c/src/tests/sptests/sp07/init.c b/c/src/tests/sptests/sp07/init.c index 3eb37a4fe3..843d8781e9 100644 --- a/c/src/tests/sptests/sp07/init.c +++ b/c/src/tests/sptests/sp07/init.c @@ -62,7 +62,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -72,7 +72,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -82,7 +82,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 3 ], 250, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] @@ -92,7 +92,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 4 ], 254, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 4 ] diff --git a/c/src/tests/sptests/sp08/init.c b/c/src/tests/sptests/sp08/init.c index 65b6f82bdf..7d6e63e00f 100644 --- a/c/src/tests/sptests/sp08/init.c +++ b/c/src/tests/sptests/sp08/init.c @@ -38,7 +38,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] diff --git a/c/src/tests/sptests/sp09/init.c b/c/src/tests/sptests/sp09/init.c index de01d2d657..b879eff42e 100644 --- a/c/src/tests/sptests/sp09/init.c +++ b/c/src/tests/sptests/sp09/init.c @@ -82,7 +82,7 @@ rtems_task Init( status = rtems_task_create( Task_name[1], 0, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -97,7 +97,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE * 3, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] diff --git a/c/src/tests/sptests/sp09/screen03.c b/c/src/tests/sptests/sp09/screen03.c index 7f431c45df..545b6c1bab 100644 --- a/c/src/tests/sptests/sp09/screen03.c +++ b/c/src/tests/sptests/sp09/screen03.c @@ -30,7 +30,7 @@ void Screen3() status = rtems_task_create( 0, 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Junk_id @@ -60,7 +60,7 @@ void Screen3() status = rtems_task_create( Task_name[ 2 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -87,7 +87,7 @@ void Screen3() status = rtems_task_create( Task_name[ 3 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] @@ -98,7 +98,7 @@ void Screen3() status = rtems_task_create( Task_name[ 4 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 4 ] @@ -109,7 +109,7 @@ void Screen3() status = rtems_task_create( Task_name[ 5 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 5 ] @@ -120,7 +120,7 @@ void Screen3() status = rtems_task_create( Task_name[ 6 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 6 ] @@ -131,7 +131,7 @@ void Screen3() status = rtems_task_create( Task_name[ 7 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 7 ] @@ -142,7 +142,7 @@ void Screen3() status = rtems_task_create( Task_name[ 8 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 8 ] @@ -153,7 +153,7 @@ void Screen3() status = rtems_task_create( Task_name[ 9 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 9 ] @@ -164,7 +164,7 @@ void Screen3() status = rtems_task_create( Task_name[ 10 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 10 ] @@ -175,7 +175,7 @@ void Screen3() status = rtems_task_create( task_name, 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Junk_id @@ -190,7 +190,7 @@ void Screen3() status = rtems_task_create( task_name, 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_GLOBAL, &Junk_id diff --git a/c/src/tests/sptests/sp11/init.c b/c/src/tests/sptests/sp11/init.c index c79a42fb4e..9524f3ff82 100644 --- a/c/src/tests/sptests/sp11/init.c +++ b/c/src/tests/sptests/sp11/init.c @@ -39,7 +39,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -49,7 +49,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] diff --git a/c/src/tests/sptests/sp12/init.c b/c/src/tests/sptests/sp12/init.c index 159ef815da..ecc45d8a4b 100644 --- a/c/src/tests/sptests/sp12/init.c +++ b/c/src/tests/sptests/sp12/init.c @@ -138,7 +138,7 @@ pause(); status = rtems_task_create( Task_name[ 1 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -148,7 +148,7 @@ pause(); status = rtems_task_create( Task_name[ 2 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -158,7 +158,7 @@ pause(); status = rtems_task_create( Task_name[ 3 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] diff --git a/c/src/tests/sptests/sp12/pridrv.c b/c/src/tests/sptests/sp12/pridrv.c index 7174faf784..7d6e1f9dc4 100644 --- a/c/src/tests/sptests/sp12/pridrv.c +++ b/c/src/tests/sptests/sp12/pridrv.c @@ -47,7 +47,7 @@ void Priority_test_driver( status = rtems_task_create( Priority_task_name[ index ], Task_priority[ index ], - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Priority_task_id[ index ] diff --git a/c/src/tests/sptests/sp12/task1.c b/c/src/tests/sptests/sp12/task1.c index d3d7f3ed15..f70ad521b1 100644 --- a/c/src/tests/sptests/sp12/task1.c +++ b/c/src/tests/sptests/sp12/task1.c @@ -100,7 +100,7 @@ pause(); status = rtems_task_create( Task_name[ 4 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 4 ] @@ -110,7 +110,7 @@ pause(); status = rtems_task_create( Task_name[ 5 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 5 ] diff --git a/c/src/tests/sptests/sp13/init.c b/c/src/tests/sptests/sp13/init.c index 178e534e11..9a778f2fff 100644 --- a/c/src/tests/sptests/sp13/init.c +++ b/c/src/tests/sptests/sp13/init.c @@ -40,7 +40,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -50,7 +50,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -60,7 +60,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 3 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] diff --git a/c/src/tests/sptests/sp14/init.c b/c/src/tests/sptests/sp14/init.c index fe66b83eb3..14b36ae081 100644 --- a/c/src/tests/sptests/sp14/init.c +++ b/c/src/tests/sptests/sp14/init.c @@ -39,7 +39,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -49,7 +49,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] diff --git a/c/src/tests/sptests/sp15/init.c b/c/src/tests/sptests/sp15/init.c index a0f3dfe649..7c4d301e45 100644 --- a/c/src/tests/sptests/sp15/init.c +++ b/c/src/tests/sptests/sp15/init.c @@ -41,7 +41,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 4, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] diff --git a/c/src/tests/sptests/sp16/init.c b/c/src/tests/sptests/sp16/init.c index 6503796ef0..7955f48075 100644 --- a/c/src/tests/sptests/sp16/init.c +++ b/c/src/tests/sptests/sp16/init.c @@ -42,7 +42,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], BASE_PRIORITY, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -52,7 +52,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], BASE_PRIORITY, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -62,7 +62,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 3 ], BASE_PRIORITY, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] diff --git a/c/src/tests/sptests/sp16/task1.c b/c/src/tests/sptests/sp16/task1.c index 25f90aca00..44df86f216 100644 --- a/c/src/tests/sptests/sp16/task1.c +++ b/c/src/tests/sptests/sp16/task1.c @@ -128,7 +128,7 @@ pause(); status = rtems_task_create( Task_name[ 4 ], BASE_PRIORITY, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 4 ] @@ -138,7 +138,7 @@ pause(); status = rtems_task_create( Task_name[ 5 ], BASE_PRIORITY, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 5 ] diff --git a/c/src/tests/sptests/sp17/init.c b/c/src/tests/sptests/sp17/init.c index 8a5bcfee1a..92c8812a8d 100644 --- a/c/src/tests/sptests/sp17/init.c +++ b/c/src/tests/sptests/sp17/init.c @@ -41,7 +41,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 2, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -54,7 +54,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] diff --git a/c/src/tests/sptests/sp19/init.c b/c/src/tests/sptests/sp19/init.c index 35b8efd4ae..0d1cce26ef 100644 --- a/c/src/tests/sptests/sp19/init.c +++ b/c/src/tests/sptests/sp19/init.c @@ -43,7 +43,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 2, - 8192, + RTEMS_MINIMUM_STACK_SIZE * 4, RTEMS_DEFAULT_MODES, RTEMS_FLOATING_POINT, &Task_id[ 1 ] @@ -53,7 +53,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 2 ], 2, - 8192, + RTEMS_MINIMUM_STACK_SIZE * 4, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -63,7 +63,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 3 ], 2, - 8192, + RTEMS_MINIMUM_STACK_SIZE * 4, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] @@ -73,7 +73,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 4 ], 2, - 8192, + RTEMS_MINIMUM_STACK_SIZE * 4, RTEMS_DEFAULT_MODES, RTEMS_FLOATING_POINT, &Task_id[ 4 ] @@ -83,7 +83,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 5 ], 2, - 8192, + RTEMS_MINIMUM_STACK_SIZE * 4, RTEMS_DEFAULT_MODES, RTEMS_FLOATING_POINT, &Task_id[ 5 ] @@ -93,7 +93,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 6 ], 1, - 8192, + RTEMS_MINIMUM_STACK_SIZE * 4, RTEMS_DEFAULT_MODES, RTEMS_FLOATING_POINT, &Task_id[ 6 ] diff --git a/c/src/tests/sptests/sp20/init.c b/c/src/tests/sptests/sp20/init.c index af23fa92e1..0e1b56ba3a 100644 --- a/c/src/tests/sptests/sp20/init.c +++ b/c/src/tests/sptests/sp20/init.c @@ -44,7 +44,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ index ], Priorities[ index ], - 4096, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] diff --git a/c/src/tests/sptests/sp21/init.c b/c/src/tests/sptests/sp21/init.c index 50824bcefd..a8ea3e7ed2 100644 --- a/c/src/tests/sptests/sp21/init.c +++ b/c/src/tests/sptests/sp21/init.c @@ -38,7 +38,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] diff --git a/c/src/tests/sptests/sp22/init.c b/c/src/tests/sptests/sp22/init.c index abfa0e0c06..874fc4096d 100644 --- a/c/src/tests/sptests/sp22/init.c +++ b/c/src/tests/sptests/sp22/init.c @@ -45,7 +45,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] diff --git a/c/src/tests/sptests/sp23/init.c b/c/src/tests/sptests/sp23/init.c index c96927ece7..9ca4b634c8 100644 --- a/c/src/tests/sptests/sp23/init.c +++ b/c/src/tests/sptests/sp23/init.c @@ -38,7 +38,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] diff --git a/c/src/tests/sptests/sp24/init.c b/c/src/tests/sptests/sp24/init.c index 8297581ea3..81abc0277a 100644 --- a/c/src/tests/sptests/sp24/init.c +++ b/c/src/tests/sptests/sp24/init.c @@ -52,7 +52,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ index ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] diff --git a/c/src/tests/sptests/sp25/init.c b/c/src/tests/sptests/sp25/init.c index 4fcf332355..10a3f8cc52 100644 --- a/c/src/tests/sptests/sp25/init.c +++ b/c/src/tests/sptests/sp25/init.c @@ -38,7 +38,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], BASE_PRIORITY, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] diff --git a/c/src/tests/sptests/spfatal/init.c b/c/src/tests/sptests/spfatal/init.c index e06ec20c8a..5abcec46a4 100644 --- a/c/src/tests/sptests/spfatal/init.c +++ b/c/src/tests/sptests/spfatal/init.c @@ -36,7 +36,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 1, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] diff --git a/c/src/tests/sptests/spsize/size.c b/c/src/tests/sptests/spsize/size.c index 93bda6ccf9..ed9bd59f7a 100644 --- a/c/src/tests/sptests/spsize/size.c +++ b/c/src/tests/sptests/spsize/size.c @@ -66,8 +66,6 @@ (sizeof (Timer_Control) + NAME_PTR_SIZE) #define PER_MSGQ \ (sizeof (Message_queue_Control) + NAME_PTR_SIZE) -#define PER_MSG_OVERHEAD \ - (sizeof (Message_queue_Buffer_control)) #define PER_REGN \ (sizeof (Region_Control) + NAME_PTR_SIZE) #define PER_PART \ @@ -479,9 +477,9 @@ maximum_msgqs = getint(); size_msgqs = PER_MSGQ * maximum_msgqs; total_size += size_msgqs; -printf( "What is maximum_messages? " ); +printf( "What is maximum_messages? XXXX " ); maximum_msgs = getint(); -size_msgs_overhead = PER_MSG_OVERHEAD * maximum_msgs; +size_msgs_overhead = 0; total_size += size_msgs_overhead; printf( "What is maximum_regions? " ); @@ -570,7 +568,7 @@ printf( " Timers - %03d * %03d = %d\n", printf( " Msg Queues - %03d * %03d = %d\n", maximum_msgqs, PER_MSGQ, size_msgqs ); printf( " Messages Overhead - %03d * %03d = %d\n", - maximum_msgs, PER_MSG_OVERHEAD, size_msgs_overhead ); + maximum_msgs, 0 /* PER_MSG_OVERHEAD */, size_msgs_overhead ); printf( " Regions - %03d * %03d = %d\n", maximum_regns, PER_REGN, size_regns); printf( " Partitions - %03d * %03d = %d\n", diff --git a/c/src/tests/tmtests/tm01/task1.c b/c/src/tests/tmtests/tm01/task1.c index cc1cfca70f..0b1863bada 100644 --- a/c/src/tests/tmtests/tm01/task1.c +++ b/c/src/tests/tmtests/tm01/task1.c @@ -35,7 +35,7 @@ rtems_task Init( status = rtems_task_create( Task_name[ 1 ], 128, - 4096, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] diff --git a/c/src/tests/tmtests/tm02/task1.c b/c/src/tests/tmtests/tm02/task1.c index a657b37c78..47e6c28d0a 100644 --- a/c/src/tests/tmtests/tm02/task1.c +++ b/c/src/tests/tmtests/tm02/task1.c @@ -60,7 +60,7 @@ void test_init() status = rtems_task_create( rtems_build_name( 'H', 'I', 'G', 'H' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &High_id @@ -76,7 +76,7 @@ void test_init() status = rtems_task_create( rtems_build_name( 'M', 'I', 'D', ' ' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Low_id @@ -92,7 +92,7 @@ void test_init() status = rtems_task_create( rtems_build_name( 'L', 'O', 'W', ' ' ), priority, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Low_id diff --git a/c/src/tests/tmtests/tm03/task1.c b/c/src/tests/tmtests/tm03/task1.c index 59f9289d10..71b4c33e90 100644 --- a/c/src/tests/tmtests/tm03/task1.c +++ b/c/src/tests/tmtests/tm03/task1.c @@ -41,7 +41,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'A', '1', ' ' ), 252, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id @@ -79,7 +79,7 @@ rtems_task test_init( rtems_task_create( rtems_build_name( 'M', 'I', 'D', ' ' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id @@ -95,7 +95,7 @@ rtems_task test_init( status = rtems_task_create( rtems_build_name( 'H', 'I', 'G', 'H' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id diff --git a/c/src/tests/tmtests/tm04/task1.c b/c/src/tests/tmtests/tm04/task1.c index 8156a17daa..603724dddb 100644 --- a/c/src/tests/tmtests/tm04/task1.c +++ b/c/src/tests/tmtests/tm04/task1.c @@ -61,7 +61,7 @@ void test_init() status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), 10, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_NO_PREEMPT, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] @@ -179,7 +179,7 @@ rtems_task High_task( rtems_task_create( name, 10, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_NO_PREEMPT, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] @@ -217,7 +217,7 @@ rtems_task High_task( status = rtems_task_create( name, 250, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_NO_PREEMPT, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] @@ -264,7 +264,7 @@ rtems_task High_task( status = rtems_task_create( name, 250, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] @@ -344,7 +344,7 @@ rtems_task Low_tasks( status = rtems_task_create( rtems_build_name( 'H', 'I', ' ', ' ' ), 5, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -357,7 +357,7 @@ rtems_task Low_tasks( status = rtems_task_create( rtems_build_name( 'H', 'I', 'G', 'H' ), 3, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Highest_id diff --git a/c/src/tests/tmtests/tm05/task1.c b/c/src/tests/tmtests/tm05/task1.c index 3f1f44a54a..031c5b64d1 100644 --- a/c/src/tests/tmtests/tm05/task1.c +++ b/c/src/tests/tmtests/tm05/task1.c @@ -61,7 +61,7 @@ void test_init() status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] diff --git a/c/src/tests/tmtests/tm06/task1.c b/c/src/tests/tmtests/tm06/task1.c index 2863cc8684..ffaef7117d 100644 --- a/c/src/tests/tmtests/tm06/task1.c +++ b/c/src/tests/tmtests/tm06/task1.c @@ -54,7 +54,7 @@ void test_init( void ) status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), 128, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -99,7 +99,7 @@ rtems_task Task_1( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), 254, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] diff --git a/c/src/tests/tmtests/tm07/task1.c b/c/src/tests/tmtests/tm07/task1.c index bd7aad8744..8cc65ed292 100644 --- a/c/src/tests/tmtests/tm07/task1.c +++ b/c/src/tests/tmtests/tm07/task1.c @@ -59,7 +59,7 @@ void test_init() status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[index] diff --git a/c/src/tests/tmtests/tm08/task1.c b/c/src/tests/tmtests/tm08/task1.c index 99958e4197..1a03329f26 100644 --- a/c/src/tests/tmtests/tm08/task1.c +++ b/c/src/tests/tmtests/tm08/task1.c @@ -47,7 +47,7 @@ void test_init() status = rtems_task_create( 1, 128, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Test_task_id @@ -60,7 +60,7 @@ void test_init() status = rtems_task_create( 1, 254, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Test_task_id diff --git a/c/src/tests/tmtests/tm09/task1.c b/c/src/tests/tmtests/tm09/task1.c index 882fc5e61c..ebdc8f6e6c 100644 --- a/c/src/tests/tmtests/tm09/task1.c +++ b/c/src/tests/tmtests/tm09/task1.c @@ -34,7 +34,7 @@ rtems_task Init( status = rtems_task_create( 1, 128, - 4096, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] diff --git a/c/src/tests/tmtests/tm10/task1.c b/c/src/tests/tmtests/tm10/task1.c index 853974ee9c..8cc6ed99a2 100644 --- a/c/src/tests/tmtests/tm10/task1.c +++ b/c/src/tests/tmtests/tm10/task1.c @@ -62,7 +62,7 @@ void test_init() status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id diff --git a/c/src/tests/tmtests/tm11/task1.c b/c/src/tests/tmtests/tm11/task1.c index a68da12d5b..d76ef0f1b0 100644 --- a/c/src/tests/tmtests/tm11/task1.c +++ b/c/src/tests/tmtests/tm11/task1.c @@ -45,7 +45,7 @@ void Init( status = rtems_task_create( 1, 251, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -89,7 +89,7 @@ rtems_task test_init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id diff --git a/c/src/tests/tmtests/tm12/task1.c b/c/src/tests/tmtests/tm12/task1.c index 16b918dd28..df67bb6099 100644 --- a/c/src/tests/tmtests/tm12/task1.c +++ b/c/src/tests/tmtests/tm12/task1.c @@ -45,7 +45,7 @@ rtems_task Init( status = rtems_task_create( 1, 251, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id @@ -85,7 +85,7 @@ rtems_task test_init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id diff --git a/c/src/tests/tmtests/tm13/task1.c b/c/src/tests/tmtests/tm13/task1.c index 2a66a38e33..bb78752560 100644 --- a/c/src/tests/tmtests/tm13/task1.c +++ b/c/src/tests/tmtests/tm13/task1.c @@ -44,7 +44,7 @@ void Init( status = rtems_task_create( 1, 251, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -88,7 +88,7 @@ rtems_task test_init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id diff --git a/c/src/tests/tmtests/tm14/task1.c b/c/src/tests/tmtests/tm14/task1.c index d799f0963c..39f0453862 100644 --- a/c/src/tests/tmtests/tm14/task1.c +++ b/c/src/tests/tmtests/tm14/task1.c @@ -45,7 +45,7 @@ rtems_task Init( status = rtems_task_create( 1, 251, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id @@ -85,7 +85,7 @@ rtems_task test_init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id diff --git a/c/src/tests/tmtests/tm15/task1.c b/c/src/tests/tmtests/tm15/task1.c index 86efae5cb2..837167db20 100644 --- a/c/src/tests/tmtests/tm15/task1.c +++ b/c/src/tests/tmtests/tm15/task1.c @@ -54,7 +54,7 @@ void test_init() status = rtems_task_create( rtems_build_name( 'L', 'O', 'W', ' ' ), 10, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_NO_PREEMPT, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -68,7 +68,7 @@ void test_init() status = rtems_task_create( rtems_build_name( 'H', 'I', 'G', 'H' ), 5, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] diff --git a/c/src/tests/tmtests/tm16/task1.c b/c/src/tests/tmtests/tm16/task1.c index 996cbecb5f..793a063194 100644 --- a/c/src/tests/tmtests/tm16/task1.c +++ b/c/src/tests/tmtests/tm16/task1.c @@ -42,7 +42,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'E', 'S', 'T' ), 251, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -76,7 +76,7 @@ rtems_task test_init( status = rtems_task_create( rtems_build_name( 'M', 'I', 'D', ' ' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] diff --git a/c/src/tests/tmtests/tm17/task1.c b/c/src/tests/tmtests/tm17/task1.c index 187f470231..2277833deb 100644 --- a/c/src/tests/tmtests/tm17/task1.c +++ b/c/src/tests/tmtests/tm17/task1.c @@ -47,7 +47,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), Task_priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ] diff --git a/c/src/tests/tmtests/tm18/task1.c b/c/src/tests/tmtests/tm18/task1.c index e2b44dac31..37fd5035a6 100644 --- a/c/src/tests/tmtests/tm18/task1.c +++ b/c/src/tests/tmtests/tm18/task1.c @@ -59,7 +59,7 @@ void test_init() status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), 128, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id diff --git a/c/src/tests/tmtests/tm19/task1.c b/c/src/tests/tmtests/tm19/task1.c index a0c4b7159b..3d02126dc1 100644 --- a/c/src/tests/tmtests/tm19/task1.c +++ b/c/src/tests/tmtests/tm19/task1.c @@ -47,7 +47,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), 128, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -60,7 +60,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), 127, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -73,7 +73,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), 126, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] diff --git a/c/src/tests/tmtests/tm20/task1.c b/c/src/tests/tmtests/tm20/task1.c index 756a957b22..22d514add6 100644 --- a/c/src/tests/tmtests/tm20/task1.c +++ b/c/src/tests/tmtests/tm20/task1.c @@ -54,7 +54,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', '1' ), 128, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -67,7 +67,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', '2' ), 129, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] @@ -348,7 +348,7 @@ rtems_task Task_1( Timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) - (void) rtems_io_initialize( 0, 0, NULL ); + (void) rtems_io_initialize( _STUB_major, 0, NULL ); end_time = Read_timer(); put_time( @@ -361,7 +361,7 @@ rtems_task Task_1( Timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) - (void) rtems_io_open( 0, 0, NULL ); + (void) rtems_io_open( _STUB_major, 0, NULL ); end_time = Read_timer(); put_time( @@ -374,7 +374,7 @@ rtems_task Task_1( Timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) - (void) rtems_io_close( 0, 0, NULL ); + (void) rtems_io_close( _STUB_major, 0, NULL ); end_time = Read_timer(); put_time( @@ -387,7 +387,7 @@ rtems_task Task_1( Timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) - (void) rtems_io_read( 0, 0, NULL ); + (void) rtems_io_read( _STUB_major, 0, NULL ); end_time = Read_timer(); put_time( @@ -400,7 +400,7 @@ rtems_task Task_1( Timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) - (void) rtems_io_write( 0, 0, NULL ); + (void) rtems_io_write( _STUB_major, 0, NULL ); end_time = Read_timer(); put_time( @@ -413,7 +413,7 @@ rtems_task Task_1( Timer_initialize(); for ( index=1 ; index <= OPERATION_COUNT ; index++ ) - (void) rtems_io_control( 0, 0, NULL ); + (void) rtems_io_control( _STUB_major, 0, NULL ); end_time = Read_timer(); put_time( diff --git a/c/src/tests/tmtests/tm21/task1.c b/c/src/tests/tmtests/tm21/task1.c index 8f3bbbd837..a7a6a09ed7 100644 --- a/c/src/tests/tmtests/tm21/task1.c +++ b/c/src/tests/tmtests/tm21/task1.c @@ -35,7 +35,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), 250, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -61,7 +61,7 @@ rtems_task Task_1( status = rtems_task_create ( index, 254, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -70,7 +70,7 @@ rtems_task Task_1( status = rtems_message_queue_create( index, - OPERATION_COUNT, + 1, 16, RTEMS_DEFAULT_ATTRIBUTES, &id diff --git a/c/src/tests/tmtests/tm22/task1.c b/c/src/tests/tmtests/tm22/task1.c index 63ae155978..3bf607e823 100644 --- a/c/src/tests/tmtests/tm22/task1.c +++ b/c/src/tests/tmtests/tm22/task1.c @@ -53,7 +53,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'L', 'O', 'W', ' ' ), 10, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_NO_PREEMPT, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -66,7 +66,7 @@ rtems_task Init( status = rtems_task_create( 1, 11, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -121,7 +121,7 @@ rtems_task Low_task( status = rtems_task_create( rtems_build_name( 'H', 'I', 'G', 'H' ), 5, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_NO_PREEMPT, RTEMS_DEFAULT_ATTRIBUTES, &id diff --git a/c/src/tests/tmtests/tm23/task1.c b/c/src/tests/tmtests/tm23/task1.c index 4fa36a8a25..55380ecc12 100644 --- a/c/src/tests/tmtests/tm23/task1.c +++ b/c/src/tests/tmtests/tm23/task1.c @@ -62,7 +62,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), priority, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id diff --git a/c/src/tests/tmtests/tm24/task1.c b/c/src/tests/tmtests/tm24/task1.c index 2cc0046bd0..4f8de47336 100644 --- a/c/src/tests/tmtests/tm24/task1.c +++ b/c/src/tests/tmtests/tm24/task1.c @@ -39,7 +39,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'H', 'I', 'G', 'H' ), 10, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -53,7 +53,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'R', 'E', 'S', 'T' ), 128, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id diff --git a/c/src/tests/tmtests/tm25/task1.c b/c/src/tests/tmtests/tm25/task1.c index 8e6fda4b68..fc24318938 100644 --- a/c/src/tests/tmtests/tm25/task1.c +++ b/c/src/tests/tmtests/tm25/task1.c @@ -48,7 +48,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'L', 'O', 'W', ' ' ), 254, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id @@ -62,7 +62,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), 128, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id diff --git a/c/src/tests/tmtests/tm26/task1.c b/c/src/tests/tmtests/tm26/task1.c index ed94b3c8ae..377ccf6dd4 100644 --- a/c/src/tests/tmtests/tm26/task1.c +++ b/c/src/tests/tmtests/tm26/task1.c @@ -72,7 +72,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'F', 'P', '1', ' ' ), 201, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_FLOATING_POINT, &task_id @@ -85,7 +85,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'F', 'P', '2', ' ' ), 202, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_FLOATING_POINT, &task_id @@ -98,7 +98,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'L', 'O', 'W', ' ' ), 200, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id @@ -111,7 +111,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'M', 'I', 'D', ' ' ), 128, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id @@ -124,7 +124,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'H', 'I', 'G', 'H' ), 5, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id @@ -147,7 +147,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'N', 'U', 'L', 'L' ), 254, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id diff --git a/c/src/tests/tmtests/tm27/task1.c b/c/src/tests/tmtests/tm27/task1.c index b90ae4d65f..51e795d817 100644 --- a/c/src/tests/tmtests/tm27/task1.c +++ b/c/src/tests/tmtests/tm27/task1.c @@ -55,7 +55,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'A', '1', ' ' ), 254, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] @@ -68,7 +68,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'A', '2', ' ' ), 254, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] diff --git a/c/src/tests/tmtests/tm28/task1.c b/c/src/tests/tmtests/tm28/task1.c index bd0682be19..26728953fa 100644 --- a/c/src/tests/tmtests/tm28/task1.c +++ b/c/src/tests/tmtests/tm28/task1.c @@ -36,7 +36,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'I', 'M', 'E' ), 128, - 4096, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] diff --git a/c/src/tests/tmtests/tm29/task1.c b/c/src/tests/tmtests/tm29/task1.c index 0958765c4c..c6691e6ee1 100644 --- a/c/src/tests/tmtests/tm29/task1.c +++ b/c/src/tests/tmtests/tm29/task1.c @@ -122,7 +122,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'E', 'S', 'T' ), 128, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -136,7 +136,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'L', 'O', 'W', ' ' ), 200, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id diff --git a/c/src/tests/tmtests/tmck/system.h b/c/src/tests/tmtests/tmck/system.h index 8b1c9b0ddd..ddbfd9ca0a 100644 --- a/c/src/tests/tmtests/tmck/system.h +++ b/c/src/tests/tmtests/tmck/system.h @@ -32,7 +32,7 @@ rtems_task Init( #define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER #define CONFIGURE_TEST_NEEDS_TIMER_DRIVER -#define CONFIGURE_MAXIMUM_TASKS 2111 +#define CONFIGURE_MAXIMUM_TASKS 2 #define CONFIGURE_TICKS_PER_TIMESLICE 0 #include <confdefs.h> diff --git a/c/src/tests/tmtests/tmck/task1.c b/c/src/tests/tmtests/tmck/task1.c index 34eb674f4d..73b551db95 100644 --- a/c/src/tests/tmtests/tmck/task1.c +++ b/c/src/tests/tmtests/tmck/task1.c @@ -50,7 +50,7 @@ rtems_task Init( status = rtems_task_create( 1, 5, - 1024, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id diff --git a/c/src/tests/tmtests/tmoverhd/testtask.c b/c/src/tests/tmtests/tmoverhd/testtask.c index f5cac161bb..a5a27f84b8 100644 --- a/c/src/tests/tmtests/tmoverhd/testtask.c +++ b/c/src/tests/tmtests/tmoverhd/testtask.c @@ -37,7 +37,7 @@ rtems_task Init( status = rtems_task_create( rtems_build_name( 'T', 'A', '1', ' ' ), 254, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id @@ -129,7 +129,7 @@ rtems_task Task_1( (void) rtems_task_create( name, in_priority, - 2048, + RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &id 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, ¤t->isr_level ); + status = sigprocmask( SIG_SETMASK, &next->isr_level, ¤t->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; +} |