summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cpukit/score/include/rtems/score/coremsg.h10
-rw-r--r--cpukit/score/include/rtems/score/mpci.h2
-rw-r--r--cpukit/score/include/rtems/score/thread.h22
-rw-r--r--cpukit/score/inline/rtems/score/coremsg.inl4
-rw-r--r--cpukit/score/src/coremsg.c10
-rw-r--r--cpukit/score/src/coremsgbroadcast.c8
-rw-r--r--cpukit/score/src/coremsgseize.c20
-rw-r--r--cpukit/score/src/coremsgsubmit.c16
-rw-r--r--cpukit/score/src/objectgetinfo.c7
9 files changed, 60 insertions, 39 deletions
diff --git a/cpukit/score/include/rtems/score/coremsg.h b/cpukit/score/include/rtems/score/coremsg.h
index c35574f3fc..f34eecee50 100644
--- a/cpukit/score/include/rtems/score/coremsg.h
+++ b/cpukit/score/include/rtems/score/coremsg.h
@@ -201,7 +201,7 @@ typedef struct {
/** This is the size in bytes of the largest message which may be
* sent via this queue.
*/
- uint32_t maximum_message_size;
+ size_t maximum_message_size;
/** This chain is the set of pending messages. It may be ordered by
* message priority or in FIFO order.
*/
@@ -244,7 +244,7 @@ boolean _CORE_message_queue_Initialize(
CORE_message_queue_Control *the_message_queue,
CORE_message_queue_Attributes *the_message_queue_attributes,
uint32_t maximum_pending_messages,
- uint32_t maximum_message_size
+ size_t maximum_message_size
);
/**
@@ -326,7 +326,7 @@ void _CORE_message_queue_Flush_waiting_threads(
*/
CORE_message_queue_Status _CORE_message_queue_Broadcast(
CORE_message_queue_Control *the_message_queue,
- void *buffer,
+ const void *buffer,
size_t size,
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
@@ -360,7 +360,7 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
*/
CORE_message_queue_Status _CORE_message_queue_Submit(
CORE_message_queue_Control *the_message_queue,
- void *buffer,
+ const void *buffer,
size_t size,
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
@@ -396,7 +396,7 @@ void _CORE_message_queue_Seize(
CORE_message_queue_Control *the_message_queue,
Objects_Id id,
void *buffer,
- size_t *size,
+ size_t *size_p,
boolean wait,
Watchdog_Interval timeout
);
diff --git a/cpukit/score/include/rtems/score/mpci.h b/cpukit/score/include/rtems/score/mpci.h
index 424875fc8e..09e2aea52c 100644
--- a/cpukit/score/include/rtems/score/mpci.h
+++ b/cpukit/score/include/rtems/score/mpci.h
@@ -122,7 +122,7 @@ typedef struct {
* MPCI layer. This size places a limit on the size of a message
* which can be transmitted over this interface.
**/
- uint32_t maximum_packet_size;
+ size_t maximum_packet_size;
/** This field points to the MPCI initialization entry point. */
MPCI_initialization_entry initialization;
/** This field points to the MPCI get packet entry point. */
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 6057cec5c7..5539dc29e2 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -209,6 +209,21 @@ typedef struct {
*/
#define THREAD_STATUS_PROXY_BLOCKING 0x1111111
+/**
+ * @brief Union type to hold a pointer to an immutable or a mutable object.
+ *
+ * The main purpose is to enable passing of pointers to read-only send buffers
+ * in the message passing subsystem. This approach is somewhat fragile since
+ * it prevents the compiler to check if the operations on objects are valid
+ * with respect to the constant qualifier. An alternative would be to add a
+ * third pointer argument for immutable objects, but this would increase the
+ * structure size.
+ */
+typedef union {
+ void *mutable_object;
+ const void *immutable_object;
+} Thread_Wait_information_Object_argument_type;
+
/** @brief Thread Blocking Management Information
*
* This contains the information required to manage a thread while it is
@@ -219,10 +234,11 @@ typedef struct {
Objects_Id id;
/** This field is used to return an integer while when blocked. */
uint32_t count;
- /** This field is the first pointer to a user return argument. */
+ /** This field is for a pointer to a user return argument. */
void *return_argument;
- /** This field is the second pointer to a user return argument. */
- void *return_argument_1;
+ /** This field is for a pointer to a second user return argument. */
+ Thread_Wait_information_Object_argument_type
+ return_argument_second;
/** This field contains any options in effect on this blocking operation. */
uint32_t option;
/** This field will contain the return status from a blocking operation.
diff --git a/cpukit/score/inline/rtems/score/coremsg.inl b/cpukit/score/inline/rtems/score/coremsg.inl
index 3ff0ccc62a..aff4b5f06b 100644
--- a/cpukit/score/inline/rtems/score/coremsg.inl
+++ b/cpukit/score/inline/rtems/score/coremsg.inl
@@ -32,7 +32,7 @@
RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send(
CORE_message_queue_Control *the_message_queue,
- void *buffer,
+ const void *buffer,
size_t size,
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
@@ -62,7 +62,7 @@ RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send(
RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Urgent(
CORE_message_queue_Control *the_message_queue,
- void *buffer,
+ const void *buffer,
size_t size,
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
diff --git a/cpukit/score/src/coremsg.c b/cpukit/score/src/coremsg.c
index c7fbac609f..8163df96e5 100644
--- a/cpukit/score/src/coremsg.c
+++ b/cpukit/score/src/coremsg.c
@@ -56,11 +56,11 @@ boolean _CORE_message_queue_Initialize(
CORE_message_queue_Control *the_message_queue,
CORE_message_queue_Attributes *the_message_queue_attributes,
uint32_t maximum_pending_messages,
- uint32_t maximum_message_size
+ size_t maximum_message_size
)
{
- uint32_t message_buffering_required;
- uint32_t allocated_message_size;
+ size_t message_buffering_required;
+ size_t allocated_message_size;
the_message_queue->maximum_pending_messages = maximum_pending_messages;
the_message_queue->number_of_pending_messages = 0;
@@ -85,7 +85,7 @@ boolean _CORE_message_queue_Initialize(
* Calculate how much total memory is required for message buffering and
* check for overflow on the multiplication.
*/
- message_buffering_required = maximum_pending_messages *
+ message_buffering_required = (size_t) maximum_pending_messages *
(allocated_message_size + sizeof(CORE_message_queue_Buffer_control));
if (message_buffering_required < allocated_message_size)
@@ -107,7 +107,7 @@ boolean _CORE_message_queue_Initialize(
_Chain_Initialize (
&the_message_queue->Inactive_messages,
the_message_queue->message_buffers,
- maximum_pending_messages,
+ (size_t) maximum_pending_messages,
allocated_message_size + sizeof( CORE_message_queue_Buffer_control )
);
diff --git a/cpukit/score/src/coremsgbroadcast.c b/cpukit/score/src/coremsgbroadcast.c
index 1710e6168e..287a17ab92 100644
--- a/cpukit/score/src/coremsgbroadcast.c
+++ b/cpukit/score/src/coremsgbroadcast.c
@@ -56,7 +56,7 @@
CORE_message_queue_Status _CORE_message_queue_Broadcast(
CORE_message_queue_Control *the_message_queue,
- void *buffer,
+ const void *buffer,
size_t size,
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
@@ -66,7 +66,7 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
Thread_Control *the_thread;
uint32_t number_broadcasted;
Thread_Wait_information *waitp;
- uint32_t constrained_size;
+ size_t constrained_size;
/*
* If there are pending messages, then there can't be threads
@@ -98,11 +98,11 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
_CORE_message_queue_Copy_buffer(
buffer,
- waitp->return_argument,
+ waitp->return_argument_second.mutable_object,
constrained_size
);
- *(uint32_t *)the_thread->Wait.return_argument_1 = size;
+ *(size_t *) the_thread->Wait.return_argument = size;
#if defined(RTEMS_MULTIPROCESSING)
if ( !_Objects_Is_local_id( the_thread->Object.id ) )
diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c
index 010f201b78..48c4d7ecb4 100644
--- a/cpukit/score/src/coremsgseize.c
+++ b/cpukit/score/src/coremsgseize.c
@@ -46,7 +46,7 @@
* 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
+ * size_p - pointer to the size of buffer to be filled
* wait - TRUE if wait is allowed, FALSE otherwise
* timeout - time to wait for a message
*
@@ -63,7 +63,7 @@ void _CORE_message_queue_Seize(
CORE_message_queue_Control *the_message_queue,
Objects_Id id,
void *buffer,
- size_t *size,
+ size_t *size_p,
boolean wait,
Watchdog_Interval timeout
)
@@ -81,9 +81,9 @@ void _CORE_message_queue_Seize(
the_message_queue->number_of_pending_messages -= 1;
_ISR_Enable( level );
- *size = the_message->Contents.size;
+ *size_p = the_message->Contents.size;
_Thread_Executing->Wait.count = the_message->priority;
- _CORE_message_queue_Copy_buffer(the_message->Contents.buffer,buffer,*size);
+ _CORE_message_queue_Copy_buffer(the_message->Contents.buffer,buffer,*size_p);
/*
* There could be a thread waiting to send a message. If there
@@ -106,9 +106,9 @@ void _CORE_message_queue_Seize(
*/
the_message->priority = the_thread->Wait.count;
- the_message->Contents.size = (uint32_t)the_thread->Wait.option;
+ the_message->Contents.size = (size_t) the_thread->Wait.option;
_CORE_message_queue_Copy_buffer(
- the_thread->Wait.return_argument,
+ the_thread->Wait.return_argument_second.immutable_object,
the_message->Contents.buffer,
the_message->Contents.size
);
@@ -128,10 +128,10 @@ void _CORE_message_queue_Seize(
}
_Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
- executing->Wait.queue = &the_message_queue->Wait_queue;
- executing->Wait.id = id;
- executing->Wait.return_argument = buffer;
- executing->Wait.return_argument_1 = (void *)size;
+ executing->Wait.queue = &the_message_queue->Wait_queue;
+ executing->Wait.id = id;
+ executing->Wait.return_argument_second.mutable_object = buffer;
+ executing->Wait.return_argument = size_p;
/* Wait.count will be filled in with the message priority */
_ISR_Enable( level );
diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c
index 2f1ea815ca..9882d1c811 100644
--- a/cpukit/score/src/coremsgsubmit.c
+++ b/cpukit/score/src/coremsgsubmit.c
@@ -59,7 +59,7 @@
CORE_message_queue_Status _CORE_message_queue_Submit(
CORE_message_queue_Control *the_message_queue,
- void *buffer,
+ const void *buffer,
size_t size,
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
@@ -85,10 +85,10 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
if ( the_thread ) {
_CORE_message_queue_Copy_buffer(
buffer,
- the_thread->Wait.return_argument,
+ the_thread->Wait.return_argument_second.mutable_object,
size
);
- *(size_t *)the_thread->Wait.return_argument_1 = size;
+ *(size_t *) the_thread->Wait.return_argument = size;
the_thread->Wait.count = submit_type;
#if defined(RTEMS_MULTIPROCESSING)
@@ -165,11 +165,11 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
_ISR_Disable( level );
_Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
- executing->Wait.queue = &the_message_queue->Wait_queue;
- executing->Wait.id = id;
- executing->Wait.return_argument = buffer;
- executing->Wait.option = size;
- executing->Wait.count = submit_type;
+ executing->Wait.queue = &the_message_queue->Wait_queue;
+ executing->Wait.id = id;
+ executing->Wait.return_argument_second.immutable_object = buffer;
+ executing->Wait.option = (uint32_t) size;
+ executing->Wait.count = submit_type;
_ISR_Enable( level );
_Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout );
diff --git a/cpukit/score/src/objectgetinfo.c b/cpukit/score/src/objectgetinfo.c
index c7d7d81b06..033f827891 100644
--- a/cpukit/score/src/objectgetinfo.c
+++ b/cpukit/score/src/objectgetinfo.c
@@ -24,11 +24,16 @@ Objects_Information *_Objects_Get_information(
)
{
Objects_Information *info;
+ int the_class_api_maximum;
if ( !_Objects_Is_api_valid( the_api ) )
return NULL;
- if ( !the_class || the_class > _Objects_API_maximum_class(the_api) )
+ if ( !the_class )
+ return NULL;
+
+ the_class_api_maximum = _Objects_API_maximum_class( the_api );
+ if ( the_class_api_maximum < 0 || the_class > (uint32_t) the_class_api_maximum )
return NULL;
if ( !_Objects_Information_table[ the_api ] )