summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/rtems/src')
-rw-r--r--cpukit/rtems/src/dpmem.c60
-rw-r--r--cpukit/rtems/src/event.c35
-rw-r--r--cpukit/rtems/src/eventmp.c18
-rw-r--r--cpukit/rtems/src/intr.c32
-rw-r--r--cpukit/rtems/src/mp.c87
-rw-r--r--cpukit/rtems/src/msg.c108
-rw-r--r--cpukit/rtems/src/msgmp.c41
-rw-r--r--cpukit/rtems/src/part.c72
-rw-r--r--cpukit/rtems/src/partmp.c18
-rw-r--r--cpukit/rtems/src/ratemon.c63
-rw-r--r--cpukit/rtems/src/region.c119
-rw-r--r--cpukit/rtems/src/regionmp.c22
-rw-r--r--cpukit/rtems/src/rtclock.c44
-rw-r--r--cpukit/rtems/src/rtemstimer.c101
-rw-r--r--cpukit/rtems/src/sem.c451
-rw-r--r--cpukit/rtems/src/semmp.c26
-rw-r--r--cpukit/rtems/src/signal.c75
-rw-r--r--cpukit/rtems/src/signalmp.c20
-rw-r--r--cpukit/rtems/src/taskmp.c22
-rw-r--r--cpukit/rtems/src/tasks.c504
20 files changed, 1132 insertions, 786 deletions
diff --git a/cpukit/rtems/src/dpmem.c b/cpukit/rtems/src/dpmem.c
index 522c14866b..ee41eec142 100644
--- a/cpukit/rtems/src/dpmem.c
+++ b/cpukit/rtems/src/dpmem.c
@@ -13,11 +13,13 @@
*/
#include <rtems/system.h>
-#include <rtems/support.h>
-#include <rtems/address.h>
-#include <rtems/dpmem.h>
-#include <rtems/object.h>
-#include <rtems/thread.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/support.h>
+#include <rtems/core/address.h>
+#include <rtems/rtems/dpmem.h>
+#include <rtems/core/object.h>
+#include <rtems/core/thread.h>
+#include <rtems/rtems/dpmem.h>
/*PAGE
*
@@ -78,11 +80,11 @@ rtems_status_code rtems_port_create(
register Dual_ported_memory_Control *the_port;
if ( !rtems_is_name_valid( name) )
- return ( RTEMS_INVALID_NAME );
+ return RTEMS_INVALID_NAME;
if ( !_Addresses_Is_aligned( internal_start ) ||
!_Addresses_Is_aligned( external_start ) )
- return( RTEMS_INVALID_ADDRESS );
+ return RTEMS_INVALID_ADDRESS;
_Thread_Disable_dispatch(); /* to prevent deletion */
@@ -90,7 +92,7 @@ rtems_status_code rtems_port_create(
if ( !the_port ) {
_Thread_Enable_dispatch();
- return( RTEMS_TOO_MANY );
+ return RTEMS_TOO_MANY;
}
the_port->internal_base = internal_start;
@@ -105,7 +107,7 @@ rtems_status_code rtems_port_create(
*id = the_port->Object.id;
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -130,14 +132,16 @@ rtems_status_code rtems_port_ident(
Objects_Id *id
)
{
- return(
- _Objects_Name_to_id(
- &_Dual_ported_memory_Information,
- &name,
- RTEMS_SEARCH_ALL_NODES,
- id
- )
+ Objects_Name_to_id_errors status;
+
+ status = _Objects_Name_to_id(
+ &_Dual_ported_memory_Information,
+ &name,
+ OBJECTS_SEARCH_ALL_NODES,
+ id
);
+
+ return _Status_Object_name_errors_to_status[ status ];
}
/*PAGE
@@ -165,17 +169,17 @@ rtems_status_code rtems_port_delete(
the_port = _Dual_ported_memory_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* this error cannot be returned */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
_Objects_Close( &_Dual_ported_memory_Information, &the_port->Object );
_Dual_ported_memory_Free( the_port );
_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
@@ -210,9 +214,9 @@ rtems_status_code rtems_port_internal_to_external(
the_port = _Dual_ported_memory_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* this error cannot be returned */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
ending = _Addresses_Subtract( internal, the_port->internal_base );
if ( ending > the_port->length )
@@ -221,10 +225,10 @@ rtems_status_code rtems_port_internal_to_external(
*external = _Addresses_Add_offset( the_port->external_base,
ending );
_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
@@ -259,9 +263,9 @@ rtems_status_code rtems_port_external_to_internal(
the_port = _Dual_ported_memory_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* this error cannot be returned */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
ending = _Addresses_Subtract( external, the_port->external_base );
if ( ending > the_port->length )
@@ -270,8 +274,8 @@ rtems_status_code rtems_port_external_to_internal(
*internal = _Addresses_Add_offset( the_port->internal_base,
ending );
_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 */
}
diff --git a/cpukit/rtems/src/event.c b/cpukit/rtems/src/event.c
index ec14c2aaa9..833358bca8 100644
--- a/cpukit/rtems/src/event.c
+++ b/cpukit/rtems/src/event.c
@@ -13,12 +13,14 @@
*/
#include <rtems/system.h>
-#include <rtems/event.h>
-#include <rtems/isr.h>
-#include <rtems/object.h>
-#include <rtems/options.h>
-#include <rtems/states.h>
-#include <rtems/thread.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/event.h>
+#include <rtems/core/isr.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/options.h>
+#include <rtems/core/states.h>
+#include <rtems/core/thread.h>
+#include <rtems/rtems/tasks.h>
/*PAGE
*
@@ -42,11 +44,12 @@ rtems_status_code rtems_event_send(
{
register Thread_Control *the_thread;
Objects_Locations location;
+ RTEMS_API_Control *api;
the_thread = _Thread_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
return(
_Event_MP_Send_request_packet(
@@ -56,13 +59,14 @@ rtems_status_code rtems_event_send(
)
);
case OBJECTS_LOCAL:
- _Event_sets_Post( event_in, &the_thread->RTEMS_API->pending_events );
+ api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
+ _Event_sets_Post( event_in, &api->pending_events );
_Event_Surrender( the_thread );
_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
@@ -90,14 +94,17 @@ rtems_status_code rtems_event_receive(
rtems_event_set *event_out
)
{
+ RTEMS_API_Control *api;
+
+ api = _Thread_Executing->API_Extensions[ THREAD_API_RTEMS ];
+
if ( _Event_sets_Is_empty( event_in ) ) {
- *event_out = _Thread_Executing->RTEMS_API->pending_events;
- return( RTEMS_SUCCESSFUL );
+ *event_out = api->pending_events;
+ return RTEMS_SUCCESSFUL;
}
_Thread_Disable_dispatch();
- _Event_Seize( event_in, option_set, ticks );
+ _Event_Seize( event_in, option_set, ticks, event_out );
_Thread_Enable_dispatch();
- *event_out = _Thread_Executing->RTEMS_API->events_out;
return( _Thread_Executing->Wait.return_code );
}
diff --git a/cpukit/rtems/src/eventmp.c b/cpukit/rtems/src/eventmp.c
index 4bc5925c2a..e477c9d3b5 100644
--- a/cpukit/rtems/src/eventmp.c
+++ b/cpukit/rtems/src/eventmp.c
@@ -13,13 +13,15 @@
*/
#include <rtems/system.h>
-#include <rtems/event.h>
-#include <rtems/mpci.h>
-#include <rtems/mppkt.h>
-#include <rtems/object.h>
-#include <rtems/options.h>
-#include <rtems/states.h>
-#include <rtems/thread.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/event.h>
+#include <rtems/core/mpci.h>
+#include <rtems/core/mppkt.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/options.h>
+#include <rtems/core/states.h>
+#include <rtems/core/thread.h>
+#include <rtems/rtems/support.h>
/*PAGE
*
@@ -49,7 +51,7 @@ rtems_status_code _Event_MP_Send_request_packet (
case EVENT_MP_SEND_REQUEST:
the_packet = _Event_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_EVENT;
+ the_packet->Prefix.the_class = MP_PACKET_EVENT;
the_packet->Prefix.length = sizeof ( Event_MP_Packet );
the_packet->Prefix.to_convert = sizeof ( Event_MP_Packet );
the_packet->operation = operation;
diff --git a/cpukit/rtems/src/intr.c b/cpukit/rtems/src/intr.c
index 25f5176967..dbcc23434c 100644
--- a/cpukit/rtems/src/intr.c
+++ b/cpukit/rtems/src/intr.c
@@ -14,10 +14,9 @@
*/
#include <rtems/system.h>
-#include <rtems/isr.h>
-#include <rtems/stack.h>
-#include <rtems/intr.h>
-#include <rtems/wkspace.h>
+#include <rtems/rtems/status.h>
+#include <rtems/core/isr.h>
+#include <rtems/rtems/intr.h>
/* _Interrupt_Manager_initialization
*
@@ -30,25 +29,6 @@
void _Interrupt_Manager_initialization( void )
{
-#if ( CPU_ALLOCATE_INTERRUPT_STACK == TRUE )
-
- if ( _CPU_Table.interrupt_stack_size < RTEMS_MINIMUM_STACK_SIZE )
- rtems_fatal_error_occurred( RTEMS_INVALID_SIZE );
-
- _CPU_Interrupt_stack_low =
- _Workspace_Allocate_or_fatal_error( _CPU_Table.interrupt_stack_size );
-
- _CPU_Interrupt_stack_high = _Addresses_Add_offset(
- _CPU_Interrupt_stack_low,
- _CPU_Table.interrupt_stack_size
- );
-
-#endif
-
-#if ( CPU_HAS_HARDWARE_INTERRUPT_STACK == TRUE )
- _CPU_Install_interrupt_stack();
-#endif
-
}
/* rtems_interrupt_catch
@@ -73,13 +53,13 @@ rtems_status_code rtems_interrupt_catch(
)
{
if ( !_ISR_Is_vector_number_valid( vector ) )
- return( RTEMS_INVALID_NUMBER );
+ return RTEMS_INVALID_NUMBER;
if ( !_ISR_Is_valid_user_handler( new_isr_handler ) )
- return( RTEMS_INVALID_ADDRESS );
+ return RTEMS_INVALID_ADDRESS;
_ISR_Install_vector(
vector, (proc_ptr)new_isr_handler, (proc_ptr *)old_isr_handler );
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/mp.c b/cpukit/rtems/src/mp.c
index c555ffb3f1..f17d3b13e6 100644
--- a/cpukit/rtems/src/mp.c
+++ b/cpukit/rtems/src/mp.c
@@ -14,23 +14,9 @@
*/
#include <rtems/system.h>
-#include <rtems/config.h>
-#include <rtems/cpu.h>
-#include <rtems/event.h>
-#include <rtems/fatal.h>
-#include <rtems/intthrd.h>
-#include <rtems/message.h>
-#include <rtems/mp.h>
-#include <rtems/mpci.h>
-#include <rtems/mppkt.h>
-#include <rtems/part.h>
-#include <rtems/sem.h>
-#include <rtems/signal.h>
-#include <rtems/states.h>
-#include <rtems/tasks.h>
-#include <rtems/thread.h>
-#include <rtems/threadq.h>
-#include <rtems/watchdog.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/mp.h>
+#include <rtems/core/mpci.h>
/*PAGE
*
@@ -40,11 +26,6 @@
void _Multiprocessing_Manager_initialization ( void )
{
- if ( _Configuration_MP_table->node < 1 ||
- _Configuration_MP_table->node > _Configuration_MP_table->maximum_nodes )
- rtems_fatal_error_occurred( RTEMS_INVALID_NODE );
-
- _Internal_threads_Set_MP_receive_server( _Multiprocessing_Receive_server );
}
/*PAGE
@@ -55,67 +36,7 @@ void _Multiprocessing_Manager_initialization ( void )
void rtems_multiprocessing_announce ( void )
{
- _Thread_Disable_dispatch();
- _Event_sets_Post(
- RTEMS_EVENT_0,
- &_Internal_threads_System_initialization_thread->RTEMS_API->pending_events
- );
- _Event_Surrender( _Internal_threads_System_initialization_thread );
- _Thread_Enable_dispatch();
-}
-
-/*PAGE
- *
- * _Multiprocessing_Receive_server
- *
- */
-
-typedef void (*packet_processor)( rtems_packet_prefix * );
-
-packet_processor _Multiprocessor_Packet_processors[] = {
- _Internal_threads_MP_Process_packet, /* RTEMS_MP_PACKET_INTERNAL_THREADS */
- _RTEMS_tasks_MP_Process_packet, /* RTEMS_MP_PACKET_TASKS */
- _Message_queue_MP_Process_packet, /* RTEMS_MP_PACKET_MESSAGE_QUEUE */
- _Semaphore_MP_Process_packet, /* RTEMS_MP_PACKET_SEMAPHORE */
- _Partition_MP_Process_packet, /* RTEMS_MP_PACKET_PARTITION */
- 0, /* RTEMS_MP_PACKET_REGION */
- _Event_MP_Process_packet, /* RTEMS_MP_PACKET_EVENT */
- _Signal_MP_Process_packet /* RTEMS_MP_PACKET_SIGNAL */
-};
-
-Thread _Multiprocessing_Receive_server (
- Thread_Argument ignored
-)
-{
-
- rtems_packet_prefix *the_packet;
- packet_processor the_function;
-
- for ( ; ; ) {
-
- _Thread_Disable_dispatch();
- _Event_Seize( RTEMS_EVENT_0, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT );
- _Thread_Enable_dispatch();
-
- for ( ; ; ) {
- the_packet = _MPCI_Receive_packet();
-
- if ( !the_packet )
- break;
-
- _Thread_Executing->receive_packet = the_packet;
-
- if ( !_Mp_packet_Is_valid_packet_class ( the_packet->the_class ) )
- break;
-
- the_function = _Multiprocessor_Packet_processors[ the_packet->the_class ];
-
- if ( !the_function )
- break;
-
- (*the_function)( the_packet );
- }
- }
+ _MPCI_Announce();
}
/* end of file */
diff --git a/cpukit/rtems/src/msg.c b/cpukit/rtems/src/msg.c
index ff4683f880..a69ae777c6 100644
--- a/cpukit/rtems/src/msg.c
+++ b/cpukit/rtems/src/msg.c
@@ -14,18 +14,19 @@
*/
#include <rtems/system.h>
-#include <rtems/attr.h>
-#include <rtems/chain.h>
-#include <rtems/config.h>
-#include <rtems/isr.h>
-#include <rtems/message.h>
-#include <rtems/object.h>
-#include <rtems/options.h>
-#include <rtems/states.h>
-#include <rtems/support.h>
-#include <rtems/thread.h>
-#include <rtems/wkspace.h>
-#include <rtems/mpci.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
*
@@ -54,6 +55,16 @@ void _Message_queue_Manager_initialization(
RTEMS_MAXIMUM_NAME_LENGTH,
FALSE
);
+
+ /*
+ * Register the MP Process Packet routine.
+ */
+
+ _MPCI_Register_packet_processor(
+ MP_PACKET_MESSAGE_QUEUE,
+ _Message_queue_MP_Process_packet
+ );
+
}
/*PAGE
@@ -72,7 +83,7 @@ Message_queue_Control *_Message_queue_Allocate (
unsigned32 message_buffering_required;
unsigned32 allocated_message_size;
- mq = \
+ mq =
(Message_queue_Control *)_Objects_Allocate(&_Message_queue_Information);
if (mq == 0)
@@ -144,11 +155,11 @@ rtems_status_code rtems_message_queue_create(
register Message_queue_Control *the_message_queue;
if ( !rtems_is_name_valid( name ) )
- return ( RTEMS_INVALID_NAME );
+ return RTEMS_INVALID_NAME;
- if ( _Attributes_Is_global( attribute_set ) &&
- !_Configuration_Is_multiprocessing() )
- return( RTEMS_MP_NOT_CONFIGURED );
+ if ( _Attributes_Is_global( attribute_set ) &&
+ !_System_state_Is_multiprocessing )
+ return RTEMS_MP_NOT_CONFIGURED;
if (count == 0)
return RTEMS_INVALID_NUMBER;
@@ -164,8 +175,7 @@ rtems_status_code rtems_message_queue_create(
*/
if ( _Attributes_Is_global( attribute_set ) &&
- _Configuration_MPCI_table &&
- (_Configuration_MPCI_table->maximum_packet_size < max_message_size))
+ (_MPCI_table->maximum_packet_size < max_message_size))
{
return RTEMS_INVALID_SIZE;
}
@@ -177,7 +187,7 @@ rtems_status_code rtems_message_queue_create(
if ( !the_message_queue ) {
_Thread_Enable_dispatch();
- return( RTEMS_TOO_MANY );
+ return RTEMS_TOO_MANY;
}
if ( _Attributes_Is_global( attribute_set ) &&
@@ -201,7 +211,8 @@ rtems_status_code rtems_message_queue_create(
_Attributes_Is_priority( attribute_set ) ?
THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO,
STATES_WAITING_FOR_MESSAGE,
- _Message_queue_MP_Send_extract_proxy
+ _Message_queue_MP_Send_extract_proxy,
+ RTEMS_TIMEOUT
);
_Objects_Open(
@@ -221,7 +232,7 @@ rtems_status_code rtems_message_queue_create(
);
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -248,12 +259,16 @@ rtems_status_code rtems_message_queue_ident(
Objects_Id *id
)
{
- return _Objects_Name_to_id(
+ Objects_Name_to_id_errors status;
+
+ status = _Objects_Name_to_id(
&_Message_queue_Information,
&name,
node,
id
);
+
+ return _Status_Object_name_errors_to_status[ status ];
}
/*PAGE
@@ -281,10 +296,10 @@ rtems_status_code rtems_message_queue_delete(
the_message_queue = _Message_queue_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:
_Objects_Close( &_Message_queue_Information,
&the_message_queue->Object );
@@ -294,7 +309,8 @@ rtems_status_code rtems_message_queue_delete(
else
_Thread_queue_Flush(
&the_message_queue->Wait_queue,
- _Message_queue_MP_Send_object_was_deleted
+ _Message_queue_MP_Send_object_was_deleted,
+ RTEMS_OBJECT_WAS_DELETED
);
_Message_queue_Free( the_message_queue );
@@ -314,10 +330,10 @@ rtems_status_code rtems_message_queue_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
@@ -403,7 +419,7 @@ rtems_status_code rtems_message_queue_broadcast(
the_message_queue = _Message_queue_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
_Thread_Executing->Wait.return_argument = count;
@@ -436,7 +452,7 @@ rtems_status_code rtems_message_queue_broadcast(
waitp->return_argument,
constrained_size);
- *waitp->Extra.message_size_p = 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;
@@ -450,7 +466,7 @@ rtems_status_code rtems_message_queue_broadcast(
}
_Thread_Enable_dispatch();
*count = number_broadcasted;
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
default:
@@ -491,11 +507,9 @@ rtems_status_code rtems_message_queue_receive(
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
- _Thread_Executing->Wait.return_argument = buffer;
-
return _Message_queue_MP_Send_request_packet(
MESSAGE_QUEUE_MP_RECEIVE_REQUEST,
id,
@@ -517,7 +531,7 @@ rtems_status_code rtems_message_queue_receive(
return _Thread_Executing->Wait.return_code;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -549,7 +563,7 @@ rtems_status_code rtems_message_queue_flush(
the_message_queue = _Message_queue_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
_Thread_Executing->Wait.return_argument = count;
@@ -569,10 +583,10 @@ rtems_status_code rtems_message_queue_flush(
else
*count = 0;
_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
@@ -633,9 +647,9 @@ boolean _Message_queue_Seize(
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_set = option_set;
- executing->Wait.return_argument = (unsigned32 *)buffer;
- executing->Wait.Extra.message_size_p = size_p;
+ executing->Wait.option = option_set;
+ executing->Wait.return_argument = (void *)buffer;
+ executing->Wait.return_argument_1 = (void *)size_p;
_ISR_Enable( level );
return FALSE;
}
@@ -724,7 +738,7 @@ rtems_status_code _Message_queue_Submit(
switch ( location )
{
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
switch ( submit_type ) {
@@ -770,7 +784,7 @@ rtems_status_code _Message_queue_Submit(
the_thread->Wait.return_argument,
size
);
- *the_thread->Wait.Extra.message_size_p = 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;
@@ -783,7 +797,7 @@ rtems_status_code _Message_queue_Submit(
}
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
/*
@@ -794,13 +808,13 @@ rtems_status_code _Message_queue_Submit(
if ( the_message_queue->number_of_pending_messages ==
the_message_queue->maximum_pending_messages ) {
_Thread_Enable_dispatch();
- return( RTEMS_TOO_MANY );
+ return RTEMS_TOO_MANY;
}
the_message = _Message_queue_Allocate_message_buffer(the_message_queue);
if ( the_message == 0) {
_Thread_Enable_dispatch();
- return( RTEMS_UNSATISFIED );
+ return RTEMS_UNSATISFIED;
}
_Message_queue_Copy_buffer( buffer, the_message->Contents.buffer, size );
@@ -818,7 +832,7 @@ rtems_status_code _Message_queue_Submit(
}
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
default:
return RTEMS_INTERNAL_ERROR; /* And they were such nice boys, too! */
diff --git a/cpukit/rtems/src/msgmp.c b/cpukit/rtems/src/msgmp.c
index 48e572c43b..06afd4eedc 100644
--- a/cpukit/rtems/src/msgmp.c
+++ b/cpukit/rtems/src/msgmp.c
@@ -14,14 +14,15 @@
*/
#include <rtems/system.h>
-#include <rtems/message.h>
-#include <rtems/mpci.h>
-#include <rtems/msgmp.h>
-#include <rtems/object.h>
-#include <rtems/options.h>
-#include <rtems/thread.h>
-#include <rtems/watchdog.h>
-#include <rtems/config.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/message.h>
+#include <rtems/core/mpci.h>
+#include <rtems/rtems/msgmp.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/options.h>
+#include <rtems/core/thread.h>
+#include <rtems/core/watchdog.h>
+#include <rtems/rtems/support.h>
/*PAGE
*
@@ -46,7 +47,7 @@ void _Message_queue_MP_Send_process_packet (
case MESSAGE_QUEUE_MP_EXTRACT_PROXY:
the_packet = _Message_queue_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_MESSAGE_QUEUE;
+ the_packet->Prefix.the_class = MP_PACKET_MESSAGE_QUEUE;
the_packet->Prefix.length = sizeof ( Message_queue_MP_Packet );
the_packet->Prefix.to_convert = sizeof ( Message_queue_MP_Packet );
the_packet->operation = operation;
@@ -102,10 +103,10 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
the_packet = _Message_queue_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_MESSAGE_QUEUE;
+ the_packet->Prefix.the_class = MP_PACKET_MESSAGE_QUEUE;
the_packet->Prefix.length = sizeof(Message_queue_MP_Packet);
if ( size_p )
- the_packet->Prefix.length += *size_p;
+ the_packet->Prefix.length += *size_p;
the_packet->Prefix.to_convert = sizeof(Message_queue_MP_Packet);
/*
@@ -114,9 +115,7 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
* we are about to slam in the payload
*/
- if (the_packet->Prefix.length >
- _Configuration_MPCI_table->maximum_packet_size)
- {
+ if (the_packet->Prefix.length > _MPCI_table->maximum_packet_size) {
_Thread_Enable_dispatch();
return RTEMS_INVALID_SIZE;
}
@@ -132,8 +131,7 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
* Copy the data into place if needed
*/
- if (buffer)
- {
+ if (buffer) {
the_packet->Buffer.size = *size_p;
_Message_queue_Copy_buffer(buffer,
the_packet->Buffer.buffer,
@@ -148,7 +146,7 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
case MESSAGE_QUEUE_MP_RECEIVE_REQUEST:
the_packet = _Message_queue_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_MESSAGE_QUEUE;
+ the_packet->Prefix.the_class = MP_PACKET_MESSAGE_QUEUE;
the_packet->Prefix.length = sizeof(Message_queue_MP_Packet);
the_packet->Prefix.to_convert = sizeof(Message_queue_MP_Packet);
@@ -160,8 +158,8 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
the_packet->option_set = option_set;
the_packet->size = 0; /* just in case of an error */
- _Thread_Executing->Wait.return_argument = (unsigned32 *)buffer;
- _Thread_Executing->Wait.Extra.message_size_p = size_p;
+ _Thread_Executing->Wait.return_argument = (unsigned32 *)buffer;
+ _Thread_Executing->Wait.return_argument_1 = size_p;
return _MPCI_Send_request_packet(rtems_get_node(message_queue_id),
&the_packet->Prefix,
@@ -296,7 +294,7 @@ void _Message_queue_MP_Process_packet (
the_packet->Prefix.timeout
);
- if ( ! _Status_Is_proxy_blocking( the_packet->Prefix.return_code ) )
+ if ( ! _Thread_Is_proxy_blocking( the_packet->Prefix.return_code ) )
_Message_queue_MP_Send_response_packet(
MESSAGE_QUEUE_MP_RECEIVE_RESPONSE,
the_packet->Prefix.id,
@@ -309,7 +307,8 @@ void _Message_queue_MP_Process_packet (
the_thread = _MPCI_Process_response( the_packet_prefix );
if (the_packet->Prefix.return_code == RTEMS_SUCCESSFUL) {
- *the_thread->Wait.Extra.message_size_p = the_packet->size;
+ *(rtems_unsigned32 *)the_thread->Wait.return_argument_1 =
+ the_packet->size;
_Message_queue_Copy_buffer(
the_packet->Buffer.buffer,
diff --git a/cpukit/rtems/src/part.c b/cpukit/rtems/src/part.c
index 3d21eed416..ee714f64c1 100644
--- a/cpukit/rtems/src/part.c
+++ b/cpukit/rtems/src/part.c
@@ -14,12 +14,13 @@
*/
#include <rtems/system.h>
-#include <rtems/support.h>
-#include <rtems/address.h>
-#include <rtems/config.h>
-#include <rtems/object.h>
-#include <rtems/part.h>
-#include <rtems/thread.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/support.h>
+#include <rtems/core/address.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/part.h>
+#include <rtems/core/thread.h>
+#include <rtems/sysstate.h>
/*PAGE
*
@@ -49,6 +50,15 @@ void _Partition_Manager_initialization(
FALSE
);
+ /*
+ * Register the MP Process Packet routine.
+ */
+
+ _MPCI_Register_packet_processor(
+ MP_PACKET_PARTITION,
+ _Partition_MP_Process_packet
+ );
+
}
/*PAGE
@@ -84,18 +94,18 @@ rtems_status_code rtems_partition_create(
register Partition_Control *the_partition;
if ( !rtems_is_name_valid( name ) )
- return ( RTEMS_INVALID_NAME );
+ return RTEMS_INVALID_NAME;
if ( length == 0 || buffer_size == 0 || length < buffer_size ||
!_Partition_Is_buffer_size_aligned( buffer_size ) )
- return ( RTEMS_INVALID_SIZE );
+ return RTEMS_INVALID_SIZE;
if ( !_Addresses_Is_aligned( starting_address ) )
- return( RTEMS_INVALID_ADDRESS );
+ return RTEMS_INVALID_ADDRESS;
- if ( _Attributes_Is_global( attribute_set ) &&
- !_Configuration_Is_multiprocessing() )
- return( RTEMS_MP_NOT_CONFIGURED );
+ if ( _Attributes_Is_global( attribute_set ) &&
+ !_System_state_Is_multiprocessing )
+ return RTEMS_MP_NOT_CONFIGURED;
_Thread_Disable_dispatch(); /* prevents deletion */
@@ -103,7 +113,7 @@ rtems_status_code rtems_partition_create(
if ( !the_partition ) {
_Thread_Enable_dispatch();
- return( RTEMS_TOO_MANY );
+ return RTEMS_TOO_MANY;
}
if ( _Attributes_Is_global( attribute_set ) &&
@@ -111,7 +121,7 @@ rtems_status_code rtems_partition_create(
the_partition->Object.id, FALSE ) ) ) {
_Partition_Free( the_partition );
_Thread_Enable_dispatch();
- return( RTEMS_TOO_MANY );
+ return RTEMS_TOO_MANY;
}
the_partition->starting_address = starting_address;
the_partition->length = length;
@@ -134,7 +144,7 @@ rtems_status_code rtems_partition_create(
);
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -161,7 +171,11 @@ rtems_status_code rtems_partition_ident(
Objects_Id *id
)
{
- return _Objects_Name_to_id( &_Partition_Information, &name, node, id );
+ Objects_Name_to_id_errors status;
+
+ status = _Objects_Name_to_id( &_Partition_Information, &name, node, id );
+
+ return _Status_Object_name_errors_to_status[ status ];
}
/*PAGE
@@ -190,10 +204,10 @@ rtems_status_code rtems_partition_delete(
the_partition = _Partition_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 ( the_partition->number_of_used_blocks == 0 ) {
_Objects_Close( &_Partition_Information, &the_partition->Object );
@@ -214,13 +228,13 @@ rtems_status_code rtems_partition_delete(
}
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
_Thread_Enable_dispatch();
- return( RTEMS_RESOURCE_IN_USE );
+ return RTEMS_RESOURCE_IN_USE;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -251,7 +265,7 @@ rtems_status_code rtems_partition_get_buffer(
the_partition = _Partition_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
_Thread_Executing->Wait.return_argument = buffer;
return(
@@ -267,13 +281,13 @@ rtems_status_code rtems_partition_get_buffer(
the_partition->number_of_used_blocks += 1;
_Thread_Enable_dispatch();
*buffer = the_buffer;
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
_Thread_Enable_dispatch();
- return( RTEMS_UNSATISFIED );
+ return RTEMS_UNSATISFIED;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -303,7 +317,7 @@ rtems_status_code rtems_partition_return_buffer(
the_partition = _Partition_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
return(
_Partition_MP_Send_request_packet(
@@ -317,11 +331,11 @@ rtems_status_code rtems_partition_return_buffer(
_Partition_Free_buffer( the_partition, buffer );
the_partition->number_of_used_blocks -= 1;
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
_Thread_Enable_dispatch();
- return( RTEMS_INVALID_ADDRESS );
+ return RTEMS_INVALID_ADDRESS;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
diff --git a/cpukit/rtems/src/partmp.c b/cpukit/rtems/src/partmp.c
index 0097844183..8fc36c6a04 100644
--- a/cpukit/rtems/src/partmp.c
+++ b/cpukit/rtems/src/partmp.c
@@ -14,12 +14,14 @@
*/
#include <rtems/system.h>
-#include <rtems/mpci.h>
-#include <rtems/mppkt.h>
-#include <rtems/object.h>
-#include <rtems/options.h>
-#include <rtems/part.h>
-#include <rtems/thread.h>
+#include <rtems/rtems/status.h>
+#include <rtems/core/mpci.h>
+#include <rtems/core/mppkt.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/options.h>
+#include <rtems/rtems/part.h>
+#include <rtems/core/thread.h>
+#include <rtems/rtems/support.h>
/*PAGE
*
@@ -44,7 +46,7 @@ void _Partition_MP_Send_process_packet (
case PARTITION_MP_EXTRACT_PROXY:
the_packet = _Partition_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_PARTITION;
+ the_packet->Prefix.the_class = MP_PACKET_PARTITION;
the_packet->Prefix.length = sizeof ( Partition_MP_Packet );
the_packet->Prefix.to_convert = sizeof ( Partition_MP_Packet );
the_packet->operation = operation;
@@ -88,7 +90,7 @@ rtems_status_code _Partition_MP_Send_request_packet (
case PARTITION_MP_RETURN_BUFFER_REQUEST:
the_packet = _Partition_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_PARTITION;
+ the_packet->Prefix.the_class = MP_PACKET_PARTITION;
the_packet->Prefix.length = sizeof ( Partition_MP_Packet );
the_packet->Prefix.to_convert = sizeof ( Partition_MP_Packet );
the_packet->operation = operation;
diff --git a/cpukit/rtems/src/ratemon.c b/cpukit/rtems/src/ratemon.c
index c98de762af..a94ba66ea0 100644
--- a/cpukit/rtems/src/ratemon.c
+++ b/cpukit/rtems/src/ratemon.c
@@ -14,11 +14,12 @@
*/
#include <rtems/system.h>
-#include <rtems/support.h>
-#include <rtems/isr.h>
-#include <rtems/object.h>
-#include <rtems/ratemon.h>
-#include <rtems/thread.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/support.h>
+#include <rtems/core/isr.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/ratemon.h>
+#include <rtems/core/thread.h>
/*PAGE
*
@@ -77,7 +78,7 @@ rtems_status_code rtems_rate_monotonic_create(
Rate_monotonic_Control *the_period;
if ( !rtems_is_name_valid( name ) )
- return( RTEMS_INVALID_NAME );
+ return RTEMS_INVALID_NAME;
_Thread_Disable_dispatch(); /* to prevent deletion */
@@ -85,7 +86,7 @@ rtems_status_code rtems_rate_monotonic_create(
if ( !the_period ) {
_Thread_Enable_dispatch();
- return( RTEMS_TOO_MANY );
+ return RTEMS_TOO_MANY;
}
the_period->owner = _Thread_Executing;
@@ -95,7 +96,7 @@ rtems_status_code rtems_rate_monotonic_create(
*id = the_period->Object.id;
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -120,12 +121,16 @@ rtems_status_code rtems_rate_monotonic_ident(
Objects_Id *id
)
{
- return _Objects_Name_to_id(
+ Objects_Name_to_id_errors status;
+
+ status = _Objects_Name_to_id(
&_Rate_monotonic_Information,
&name,
- RTEMS_SEARCH_LOCAL_NODE,
+ OBJECTS_SEARCH_LOCAL_NODE,
id
);
+
+ return _Status_Object_name_errors_to_status[ status ];
}
/*PAGE
@@ -152,21 +157,21 @@ rtems_status_code rtems_rate_monotonic_cancel(
the_period = _Rate_monotonic_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
- case OBJECTS_REMOTE: /* should never return this */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INVALID_ID;
+ case OBJECTS_REMOTE:
+ return RTEMS_INTERNAL_ERROR; /* should never return this */
case OBJECTS_LOCAL:
if ( !_Thread_Is_executing( the_period->owner ) ) {
_Thread_Enable_dispatch();
- return( RTEMS_NOT_OWNER_OF_RESOURCE );
+ return RTEMS_NOT_OWNER_OF_RESOURCE;
}
(void) _Watchdog_Remove( &the_period->Timer );
the_period->state = RATE_MONOTONIC_INACTIVE;
_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
@@ -193,19 +198,19 @@ rtems_status_code rtems_rate_monotonic_delete(
the_period = _Rate_monotonic_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* should never return this */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
_Objects_Close( &_Rate_monotonic_Information, &the_period->Object );
(void) _Watchdog_Remove( &the_period->Timer );
the_period->state = RATE_MONOTONIC_INACTIVE;
_Rate_monotonic_Free( the_period );
_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
@@ -225,23 +230,23 @@ rtems_status_code rtems_rate_monotonic_delete(
rtems_status_code rtems_rate_monotonic_period(
Objects_Id id,
- rtems_interval length
+ rtems_interval length
)
{
Rate_monotonic_Control *the_period;
Objects_Locations location;
- rtems_status_code return_value;
+ rtems_status_code return_value;
the_period = _Rate_monotonic_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* should never return this */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
if ( !_Thread_Is_executing( the_period->owner ) ) {
_Thread_Enable_dispatch();
- return( RTEMS_NOT_OWNER_OF_RESOURCE );
+ return RTEMS_NOT_OWNER_OF_RESOURCE;
}
if ( length == RTEMS_PERIOD_STATUS ) {
@@ -275,14 +280,14 @@ rtems_status_code rtems_rate_monotonic_period(
_Watchdog_Insert_ticks(
&the_period->Timer, length, WATCHDOG_ACTIVATE_NOW );
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
case RATE_MONOTONIC_ACTIVE:
/* following is and could be a critical section problem */
_Thread_Executing->Wait.id = the_period->Object.id;
if ( _Rate_monotonic_Set_state( the_period ) ) {
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
/* has expired -- fall into next case */
case RATE_MONOTONIC_EXPIRED:
@@ -290,11 +295,11 @@ rtems_status_code rtems_rate_monotonic_period(
_Watchdog_Insert_ticks(
&the_period->Timer, length, WATCHDOG_ACTIVATE_NOW );
_Thread_Enable_dispatch();
- return( RTEMS_TIMEOUT );
+ return RTEMS_TIMEOUT;
}
}
- 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/region.c b/cpukit/rtems/src/region.c
index 25aca9cda7..b5d55afdc3 100644
--- a/cpukit/rtems/src/region.c
+++ b/cpukit/rtems/src/region.c
@@ -14,13 +14,13 @@
*/
#include <rtems/system.h>
-#include <rtems/support.h>
-#include <rtems/config.h>
-#include <rtems/object.h>
-#include <rtems/options.h>
-#include <rtems/region.h>
-#include <rtems/states.h>
-#include <rtems/thread.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/support.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/options.h>
+#include <rtems/rtems/region.h>
+#include <rtems/core/states.h>
+#include <rtems/core/thread.h>
/*PAGE
*
@@ -48,6 +48,16 @@ void _Region_Manager_initialization(
RTEMS_MAXIMUM_NAME_LENGTH,
FALSE
);
+
+ /*
+ * Register the MP Process Packet routine.
+ */
+
+ _MPCI_Register_packet_processor(
+ MP_PACKET_REGION,
+ 0 /* XXX _Region_MP_Process_packet */
+ );
+
}
/*PAGE
@@ -83,10 +93,10 @@ rtems_status_code rtems_region_create(
Region_Control *the_region;
if ( !rtems_is_name_valid( name ) )
- return ( RTEMS_INVALID_NAME );
+ return RTEMS_INVALID_NAME;
if ( !_Addresses_Is_aligned( starting_address ) )
- return( RTEMS_INVALID_ADDRESS );
+ return RTEMS_INVALID_ADDRESS;
_Thread_Disable_dispatch(); /* to prevent deletion */
@@ -94,7 +104,7 @@ rtems_status_code rtems_region_create(
if ( !the_region ) {
_Thread_Enable_dispatch();
- return( RTEMS_TOO_MANY );
+ return RTEMS_TOO_MANY;
}
the_region->maximum_segment_size =
@@ -103,7 +113,7 @@ rtems_status_code rtems_region_create(
if ( !the_region->maximum_segment_size ) {
_Region_Free( the_region );
_Thread_Enable_dispatch();
- return( RTEMS_INVALID_SIZE );
+ return RTEMS_INVALID_SIZE;
}
the_region->starting_address = starting_address;
@@ -118,14 +128,15 @@ rtems_status_code rtems_region_create(
_Attributes_Is_priority( attribute_set ) ?
THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO,
STATES_WAITING_FOR_SEGMENT,
- _Region_MP_Send_extract_proxy
+ _Region_MP_Send_extract_proxy,
+ RTEMS_TIMEOUT
);
_Objects_Open( &_Region_Information, &the_region->Object, &name );
*id = the_region->Object.id;
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -150,12 +161,16 @@ rtems_status_code rtems_region_ident(
Objects_Id *id
)
{
- return _Objects_Name_to_id(
- &_Region_Information,
- &name,
- RTEMS_SEARCH_LOCAL_NODE,
- id
- );
+ Objects_Name_to_id_errors status;
+
+ status = _Objects_Name_to_id(
+ &_Region_Information,
+ &name,
+ OBJECTS_SEARCH_LOCAL_NODE,
+ id
+ );
+
+ return _Status_Object_name_errors_to_status[ status ];
}
/*PAGE
@@ -184,22 +199,22 @@ rtems_status_code rtems_region_delete(
the_region = _Region_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* this error cannot be returned */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
_Region_Debug_Walk( the_region, 5 );
if ( the_region->number_of_used_blocks == 0 ) {
_Objects_Close( &_Region_Information, &the_region->Object );
_Region_Free( the_region );
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
_Thread_Enable_dispatch();
- return( RTEMS_RESOURCE_IN_USE );
+ return RTEMS_RESOURCE_IN_USE;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -236,9 +251,9 @@ rtems_status_code rtems_region_extend(
the_region = _Region_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* this error cannot be returned */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
heap_status = _Heap_Extend(
@@ -264,7 +279,7 @@ rtems_status_code rtems_region_extend(
return( status );
}
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -289,8 +304,8 @@ rtems_status_code rtems_region_extend(
rtems_status_code rtems_region_get_segment(
Objects_Id id,
unsigned32 size,
- rtems_option option_set,
- rtems_interval timeout,
+ rtems_option option_set,
+ rtems_interval timeout,
void **segment
)
{
@@ -300,19 +315,19 @@ rtems_status_code rtems_region_get_segment(
void *the_segment;
if ( size == 0 )
- return( RTEMS_INVALID_SIZE );
+ return RTEMS_INVALID_SIZE;
executing = _Thread_Executing;
the_region = _Region_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* this error cannot be returned */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
if ( size > the_region->maximum_segment_size ) {
_Thread_Enable_dispatch();
- return( RTEMS_INVALID_SIZE );
+ return RTEMS_INVALID_SIZE;
}
_Region_Debug_Walk( the_region, 1 );
@@ -325,18 +340,18 @@ rtems_status_code rtems_region_get_segment(
the_region->number_of_used_blocks += 1;
_Thread_Enable_dispatch();
*segment = the_segment;
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
if ( _Options_Is_no_wait( option_set ) ) {
_Thread_Enable_dispatch();
- return( RTEMS_UNSATISFIED );
+ return RTEMS_UNSATISFIED;
}
- executing->Wait.queue = &the_region->Wait_queue;
- executing->Wait.id = id;
- executing->Wait.Extra.segment_size = size;
- executing->Wait.return_argument = (unsigned32 *) segment;
+ executing->Wait.queue = &the_region->Wait_queue;
+ executing->Wait.id = id;
+ executing->Wait.count = size;
+ executing->Wait.return_argument = (unsigned32 *) segment;
the_region->Wait_queue.sync = TRUE;
@@ -346,7 +361,7 @@ rtems_status_code rtems_region_get_segment(
return( executing->Wait.return_code );
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
*
@@ -379,20 +394,20 @@ rtems_status_code rtems_region_get_segment_size(
the_region = _Region_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* this error cannot be returned */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
if ( _Heap_Size_of_user_area( &the_region->Memory, segment, size ) ) {
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
_Thread_Enable_dispatch();
- return( RTEMS_INVALID_ADDRESS );
+ return RTEMS_INVALID_ADDRESS;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -424,9 +439,9 @@ rtems_status_code rtems_region_return_segment(
the_region = _Region_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* this error cannot be returned */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
_Region_Debug_Walk( the_region, 3 );
@@ -437,7 +452,7 @@ rtems_status_code rtems_region_return_segment(
if ( !status ) {
_Thread_Enable_dispatch();
- return( RTEMS_INVALID_ADDRESS );
+ return RTEMS_INVALID_ADDRESS;
}
the_region->number_of_used_blocks -= 1;
@@ -448,7 +463,9 @@ rtems_status_code rtems_region_return_segment(
break;
the_segment = _Region_Allocate_segment(
- the_region, the_thread->Wait.Extra.segment_size );
+ the_region,
+ the_thread->Wait.count
+ );
if ( the_segment == NULL )
break;
@@ -460,8 +477,8 @@ rtems_status_code rtems_region_return_segment(
}
_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 */
}
diff --git a/cpukit/rtems/src/regionmp.c b/cpukit/rtems/src/regionmp.c
index b460e554fe..89b9d851c5 100644
--- a/cpukit/rtems/src/regionmp.c
+++ b/cpukit/rtems/src/regionmp.c
@@ -14,12 +14,14 @@
*/
#include <rtems/system.h>
-#include <rtems/mpci.h>
-#include <rtems/mppkt.h>
-#include <rtems/object.h>
-#include <rtems/options.h>
-#include <rtems/region.h>
-#include <rtems/thread.h>
+#include <rtems/rtems/status.h>
+#include <rtems/core/mpci.h>
+#include <rtems/core/mppkt.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/options.h>
+#include <rtems/rtems/region.h>
+#include <rtems/core/thread.h>
+#include <rtems/rtems/support.h>
/*PAGE
*
@@ -44,7 +46,7 @@ void _Region_MP_Send_process_packet (
case REGION_MP_EXTRACT_PROXY:
the_packet = _Region_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_REGION;
+ the_packet->Prefix.the_class = MP_PACKET_REGION;
the_packet->Prefix.length = sizeof ( Region_MP_Packet );
the_packet->Prefix.to_convert = sizeof ( Region_MP_Packet );
the_packet->operation = operation;
@@ -79,8 +81,8 @@ rtems_status_code _Region_MP_Send_request_packet (
Objects_Id region_id,
void *segment,
unsigned32 size,
- rtems_option option_set,
- rtems_interval timeout
+ rtems_option option_set,
+ rtems_interval timeout
)
{
Region_MP_Packet *the_packet;
@@ -91,7 +93,7 @@ rtems_status_code _Region_MP_Send_request_packet (
case REGION_MP_RETURN_SEGMENT_REQUEST:
the_packet = _Region_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_REGION;
+ the_packet->Prefix.the_class = MP_PACKET_REGION;
the_packet->Prefix.length = sizeof ( Region_MP_Packet );
the_packet->Prefix.to_convert = sizeof ( Region_MP_Packet );
if ( ! _Options_Is_no_wait(option_set))
diff --git a/cpukit/rtems/src/rtclock.c b/cpukit/rtems/src/rtclock.c
index f82baa6337..01f61374cf 100644
--- a/cpukit/rtems/src/rtclock.c
+++ b/cpukit/rtems/src/rtclock.c
@@ -13,12 +13,12 @@
*/
#include <rtems/system.h>
-#include <rtems/clock.h>
-#include <rtems/config.h>
-#include <rtems/isr.h>
-#include <rtems/thread.h>
-#include <rtems/tod.h>
-#include <rtems/watchdog.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/clock.h>
+#include <rtems/core/isr.h>
+#include <rtems/core/thread.h>
+#include <rtems/core/tod.h>
+#include <rtems/core/watchdog.h>
/*PAGE
*
@@ -49,29 +49,29 @@ rtems_status_code rtems_clock_get(
switch ( option ) {
case RTEMS_CLOCK_GET_TOD:
if ( !_TOD_Is_set() )
- return( RTEMS_NOT_DEFINED );
+ return RTEMS_NOT_DEFINED;
*(rtems_time_of_day *)time_buffer = _TOD_Current;
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
case RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH:
if ( !_TOD_Is_set() )
- return( RTEMS_NOT_DEFINED );
+ return RTEMS_NOT_DEFINED;
*(rtems_interval *)time_buffer = _TOD_Seconds_since_epoch;
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
case RTEMS_CLOCK_GET_TICKS_SINCE_BOOT:
*(rtems_interval *)time_buffer = _TOD_Ticks_since_boot;
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
case RTEMS_CLOCK_GET_TICKS_PER_SECOND:
*(rtems_interval *)time_buffer = _TOD_Ticks_per_second;
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
case RTEMS_CLOCK_GET_TIME_VALUE:
if ( !_TOD_Is_set() )
- return( RTEMS_NOT_DEFINED );
+ return RTEMS_NOT_DEFINED;
_ISR_Disable( level );
((rtems_clock_time_value *)time_buffer)->seconds =
@@ -79,13 +79,13 @@ rtems_status_code rtems_clock_get(
tmp = _TOD_Current.ticks;
_ISR_Enable( level );
- tmp *= _Configuration_Table->microseconds_per_tick;
+ tmp *= _TOD_Microseconds_per_tick;
((rtems_clock_time_value *)time_buffer)->microseconds = tmp;
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
- return( RTEMS_SUCCESSFUL ); /* should never get here */
+ return RTEMS_INTERNAL_ERROR; /* should never get here */
}
@@ -107,18 +107,16 @@ rtems_status_code rtems_clock_set(
rtems_time_of_day *time_buffer
)
{
- rtems_status_code local_result;
- rtems_interval seconds;
+ rtems_interval seconds;
- local_result = _TOD_Validate( time_buffer );
- if ( rtems_is_status_successful( local_result ) ) {
+ if ( _TOD_Validate( time_buffer ) ) {
seconds = _TOD_To_seconds( time_buffer );
_Thread_Disable_dispatch();
_TOD_Set( time_buffer, seconds );
_Thread_Enable_dispatch();
-
+ return RTEMS_SUCCESSFUL;
}
- return( local_result );
+ return RTEMS_INVALID_CLOCK;
}
/*PAGE
@@ -149,5 +147,5 @@ rtems_status_code rtems_clock_tick( void )
_Thread_Is_dispatching_enabled() )
_Thread_Dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/rtemstimer.c b/cpukit/rtems/src/rtemstimer.c
index 68d9e4591b..c59e137d0c 100644
--- a/cpukit/rtems/src/rtemstimer.c
+++ b/cpukit/rtems/src/rtemstimer.c
@@ -14,12 +14,13 @@
*/
#include <rtems/system.h>
-#include <rtems/support.h>
-#include <rtems/object.h>
-#include <rtems/thread.h>
-#include <rtems/timer.h>
-#include <rtems/tod.h>
-#include <rtems/watchdog.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/support.h>
+#include <rtems/core/object.h>
+#include <rtems/core/thread.h>
+#include <rtems/rtems/timer.h>
+#include <rtems/core/tod.h>
+#include <rtems/core/watchdog.h>
/*PAGE
*
@@ -73,7 +74,7 @@ rtems_status_code rtems_timer_create(
Timer_Control *the_timer;
if ( !rtems_is_name_valid( name ) )
- return ( RTEMS_INVALID_NAME );
+ return RTEMS_INVALID_NAME;
_Thread_Disable_dispatch(); /* to prevent deletion */
@@ -81,7 +82,7 @@ rtems_status_code rtems_timer_create(
if ( !the_timer ) {
_Thread_Enable_dispatch();
- return( RTEMS_TOO_MANY );
+ return RTEMS_TOO_MANY;
}
the_timer->the_class = TIMER_DORMANT;
@@ -90,7 +91,7 @@ rtems_status_code rtems_timer_create(
*id = the_timer->Object.id;
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -115,12 +116,16 @@ rtems_status_code rtems_timer_ident(
Objects_Id *id
)
{
- return _Objects_Name_to_id(
+ Objects_Name_to_id_errors status;
+
+ status = _Objects_Name_to_id(
&_Timer_Information,
&name,
- RTEMS_SEARCH_LOCAL_NODE,
+ OBJECTS_SEARCH_LOCAL_NODE,
id
);
+
+ return _Status_Object_name_errors_to_status[ status ];
}
/*PAGE
@@ -147,17 +152,17 @@ rtems_status_code rtems_timer_cancel(
the_timer = _Timer_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* should never return this */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
if ( !_Timer_Is_dormant_class( the_timer->the_class ) )
(void) _Watchdog_Remove( &the_timer->Ticker );
_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
@@ -184,18 +189,18 @@ rtems_status_code rtems_timer_delete(
the_timer = _Timer_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* should never return this */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
_Objects_Close( &_Timer_Information, &the_timer->Object );
(void) _Watchdog_Remove( &the_timer->Ticker );
_Timer_Free( the_timer );
_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
@@ -215,24 +220,24 @@ rtems_status_code rtems_timer_delete(
*/
rtems_status_code rtems_timer_fire_after(
- Objects_Id id,
- rtems_interval ticks,
- Timer_Service routine,
- void *user_data
+ Objects_Id id,
+ rtems_interval ticks,
+ rtems_timer_service_routine_entry routine,
+ void *user_data
)
{
Timer_Control *the_timer;
Objects_Locations location;
if ( ticks == 0 )
- return( RTEMS_INVALID_NUMBER );
+ return RTEMS_INVALID_NUMBER;
the_timer = _Timer_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* should never return this */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
(void) _Watchdog_Remove( &the_timer->Ticker );
the_timer->the_class = TIMER_INTERVAL;
@@ -240,10 +245,10 @@ rtems_status_code rtems_timer_fire_after(
_Watchdog_Insert_ticks( &the_timer->Ticker,
ticks, WATCHDOG_ACTIVATE_NOW );
_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
@@ -263,34 +268,32 @@ rtems_status_code rtems_timer_fire_after(
*/
rtems_status_code rtems_timer_fire_when(
- Objects_Id id,
- rtems_time_of_day *wall_time,
- Timer_Service routine,
- void *user_data
+ Objects_Id id,
+ rtems_time_of_day *wall_time,
+ rtems_timer_service_routine_entry routine,
+ void *user_data
)
{
- Timer_Control *the_timer;
- Objects_Locations location;
- rtems_status_code validate_status;
+ Timer_Control *the_timer;
+ Objects_Locations location;
rtems_interval seconds;
if ( !_TOD_Is_set() )
- return( RTEMS_NOT_DEFINED );
+ return RTEMS_NOT_DEFINED;
- validate_status = _TOD_Validate( wall_time );
- if ( !rtems_is_status_successful( validate_status ) )
- return( validate_status );
+ if ( !_TOD_Validate( wall_time ) )
+ return RTEMS_INVALID_CLOCK;
seconds = _TOD_To_seconds( wall_time );
if ( seconds <= _TOD_Seconds_since_epoch )
- return( RTEMS_INVALID_CLOCK );
+ return RTEMS_INVALID_CLOCK;
the_timer = _Timer_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* should never return this */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
(void) _Watchdog_Remove( &the_timer->Ticker );
the_timer->the_class = TIMER_TIME_OF_DAY;
@@ -298,10 +301,10 @@ rtems_status_code rtems_timer_fire_when(
_Watchdog_Insert_seconds( &the_timer->Ticker,
seconds - _TOD_Seconds_since_epoch, WATCHDOG_ACTIVATE_NOW );
_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
@@ -328,18 +331,18 @@ rtems_status_code rtems_timer_reset(
the_timer = _Timer_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE: /* should never return this */
- return( RTEMS_INTERNAL_ERROR );
+ return RTEMS_INTERNAL_ERROR;
case OBJECTS_LOCAL:
if ( _Timer_Is_interval_class( the_timer->the_class ) ) {
_Watchdog_Reset( &the_timer->Ticker );
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
_Thread_Enable_dispatch();
- return( RTEMS_NOT_DEFINED );
+ return RTEMS_NOT_DEFINED;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
diff --git a/cpukit/rtems/src/sem.c b/cpukit/rtems/src/sem.c
index 9e87550c31..9ba1634164 100644
--- a/cpukit/rtems/src/sem.c
+++ b/cpukit/rtems/src/sem.c
@@ -27,17 +27,22 @@
*/
#include <rtems/system.h>
-#include <rtems/support.h>
-#include <rtems/attr.h>
-#include <rtems/config.h>
-#include <rtems/isr.h>
-#include <rtems/object.h>
-#include <rtems/options.h>
-#include <rtems/sem.h>
-#include <rtems/states.h>
-#include <rtems/thread.h>
-#include <rtems/threadq.h>
-#include <rtems/mpci.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/support.h>
+#include <rtems/rtems/attr.h>
+#include <rtems/core/isr.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/options.h>
+#include <rtems/rtems/sem.h>
+#include <rtems/core/coremutex.h>
+#include <rtems/core/coresem.h>
+#include <rtems/core/states.h>
+#include <rtems/core/thread.h>
+#include <rtems/core/threadq.h>
+#include <rtems/core/mpci.h>
+#include <rtems/sysstate.h>
+
+#include <rtems/core/interr.h>
/*PAGE
*
@@ -65,6 +70,16 @@ void _Semaphore_Manager_initialization(
RTEMS_MAXIMUM_NAME_LENGTH,
FALSE
);
+
+ /*
+ * Register the MP Process Packet routine.
+ */
+
+ _MPCI_Register_packet_processor(
+ MP_PACKET_SEMAPHORE,
+ _Semaphore_MP_Process_packet
+ );
+
}
/*PAGE
@@ -75,10 +90,11 @@ void _Semaphore_Manager_initialization(
* on the given count. A semaphore id is returned.
*
* Input parameters:
- * name - user defined semaphore name
- * count - initial count of semaphore
- * attribute_set - semaphore attributes
- * id - pointer to semaphore id
+ * name - user defined semaphore name
+ * count - initial count of semaphore
+ * attribute_set - semaphore attributes
+ * priority_ceiling - semaphore's ceiling priority
+ * id - pointer to semaphore id
*
* Output parameters:
* id - semaphore id
@@ -87,21 +103,24 @@ void _Semaphore_Manager_initialization(
*/
rtems_status_code rtems_semaphore_create(
- rtems_name name,
- unsigned32 count,
- rtems_attribute attribute_set,
- rtems_task_priority priority_ceiling,
- Objects_Id *id
+ rtems_name name,
+ unsigned32 count,
+ rtems_attribute attribute_set,
+ rtems_task_priority priority_ceiling,
+ Objects_Id *id
)
{
register Semaphore_Control *the_semaphore;
+ CORE_mutex_Attributes the_mutex_attributes;
+ CORE_semaphore_Attributes the_semaphore_attributes;
+ unsigned32 lock;
if ( !rtems_is_name_valid( name ) )
return ( RTEMS_INVALID_NAME );
if ( _Attributes_Is_global( attribute_set ) ) {
- if ( !_Configuration_Is_multiprocessing() )
+ if ( !_System_state_Is_multiprocessing )
return( RTEMS_MP_NOT_CONFIGURED );
if ( _Attributes_Is_inherit_priority( attribute_set ) )
@@ -128,7 +147,7 @@ rtems_status_code rtems_semaphore_create(
}
if ( _Attributes_Is_global( attribute_set ) &&
- !( _Objects_MP_Allocate_and_open( &_Semaphore_Information, name,
+ ! ( _Objects_MP_Allocate_and_open( &_Semaphore_Information, name,
the_semaphore->Object.id, FALSE ) ) ) {
_Semaphore_Free( the_semaphore );
_Thread_Enable_dispatch();
@@ -136,27 +155,48 @@ rtems_status_code rtems_semaphore_create(
}
the_semaphore->attribute_set = attribute_set;
- the_semaphore->count = count;
-
- if ( _Attributes_Is_binary_semaphore( attribute_set ) && count == 0 ) {
- the_semaphore->nest_count = 1;
- the_semaphore->holder = _Thread_Executing;
- the_semaphore->holder_id = _Thread_Executing->Object.id;
- _Thread_Executing->resource_count++;
- } else {
- the_semaphore->nest_count = 0;
- the_semaphore->holder = NULL;
- the_semaphore->holder_id = 0;
- }
- _Thread_queue_Initialize(
- &the_semaphore->Wait_queue,
- OBJECTS_RTEMS_SEMAPHORES,
- _Attributes_Is_priority( attribute_set ) ?
- THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO,
- STATES_WAITING_FOR_SEMAPHORE,
- _Semaphore_MP_Send_extract_proxy
- );
+ if ( _Attributes_Is_binary_semaphore( attribute_set ) ) {
+ if ( _Attributes_Is_inherit_priority( attribute_set ) )
+ the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT;
+ else if (_Attributes_Is_priority_ceiling( attribute_set ) )
+ the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING;
+ else if (_Attributes_Is_priority( attribute_set ) )
+ the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY;
+ else
+ the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_FIFO;
+
+ the_mutex_attributes.allow_nesting = TRUE;
+
+ /* Add priority ceiling code here ????? */
+
+ if ( count == 1 )
+ lock = CORE_MUTEX_UNLOCKED;
+ else
+ lock = CORE_MUTEX_LOCKED;
+
+ _CORE_mutex_Initialize(
+ &the_semaphore->Core_control.mutex,
+ OBJECTS_RTEMS_SEMAPHORES,
+ &the_mutex_attributes,
+ lock,
+ _Semaphore_MP_Send_extract_proxy
+ );
+ }
+ else {
+ if ( _Attributes_Is_priority( attribute_set ) )
+ the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY;
+ else
+ the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO;
+
+ _CORE_semaphore_Initialize(
+ &the_semaphore->Core_control.semaphore,
+ OBJECTS_RTEMS_SEMAPHORES,
+ &the_semaphore_attributes,
+ count,
+ _Semaphore_MP_Send_extract_proxy
+ );
+ }
_Objects_Open( &_Semaphore_Information, &the_semaphore->Object, &name );
@@ -192,12 +232,16 @@ rtems_status_code rtems_semaphore_create(
*/
rtems_status_code rtems_semaphore_ident(
- rtems_name name,
- unsigned32 node,
- Objects_Id *id
+ rtems_name name,
+ unsigned32 node,
+ Objects_Id *id
)
{
- return( _Objects_Name_to_id( &_Semaphore_Information, &name, node, id ) );
+ Objects_Name_to_id_errors status;
+
+ status = _Objects_Name_to_id( &_Semaphore_Information, &name, node, id );
+
+ return _Status_Object_name_errors_to_status[ status ];
}
/*PAGE
@@ -231,19 +275,27 @@ rtems_status_code rtems_semaphore_delete(
_Thread_Dispatch();
return( RTEMS_ILLEGAL_ON_REMOTE_OBJECT );
case OBJECTS_LOCAL:
- if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set) &&
- ( the_semaphore->count == 0 ) ) {
- _Thread_Enable_dispatch();
- return( RTEMS_RESOURCE_IN_USE );
+ 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 );
+ }
+ else
+ _CORE_mutex_Flush(
+ &the_semaphore->Core_control.mutex,
+ _Semaphore_MP_Send_object_was_deleted,
+ CORE_MUTEX_WAS_DELETED
+ );
}
+ else
+ _CORE_semaphore_Flush(
+ &the_semaphore->Core_control.semaphore,
+ _Semaphore_MP_Send_object_was_deleted,
+ CORE_SEMAPHORE_WAS_DELETED
+ );
_Objects_Close( &_Semaphore_Information, &the_semaphore->Object );
- _Thread_queue_Flush(
- &the_semaphore->Wait_queue,
- _Semaphore_MP_Send_object_was_deleted
- );
-
_Semaphore_Free( the_semaphore );
if ( _Attributes_Is_global( the_semaphore->attribute_set ) ) {
@@ -281,13 +333,14 @@ rtems_status_code rtems_semaphore_delete(
*/
rtems_status_code rtems_semaphore_obtain(
- Objects_Id id,
- unsigned32 option_set,
- rtems_interval timeout
+ Objects_Id id,
+ unsigned32 option_set,
+ rtems_interval timeout
)
{
register Semaphore_Control *the_semaphore;
Objects_Locations location;
+ boolean wait;
the_semaphore = _Semaphore_Get( id, &location );
switch ( location ) {
@@ -301,17 +354,32 @@ rtems_status_code rtems_semaphore_obtain(
timeout
);
case OBJECTS_LOCAL:
- if ( !_Semaphore_Seize( the_semaphore, option_set ) ) {
- if ( _Attributes_Is_inherit_priority( the_semaphore->attribute_set ) &&
- the_semaphore->holder->current_priority >
- _Thread_Executing->current_priority ) {
- _Thread_Change_priority(
- the_semaphore->holder, _Thread_Executing->current_priority );
- }
- _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
+ if ( _Options_Is_no_wait( option_set ) )
+ wait = FALSE;
+ else
+ wait = TRUE;
+
+ if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set ) ) {
+ _CORE_mutex_Seize(
+ &the_semaphore->Core_control.mutex,
+ id,
+ wait,
+ timeout
+ );
+ _Thread_Enable_dispatch();
+ return( _Semaphore_Translate_core_mutex_return_code(
+ _Thread_Executing->Wait.return_code ) );
+ } else {
+ _CORE_semaphore_Seize(
+ &the_semaphore->Core_control.semaphore,
+ id,
+ wait,
+ timeout
+ );
+ _Thread_Enable_dispatch();
+ return( _Semaphore_Translate_core_semaphore_return_code(
+ _Thread_Executing->Wait.return_code ) );
}
- _Thread_Enable_dispatch();
- return( _Thread_Executing->Wait.return_code );
}
return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
@@ -337,7 +405,8 @@ rtems_status_code rtems_semaphore_release(
{
register Semaphore_Control *the_semaphore;
Objects_Locations location;
- Thread_Control *the_thread;
+ CORE_mutex_Status mutex_status;
+ CORE_semaphore_Status semaphore_status;
the_semaphore = _Semaphore_Get( id, &location );
switch ( location ) {
@@ -353,143 +422,153 @@ rtems_status_code rtems_semaphore_release(
)
);
case OBJECTS_LOCAL:
- if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set)) {
-
- if ( !_Objects_Are_ids_equal(
- _Thread_Executing->Object.id, the_semaphore->holder_id ) ) {
- _Thread_Enable_dispatch();
- return( RTEMS_NOT_OWNER_OF_RESOURCE );
- }
-
- the_semaphore->nest_count--;
-
- if ( the_semaphore->nest_count != 0 ) {
- _Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
- }
-
- _Thread_Executing->resource_count--;
- the_semaphore->holder = NULL;
- the_semaphore->holder_id = 0;
-
- /*
- * Whether or not someone is waiting for the semaphore, an
- * inherited priority must be lowered if this is the last
- * semaphore (i.e. resource) this task has.
- */
-
- if ( _Attributes_Is_inherit_priority(the_semaphore->attribute_set) &&
- _Thread_Executing->resource_count == 0 &&
- _Thread_Executing->real_priority !=
- _Thread_Executing->current_priority ) {
- _Thread_Change_priority(
- _Thread_Executing, _Thread_Executing->real_priority );
- }
-
+ if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set ) ) {
+ mutex_status = _CORE_mutex_Surrender(
+ &the_semaphore->Core_control.mutex,
+ id,
+ _Semaphore_Core_mutex_mp_support
+ );
+ _Thread_Enable_dispatch();
+ return( _Semaphore_Translate_core_mutex_return_code( mutex_status ) );
}
+ else
+ semaphore_status = _CORE_semaphore_Surrender(
+ &the_semaphore->Core_control.semaphore,
+ id,
+ _Semaphore_Core_semaphore_mp_support
+ );
+ _Thread_Enable_dispatch();
+ return(
+ _Semaphore_Translate_core_semaphore_return_code( semaphore_status ) );
+ }
- if ( (the_thread = _Thread_queue_Dequeue(&the_semaphore->Wait_queue)) ) {
-
- if ( !_Objects_Is_local_id( the_thread->Object.id ) ) {
- the_thread->receive_packet->return_code = RTEMS_SUCCESSFUL;
-
- if ( _Attributes_Is_binary_semaphore(the_semaphore->attribute_set) ) {
- the_semaphore->holder = NULL;
- the_semaphore->holder_id = the_thread->Object.id;
- the_semaphore->nest_count = 1;
- }
-
- _Semaphore_MP_Send_response_packet(
- SEMAPHORE_MP_OBTAIN_RESPONSE,
- id,
- the_thread
- );
- } else {
-
- if ( _Attributes_Is_binary_semaphore(the_semaphore->attribute_set) ) {
- the_semaphore->holder = the_thread;
- the_semaphore->holder_id = the_thread->Object.id;
- the_thread->resource_count++;
- the_semaphore->nest_count = 1;
- }
-
- /*
- * No special action for priority inheritance because the_thread
- * is guaranteed to be the highest priority thread waiting for
- * the semaphore.
- */
- }
- } else
- the_semaphore->count += 1;
+ return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+}
- _Thread_Enable_dispatch();
+/*PAGE
+ *
+ * _Semaphore_Translate_core_mutex_return_code
+ *
+ * Input parameters:
+ * the_mutex_status - mutex status code to translate
+ *
+ * Output parameters:
+ * rtems status code - translated RTEMS status code
+ *
+ */
+
+rtems_status_code _Semaphore_Translate_core_mutex_return_code (
+ unsigned32 the_mutex_status
+)
+{
+ switch ( the_mutex_status ) {
+ case CORE_MUTEX_STATUS_SUCCESSFUL:
return( RTEMS_SUCCESSFUL );
+ case CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT:
+ return( RTEMS_UNSATISFIED );
+ case CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED:
+ return( RTEMS_INTERNAL_ERROR );
+ case CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE:
+ return( RTEMS_NOT_OWNER_OF_RESOURCE );
+ case CORE_MUTEX_WAS_DELETED:
+ return( RTEMS_OBJECT_WAS_DELETED );
+ case CORE_MUTEX_TIMEOUT:
+ return( RTEMS_TIMEOUT );
+ case 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 */
}
/*PAGE
*
- * _Semaphore_Seize
- *
- * This routine attempts to allocate a semaphore to the calling thread.
+ * _Semaphore_Translate_core_semaphore_return_code
*
* Input parameters:
- * the_semaphore - pointer to semaphore control block
- * option_set - acquire semaphore options
+ * the_semaphore_status - semaphore status code to translate
*
* Output parameters:
- * TRUE - if semaphore allocated
- * FALSE - if semaphore NOT allocated
+ * rtems status code - translated RTEMS status code
*
- * INTERRUPT LATENCY:
- * available
- * wait
*/
-
-boolean _Semaphore_Seize(
- Semaphore_Control *the_semaphore,
- rtems_option option_set
+
+rtems_status_code _Semaphore_Translate_core_semaphore_return_code (
+ unsigned32 the_semaphore_status
)
{
- Thread_Control *executing;
- ISR_Level level;
-
- executing = _Thread_Executing;
- executing->Wait.return_code = RTEMS_SUCCESSFUL;
- _ISR_Disable( level );
- if ( the_semaphore->count != 0 ) {
- the_semaphore->count -= 1;
- if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set ) ) {
- the_semaphore->holder = executing;
- the_semaphore->holder_id = executing->Object.id;
- the_semaphore->nest_count = 1;
- executing->resource_count++;
- }
- _ISR_Enable( level );
- return( TRUE );
+ switch ( the_semaphore_status ) {
+ case CORE_SEMAPHORE_STATUS_SUCCESSFUL:
+ return( RTEMS_SUCCESSFUL );
+ case CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT:
+ return( RTEMS_UNSATISFIED );
+ case CORE_SEMAPHORE_WAS_DELETED:
+ return( RTEMS_OBJECT_WAS_DELETED );
+ case CORE_SEMAPHORE_TIMEOUT:
+ return( RTEMS_TIMEOUT );
+ case 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 */
+}
- if ( _Options_Is_no_wait( option_set ) ) {
- _ISR_Enable( level );
- executing->Wait.return_code = RTEMS_UNSATISFIED;
- return( TRUE );
- }
+/*PAGE
+ *
+ * _Semaphore_Core_mutex_mp_support
+ *
+ * Input parameters:
+ * the_thread - the remote thread the semaphore was surrendered to
+ * id - id of the surrendered semaphore
+ *
+ * Output parameters: NONE
+ */
+
+void _Semaphore_Core_mutex_mp_support (
+ Thread_Control *the_thread,
+ Objects_Id id
+)
+{
+ the_thread->receive_packet->return_code = RTEMS_SUCCESSFUL;
+
+ _Semaphore_MP_Send_response_packet(
+ SEMAPHORE_MP_OBTAIN_RESPONSE,
+ id,
+ the_thread
+ );
+}
- if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set ) ) {
- if ( _Objects_Are_ids_equal(
- _Thread_Executing->Object.id, the_semaphore->holder_id ) ) {
- the_semaphore->nest_count++;
- _ISR_Enable( level );
- return( TRUE );
- }
- }
- the_semaphore->Wait_queue.sync = TRUE;
- executing->Wait.queue = &the_semaphore->Wait_queue;
- executing->Wait.id = the_semaphore->Object.id;
- executing->Wait.option_set = option_set;
- _ISR_Enable( level );
- return( FALSE );
+/*PAGE
+ *
+ * _Semaphore_Core_semaphore_mp_support
+ *
+ * Input parameters:
+ * the_thread - the remote thread the semaphore was surrendered to
+ * id - id of the surrendered semaphore
+ *
+ * Output parameters: NONE
+ */
+
+void _Semaphore_Core_semaphore_mp_support (
+ Thread_Control *the_thread,
+ Objects_Id id
+)
+{
+ the_thread->receive_packet->return_code = RTEMS_SUCCESSFUL;
+
+ _Semaphore_MP_Send_response_packet(
+ SEMAPHORE_MP_OBTAIN_RESPONSE,
+ id,
+ the_thread
+ );
}
diff --git a/cpukit/rtems/src/semmp.c b/cpukit/rtems/src/semmp.c
index 03ca51a228..c0a43f3f53 100644
--- a/cpukit/rtems/src/semmp.c
+++ b/cpukit/rtems/src/semmp.c
@@ -14,13 +14,15 @@
*/
#include <rtems/system.h>
-#include <rtems/mpci.h>
-#include <rtems/mppkt.h>
-#include <rtems/object.h>
-#include <rtems/options.h>
-#include <rtems/sem.h>
-#include <rtems/thread.h>
-#include <rtems/watchdog.h>
+#include <rtems/rtems/status.h>
+#include <rtems/core/mpci.h>
+#include <rtems/core/mppkt.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/options.h>
+#include <rtems/rtems/sem.h>
+#include <rtems/core/thread.h>
+#include <rtems/core/watchdog.h>
+#include <rtems/rtems/support.h>
/*PAGE
*
@@ -45,7 +47,7 @@ void _Semaphore_MP_Send_process_packet (
case SEMAPHORE_MP_EXTRACT_PROXY:
the_packet = _Semaphore_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_SEMAPHORE;
+ the_packet->Prefix.the_class = MP_PACKET_SEMAPHORE;
the_packet->Prefix.length = sizeof ( Semaphore_MP_Packet );
the_packet->Prefix.to_convert = sizeof ( Semaphore_MP_Packet );
the_packet->operation = operation;
@@ -78,8 +80,8 @@ void _Semaphore_MP_Send_process_packet (
rtems_status_code _Semaphore_MP_Send_request_packet (
Semaphore_MP_Remote_operations operation,
Objects_Id semaphore_id,
- rtems_option option_set,
- rtems_interval timeout
+ rtems_option option_set,
+ rtems_interval timeout
)
{
Semaphore_MP_Packet *the_packet;
@@ -90,7 +92,7 @@ rtems_status_code _Semaphore_MP_Send_request_packet (
case SEMAPHORE_MP_RELEASE_REQUEST:
the_packet = _Semaphore_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_SEMAPHORE;
+ the_packet->Prefix.the_class = MP_PACKET_SEMAPHORE;
the_packet->Prefix.length = sizeof ( Semaphore_MP_Packet );
the_packet->Prefix.to_convert = sizeof ( Semaphore_MP_Packet );
if ( ! _Options_Is_no_wait(option_set))
@@ -222,7 +224,7 @@ void _Semaphore_MP_Process_packet (
the_packet->Prefix.timeout
);
- if ( ! _Status_Is_proxy_blocking( the_packet->Prefix.return_code ) )
+ if ( ! _Thread_Is_proxy_blocking( the_packet->Prefix.return_code ) )
_Semaphore_MP_Send_response_packet(
SEMAPHORE_MP_OBTAIN_RESPONSE,
the_packet->Prefix.id,
diff --git a/cpukit/rtems/src/signal.c b/cpukit/rtems/src/signal.c
index 8a300d2969..f43107fe12 100644
--- a/cpukit/rtems/src/signal.c
+++ b/cpukit/rtems/src/signal.c
@@ -14,14 +14,39 @@
*/
#include <rtems/system.h>
-#include <rtems/asr.h>
-#include <rtems/isr.h>
-#include <rtems/modes.h>
-#include <rtems/signal.h>
-#include <rtems/thread.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/asr.h>
+#include <rtems/core/isr.h>
+#include <rtems/rtems/modes.h>
+#include <rtems/rtems/signal.h>
+#include <rtems/core/thread.h>
+#include <rtems/rtems/tasks.h>
/*PAGE
*
+ * _Signal_Manager_initialization
+ *
+ * This routine initializes all signal manager related data structures.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ */
+
+void _Signal_Manager_initialization( void )
+{
+ /*
+ * Register the MP Process Packet routine.
+ */
+
+ _MPCI_Register_packet_processor(
+ MP_PACKET_SIGNAL,
+ _Signal_MP_Process_packet
+ );
+}
+
+/*PAGE
+ *
* rtems_signal_catch
*
* This directive allows a thread to specify what action to take when
@@ -41,21 +66,26 @@ rtems_status_code rtems_signal_catch(
rtems_mode mode_set
)
{
- Thread_Control *executing;
+ Thread_Control *executing;
+ RTEMS_API_Control *api;
+ ASR_Information *asr;
/* XXX normalize mode */
executing = _Thread_Executing;
+ api = executing->API_Extensions[ THREAD_API_RTEMS ];
+ asr = &api->Signal;
+
_Thread_Disable_dispatch(); /* cannot reschedule while */
/* the thread is inconsistent */
if ( !_ASR_Is_null_handler( asr_handler ) ) {
- executing->RTEMS_API->Signal.mode_set = mode_set;
- executing->RTEMS_API->Signal.handler = asr_handler;
+ asr->mode_set = mode_set;
+ asr->handler = asr_handler;
}
else
- _ASR_Initialize( &executing->RTEMS_API->Signal );
+ _ASR_Initialize( asr );
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -80,11 +110,13 @@ rtems_status_code rtems_signal_send(
{
register Thread_Control *the_thread;
Objects_Locations location;
+ RTEMS_API_Control *api;
+ ASR_Information *asr;
the_thread = _Thread_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
return _Signal_MP_Send_request_packet(
SIGNAL_MP_SEND_REQUEST,
@@ -92,22 +124,23 @@ rtems_status_code rtems_signal_send(
signal_set
);
case OBJECTS_LOCAL:
- if ( ! _ASR_Is_null_handler( the_thread->RTEMS_API->Signal.handler ) ) {
- if ( _Modes_Is_asr_disabled( the_thread->current_modes ) )
- _ASR_Post_signals(
- signal_set, &the_thread->RTEMS_API->Signal.signals_pending );
- else {
- _ASR_Post_signals(
- signal_set, &the_thread->RTEMS_API->Signal.signals_posted );
+ api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
+ asr = &api->Signal;
+
+ if ( ! _ASR_Is_null_handler( asr->handler ) ) {
+ if ( asr->is_enabled ) {
+ _ASR_Post_signals( signal_set, &asr->signals_posted );
if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
_ISR_Signals_to_thread_executing = TRUE;
+ } else {
+ _ASR_Post_signals( signal_set, &asr->signals_pending );
}
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
_Thread_Enable_dispatch();
- return( RTEMS_NOT_DEFINED );
+ return RTEMS_NOT_DEFINED;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
diff --git a/cpukit/rtems/src/signalmp.c b/cpukit/rtems/src/signalmp.c
index 4ac8123766..3a38818c25 100644
--- a/cpukit/rtems/src/signalmp.c
+++ b/cpukit/rtems/src/signalmp.c
@@ -14,14 +14,16 @@
*/
#include <rtems/system.h>
-#include <rtems/mpci.h>
-#include <rtems/mppkt.h>
-#include <rtems/object.h>
-#include <rtems/options.h>
-#include <rtems/signal.h>
-#include <rtems/states.h>
-#include <rtems/thread.h>
-#include <rtems/watchdog.h>
+#include <rtems/rtems/status.h>
+#include <rtems/core/mpci.h>
+#include <rtems/core/mppkt.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/options.h>
+#include <rtems/rtems/signal.h>
+#include <rtems/core/states.h>
+#include <rtems/core/thread.h>
+#include <rtems/core/watchdog.h>
+#include <rtems/rtems/support.h>
/*PAGE
*
@@ -51,7 +53,7 @@ rtems_status_code _Signal_MP_Send_request_packet (
case SIGNAL_MP_SEND_REQUEST:
the_packet = _Signal_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_SIGNAL;
+ the_packet->Prefix.the_class = MP_PACKET_SIGNAL;
the_packet->Prefix.length = sizeof ( Signal_MP_Packet );
the_packet->Prefix.to_convert = sizeof ( Signal_MP_Packet );
the_packet->operation = operation;
diff --git a/cpukit/rtems/src/taskmp.c b/cpukit/rtems/src/taskmp.c
index 2b7fb214c6..98b0e9d3e5 100644
--- a/cpukit/rtems/src/taskmp.c
+++ b/cpukit/rtems/src/taskmp.c
@@ -14,13 +14,15 @@
*/
#include <rtems/system.h>
-#include <rtems/mpci.h>
-#include <rtems/mppkt.h>
-#include <rtems/object.h>
-#include <rtems/options.h>
-#include <rtems/tasks.h>
-#include <rtems/thread.h>
-#include <rtems/watchdog.h>
+#include <rtems/rtems/status.h>
+#include <rtems/core/mpci.h>
+#include <rtems/core/mppkt.h>
+#include <rtems/core/object.h>
+#include <rtems/rtems/options.h>
+#include <rtems/rtems/tasks.h>
+#include <rtems/core/thread.h>
+#include <rtems/core/watchdog.h>
+#include <rtems/rtems/support.h>
/*PAGE
*
@@ -42,7 +44,7 @@ void _RTEMS_tasks_MP_Send_process_packet (
case RTEMS_TASKS_MP_ANNOUNCE_DELETE:
the_packet = _RTEMS_tasks_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_TASKS;
+ the_packet->Prefix.the_class = MP_PACKET_TASKS;
the_packet->Prefix.length = sizeof ( RTEMS_tasks_MP_Packet );
the_packet->Prefix.to_convert = sizeof ( RTEMS_tasks_MP_Packet );
the_packet->operation = operation;
@@ -91,7 +93,7 @@ rtems_status_code _RTEMS_tasks_MP_Send_request_packet (
case RTEMS_TASKS_MP_SET_NOTE_REQUEST:
the_packet = _RTEMS_tasks_MP_Get_packet();
- the_packet->Prefix.the_class = RTEMS_MP_PACKET_TASKS;
+ the_packet->Prefix.the_class = MP_PACKET_TASKS;
the_packet->Prefix.length = sizeof ( RTEMS_tasks_MP_Packet );
the_packet->Prefix.to_convert = sizeof ( RTEMS_tasks_MP_Packet );
the_packet->operation = operation;
@@ -332,7 +334,7 @@ void _RTEMS_tasks_MP_Process_packet (
RTEMS_tasks_MP_Packet *_RTEMS_tasks_MP_Get_packet ( void )
{
- return ( (RTEMS_tasks_MP_Packet *) _MPCI_Get_packet() );
+ return (RTEMS_tasks_MP_Packet *) _MPCI_Get_packet();
}
/* end of file */
diff --git a/cpukit/rtems/src/tasks.c b/cpukit/rtems/src/tasks.c
index 62bc8c1995..70ec7d6928 100644
--- a/cpukit/rtems/src/tasks.c
+++ b/cpukit/rtems/src/tasks.c
@@ -14,17 +14,148 @@
*/
#include <rtems/system.h>
-#include <rtems/support.h>
-#include <rtems/modes.h>
-#include <rtems/object.h>
-#include <rtems/stack.h>
-#include <rtems/states.h>
-#include <rtems/tasks.h>
-#include <rtems/thread.h>
-#include <rtems/threadq.h>
-#include <rtems/tod.h>
-#include <rtems/userext.h>
-#include <rtems/wkspace.h>
+#include <rtems/rtems/status.h>
+#include <rtems/rtems/support.h>
+#include <rtems/rtems/modes.h>
+#include <rtems/core/object.h>
+#include <rtems/core/stack.h>
+#include <rtems/core/states.h>
+#include <rtems/rtems/tasks.h>
+#include <rtems/core/thread.h>
+#include <rtems/core/threadq.h>
+#include <rtems/core/tod.h>
+#include <rtems/core/userext.h>
+#include <rtems/core/wkspace.h>
+#include <rtems/core/intthrd.h>
+#include <rtems/sysstate.h>
+
+/*PAGE
+ *
+ * _RTEMS_tasks_Create_extension
+ *
+ * XXX
+ */
+
+boolean _RTEMS_tasks_Create_extension(
+ Thread_Control *executing,
+ Thread_Control *created
+)
+{
+ RTEMS_API_Control *api;
+
+ api = _Workspace_Allocate( sizeof( RTEMS_API_Control ) );
+
+ if ( !api )
+ return FALSE;
+
+ created->API_Extensions[ THREAD_API_RTEMS ] = api;
+
+ api->pending_events = EVENT_SETS_NONE_PENDING;
+ _ASR_Initialize( &api->Signal );
+ return TRUE;
+}
+
+/*PAGE
+ *
+ * _RTEMS_tasks_Start_extension
+ *
+ * XXX
+ */
+
+User_extensions_routine _RTEMS_tasks_Start_extension(
+ Thread_Control *executing,
+ Thread_Control *started
+)
+{
+ RTEMS_API_Control *api;
+
+ api = started->API_Extensions[ THREAD_API_RTEMS ];
+
+ api->pending_events = EVENT_SETS_NONE_PENDING;
+
+ _ASR_Initialize( &api->Signal );
+}
+
+/*PAGE
+ *
+ * _RTEMS_tasks_Delete_extension
+ *
+ * XXX
+ */
+
+User_extensions_routine _RTEMS_tasks_Delete_extension(
+ Thread_Control *executing,
+ Thread_Control *deleted
+)
+{
+ (void) _Workspace_Free( deleted->API_Extensions[ THREAD_API_RTEMS ] );
+
+ deleted->API_Extensions[ THREAD_API_RTEMS ] = NULL;
+}
+
+/*PAGE
+ *
+ * _RTEMS_tasks_Switch_extension
+ *
+ * XXX
+ */
+
+User_extensions_routine _RTEMS_tasks_Switch_extension(
+ Thread_Control *executing
+)
+{
+ ISR_Level level;
+ RTEMS_API_Control *api;
+ ASR_Information *asr;
+ rtems_signal_set signal_set;
+ Modes_Control prev_mode;
+
+ api = executing->API_Extensions[ THREAD_API_RTEMS ];
+ 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; */
+ asr->signals_posted = 0;
+ _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 );
+ }
+ else
+ _ISR_Enable( level );
+
+}
+
+Internal_threads_Extensions_control _RTEMS_tasks_Internal_thread_extensions = {
+ { NULL, NULL },
+ NULL, /* predriver */
+ _RTEMS_tasks_Initialize_user_tasks /* postdriver */
+};
+
+User_extensions_Control _RTEMS_tasks_API_extensions = {
+ { NULL, NULL },
+ { _RTEMS_tasks_Create_extension, /* create */
+ _RTEMS_tasks_Start_extension, /* start */
+ _RTEMS_tasks_Start_extension, /* restart */
+ _RTEMS_tasks_Delete_extension, /* delete */
+ NULL, /* switch */
+ _RTEMS_tasks_Switch_extension, /* post switch */
+ NULL, /* begin */
+ NULL, /* exitted */
+ NULL /* fatal */
+ }
+};
/*PAGE
*
@@ -39,9 +170,18 @@
*/
void _RTEMS_tasks_Manager_initialization(
- unsigned32 maximum_tasks
+ unsigned32 maximum_tasks,
+ unsigned32 number_of_initialization_tasks,
+ rtems_initialization_tasks_table *user_tasks
)
{
+
+ _RTEMS_tasks_Number_of_initialization_tasks = number_of_initialization_tasks;
+ _RTEMS_tasks_User_initialization_tasks = user_tasks;
+
+ if ( user_tasks == NULL || number_of_initialization_tasks == 0 )
+ _Internal_error_Occurred( INTERNAL_ERROR_RTEMS_API, TRUE, RTEMS_TOO_MANY );
+
_Objects_Initialize_information(
&_RTEMS_tasks_Information,
OBJECTS_RTEMS_TASKS,
@@ -52,6 +192,24 @@ void _RTEMS_tasks_Manager_initialization(
RTEMS_MAXIMUM_NAME_LENGTH,
TRUE
);
+
+ /*
+ * Add all the extensions for this API
+ */
+
+ _User_extensions_Add_API_set( &_RTEMS_tasks_API_extensions );
+
+ _Internal_threads_Add_extension( &_RTEMS_tasks_Internal_thread_extensions );
+
+ /*
+ * Register the MP Process Packet routine.
+ */
+
+ _MPCI_Register_packet_processor(
+ MP_PACKET_TASKS,
+ _RTEMS_tasks_MP_Process_packet
+ );
+
}
/*PAGE
@@ -89,12 +247,15 @@ rtems_status_code rtems_task_create(
Objects_MP_Control *the_global_object = NULL;
boolean is_fp;
boolean is_global;
+ boolean status;
rtems_attribute the_attribute_set;
Priority_Control core_priority;
+ RTEMS_API_Control *api;
+ ASR_Information *asr;
if ( !rtems_is_name_valid( name ) )
- return ( RTEMS_INVALID_NAME );
+ return RTEMS_INVALID_NAME;
/*
* Core Thread Initialize insures we get the minimum amount of
@@ -103,17 +264,17 @@ rtems_status_code rtems_task_create(
#if 0
if ( !_Stack_Is_enough( stack_size ) )
- return( RTEMS_INVALID_SIZE );
+ return RTEMS_INVALID_SIZE;
#endif
/*
* Validate the RTEMS API priority and convert it to the core priority range.
*/
- if ( !_Priority_Is_valid( initial_priority ) )
- return( RTEMS_INVALID_PRIORITY );
+ if ( !_RTEMS_tasks_Priority_is_valid( initial_priority ) )
+ return RTEMS_INVALID_PRIORITY;
- core_priority = _RTEMS_Tasks_Priority_to_Core( initial_priority );
+ core_priority = _RTEMS_tasks_Priority_to_Core( initial_priority );
/*
* Fix the attribute set to match the attributes which
@@ -137,8 +298,8 @@ rtems_status_code rtems_task_create(
is_global = TRUE;
- if ( !_Configuration_Is_multiprocessing() )
- return( RTEMS_MP_NOT_CONFIGURED );
+ if ( !_System_state_Is_multiprocessing )
+ return RTEMS_MP_NOT_CONFIGURED;
} else
is_global = FALSE;
@@ -167,7 +328,7 @@ rtems_status_code rtems_task_create(
if ( !the_thread ) {
_Thread_Enable_dispatch();
- return( RTEMS_TOO_MANY );
+ return RTEMS_TOO_MANY;
}
if ( is_global ) {
@@ -176,49 +337,45 @@ rtems_status_code rtems_task_create(
if ( _Objects_MP_Is_null_global_object( the_global_object ) ) {
_RTEMS_tasks_Free( the_thread );
_Thread_Enable_dispatch();
- return( RTEMS_TOO_MANY );
+ return RTEMS_TOO_MANY;
}
}
-#if 0
- /*
- * Allocate and initialize the RTEMS API specific information
- */
-
- the_thread->RTEMS_API = _Workspace_Allocate( sizeof( RTEMS_API_Control ) );
-
- if ( !the_thread->RTEMS_API ) {
- _RTEMS_tasks_Free( the_thread );
- if ( is_global )
- _Objects_MP_Free_global_object( the_global_object );
- _Thread_Enable_dispatch();
- return( RTEMS_UNSATISFIED );
- }
-
- the_thread->RTEMS_API->pending_events = EVENT_SETS_NONE_PENDING;
- _ASR_Initialize( &the_thread->RTEMS_API->Signal );
-#endif
-
/*
* Initialize the core thread for this task.
*/
-/* XXX normalize mode */
+ status = _Thread_Initialize(
+ &_RTEMS_tasks_Information,
+ the_thread,
+ NULL,
+ stack_size,
+ is_fp,
+ core_priority,
+ _Modes_Is_preempt(initial_modes) ? TRUE : FALSE,
+ _Modes_Is_timeslice(initial_modes) ? TRUE : FALSE,
+ _Modes_Get_interrupt_level(initial_modes),
+ &name
+ );
- if ( !_Thread_Initialize( &_RTEMS_tasks_Information, the_thread,
- NULL, stack_size, is_fp, core_priority, initial_modes, &name ) ) {
+ if ( !status ) {
if ( is_global )
_Objects_MP_Free_global_object( the_global_object );
_RTEMS_tasks_Free( the_thread );
_Thread_Enable_dispatch();
- return( RTEMS_UNSATISFIED );
+ return RTEMS_UNSATISFIED;
}
+ api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
+ asr = &api->Signal;
+
+ asr->is_enabled = _Modes_Is_asr_disabled(initial_modes) ? FALSE : TRUE;
+
*id = the_thread->Object.id;
if ( is_global ) {
- the_thread->RTEMS_API->is_global = TRUE;
+ the_thread->is_global = TRUE;
_Objects_MP_Open(
&_RTEMS_tasks_Information,
@@ -236,7 +393,7 @@ rtems_status_code rtems_task_create(
}
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -263,11 +420,16 @@ rtems_status_code rtems_task_ident(
Objects_Id *id
)
{
- if ( name != OBJECTS_ID_OF_SELF )
- return( _Objects_Name_to_id( &_RTEMS_tasks_Information, &name, node, id ) );
+ Objects_Name_to_id_errors status;
+
+ if ( name == OBJECTS_ID_OF_SELF ) {
+ *id = _Thread_Executing->Object.id;
+ return RTEMS_SUCCESSFUL;
+ }
+
+ status = _Objects_Name_to_id( &_RTEMS_tasks_Information, &name, node, id );
- *id = _Thread_Executing->Object.id;
- return( RTEMS_SUCCESSFUL );
+ return _Status_Object_name_errors_to_status[ status ];
}
/*PAGE
@@ -298,26 +460,26 @@ rtems_status_code rtems_task_start(
Objects_Locations location;
if ( entry_point == NULL )
- return( RTEMS_INVALID_ADDRESS );
+ return RTEMS_INVALID_ADDRESS;
the_thread = _Thread_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 ( _Thread_Start(
the_thread, THREAD_START_NUMERIC, entry_point, NULL, argument ) ) {
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
_Thread_Enable_dispatch();
- return( RTEMS_INCORRECT_STATE );
+ return RTEMS_INCORRECT_STATE;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -349,25 +511,20 @@ rtems_status_code rtems_task_restart(
the_thread = _Thread_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 ( _Thread_Restart( the_thread, NULL, argument ) ) {
-
- /* XXX until these are in an API extension they are too late. */
- _ASR_Initialize( &the_thread->RTEMS_API->Signal );
- the_thread->RTEMS_API->pending_events = EVENT_SETS_NONE_PENDING;
-
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
_Thread_Enable_dispatch();
- return( RTEMS_INCORRECT_STATE );
+ return RTEMS_INCORRECT_STATE;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -398,19 +555,16 @@ rtems_status_code rtems_task_delete(
the_thread = _Thread_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:
_Thread_Close( &_RTEMS_tasks_Information, the_thread );
- /* XXX */
- (void) _Workspace_Free( the_thread->RTEMS_API );
-
_RTEMS_tasks_Free( the_thread );
- if ( _Attributes_Is_global( the_thread->RTEMS_API->is_global ) ) {
+ if ( the_thread->is_global ) {
_Objects_MP_Close( &_RTEMS_tasks_Information, the_thread->Object.id );
@@ -422,10 +576,10 @@ rtems_status_code rtems_task_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
@@ -454,28 +608,26 @@ rtems_status_code rtems_task_suspend(
the_thread = _Thread_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
- return(
- _RTEMS_tasks_MP_Send_request_packet(
- RTEMS_TASKS_MP_SUSPEND_REQUEST,
- id,
- 0, /* Not used */
- 0, /* Not used */
- 0 /* Not used */
- )
+ return _RTEMS_tasks_MP_Send_request_packet(
+ RTEMS_TASKS_MP_SUSPEND_REQUEST,
+ id,
+ 0, /* Not used */
+ 0, /* Not used */
+ 0 /* Not used */
);
case OBJECTS_LOCAL:
if ( !_States_Is_suspended( the_thread->current_state ) ) {
_Thread_Set_state( the_thread, STATES_SUSPENDED );
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
_Thread_Enable_dispatch();
- return( RTEMS_ALREADY_SUSPENDED );
+ return RTEMS_ALREADY_SUSPENDED;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -503,7 +655,7 @@ rtems_status_code rtems_task_resume(
the_thread = _Thread_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
return(
_RTEMS_tasks_MP_Send_request_packet(
@@ -518,13 +670,13 @@ rtems_status_code rtems_task_resume(
if ( _States_Is_suspended( the_thread->current_state ) ) {
_Thread_Resume( the_thread );
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
_Thread_Enable_dispatch();
- return( RTEMS_INCORRECT_STATE );
+ return RTEMS_INCORRECT_STATE;
}
- return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */
+ return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}
/*PAGE
@@ -556,13 +708,13 @@ rtems_status_code rtems_task_set_priority(
Objects_Locations location;
if ( new_priority != RTEMS_CURRENT_PRIORITY &&
- !_Priority_Is_valid( new_priority ) )
- return( RTEMS_INVALID_PRIORITY );
+ !_RTEMS_tasks_Priority_is_valid( new_priority ) )
+ return RTEMS_INVALID_PRIORITY;
the_thread = _Thread_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
_Thread_Executing->Wait.return_argument = old_priority;
return(
@@ -583,10 +735,10 @@ rtems_status_code rtems_task_set_priority(
_Thread_Change_priority( the_thread, new_priority );
}
_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
@@ -603,7 +755,7 @@ rtems_status_code rtems_task_set_priority(
*
* Output:
* *previous_mode_set - previous mode set
- * always returns RTEMS_SUCCESSFUL
+ * always return RTEMS_SUCCESSFUL;
*/
rtems_status_code rtems_task_mode(
@@ -612,9 +764,62 @@ rtems_status_code rtems_task_mode(
rtems_mode *previous_mode_set
)
{
- if ( _Thread_Change_mode( mode_set, mask, previous_mode_set ) )
+ Thread_Control *executing;
+ RTEMS_API_Control *api;
+ ASR_Information *asr;
+ boolean is_asr_enabled = FALSE;
+ boolean needs_asr_dispatching = FALSE;
+ rtems_mode old_mode;
+
+ executing = _Thread_Executing;
+ api = executing->API_Extensions[ THREAD_API_RTEMS ];
+ asr = &api->Signal;
+
+ old_mode = (executing->is_preemptible) ? RTEMS_PREEMPT : RTEMS_NO_PREEMPT;
+ old_mode |= (executing->is_timeslice) ? RTEMS_TIMESLICE : RTEMS_NO_TIMESLICE;
+ old_mode |= (asr->is_enabled) ? RTEMS_ASR : RTEMS_NO_ASR;
+ old_mode |= _ISR_Get_level();
+
+ *previous_mode_set = old_mode;
+
+ /*
+ * These are generic thread scheduling characteristics.
+ */
+
+ if ( mask & RTEMS_PREEMPT_MASK )
+ executing->is_preemptible = _Modes_Is_preempt(mode_set) ? TRUE : FALSE;
+
+ if ( mask & RTEMS_TIMESLICE_MASK )
+ executing->is_timeslice = _Modes_Is_timeslice(mode_set) ? TRUE : FALSE;
+
+ /*
+ * Set the new interrupt level
+ */
+
+ if ( mask & RTEMS_INTERRUPT_MASK )
+ _Modes_Set_interrupt_level( mode_set );
+
+ /*
+ * This is specific to the RTEMS API
+ */
+
+ is_asr_enabled = FALSE;
+ needs_asr_dispatching = FALSE;
+
+ if ( mask & RTEMS_ASR_MASK ) {
+ is_asr_enabled = _Modes_Is_asr_disabled( mode_set ) ? FALSE : TRUE;
+ if ( is_asr_enabled != asr->is_enabled ) {
+ asr->is_enabled = is_asr_enabled;
+ _ASR_Swap_signals( asr );
+ if ( _ASR_Are_signals_pending( asr ) )
+ needs_asr_dispatching = TRUE;
+ }
+ }
+
+ if ( _Thread_Evaluate_mode() || needs_asr_dispatching )
_Thread_Dispatch();
- return( RTEMS_SUCCESSFUL );
+
+ return RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -643,6 +848,7 @@ rtems_status_code rtems_task_get_note(
{
register Thread_Control *the_thread;
Objects_Locations location;
+ RTEMS_API_Control *api;
/*
* NOTE: There is no check for < RTEMS_NOTEPAD_FIRST because that would
@@ -650,7 +856,7 @@ rtems_status_code rtems_task_get_note(
*/
if ( notepad > RTEMS_NOTEPAD_LAST )
- return( RTEMS_INVALID_NUMBER );
+ return RTEMS_INVALID_NUMBER;
/*
* Optimize the most likely case to avoid the Thread_Dispatch.
@@ -658,14 +864,15 @@ rtems_status_code rtems_task_get_note(
if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ||
_Objects_Are_ids_equal( id, _Thread_Executing->Object.id ) ) {
- *note = _Thread_Executing->RTEMS_API->Notepads[ notepad ];
- return( RTEMS_SUCCESSFUL );
+ api = _Thread_Executing->API_Extensions[ THREAD_API_RTEMS ];
+ *note = api->Notepads[ notepad ];
+ return RTEMS_SUCCESSFUL;
}
the_thread = _Thread_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
_Thread_Executing->Wait.return_argument = note;
@@ -677,12 +884,13 @@ rtems_status_code rtems_task_get_note(
0 /* Not used */
);
case OBJECTS_LOCAL:
- *note= the_thread->RTEMS_API->Notepads[ notepad ];
+ api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
+ *note = api->Notepads[ notepad ];
_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
@@ -710,6 +918,7 @@ rtems_status_code rtems_task_set_note(
{
register Thread_Control *the_thread;
Objects_Locations location;
+ RTEMS_API_Control *api;
/*
* NOTE: There is no check for < RTEMS_NOTEPAD_FIRST because that would
@@ -717,7 +926,7 @@ rtems_status_code rtems_task_set_note(
*/
if ( notepad > RTEMS_NOTEPAD_LAST )
- return( RTEMS_INVALID_NUMBER );
+ return RTEMS_INVALID_NUMBER;
/*
* Optimize the most likely case to avoid the Thread_Dispatch.
@@ -725,14 +934,15 @@ rtems_status_code rtems_task_set_note(
if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ||
_Objects_Are_ids_equal( id, _Thread_Executing->Object.id ) ) {
- _Thread_Executing->RTEMS_API->Notepads[ notepad ] = note;
- return( RTEMS_SUCCESSFUL );
+ api = _Thread_Executing->API_Extensions[ THREAD_API_RTEMS ];
+ api->Notepads[ notepad ] = note;
+ return RTEMS_SUCCESSFUL;
}
the_thread = _Thread_Get( id, &location );
switch ( location ) {
case OBJECTS_ERROR:
- return( RTEMS_INVALID_ID );
+ return RTEMS_INVALID_ID;
case OBJECTS_REMOTE:
return _RTEMS_tasks_MP_Send_request_packet(
RTEMS_TASKS_MP_SET_NOTE_REQUEST,
@@ -743,12 +953,13 @@ rtems_status_code rtems_task_set_note(
);
case OBJECTS_LOCAL:
- the_thread->RTEMS_API->Notepads[ notepad ] = note;
+ api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
+ api->Notepads[ notepad ] = note;
_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
@@ -785,7 +996,7 @@ rtems_status_code rtems_task_wake_after(
ticks, WATCHDOG_ACTIVATE_NOW );
_Thread_Enable_dispatch();
}
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -807,23 +1018,20 @@ rtems_status_code rtems_task_wake_when(
rtems_time_of_day *time_buffer
)
{
- rtems_interval seconds;
- rtems_status_code local_result;
+ Watchdog_Interval seconds;
if ( !_TOD_Is_set() )
- return( RTEMS_NOT_DEFINED );
+ return RTEMS_NOT_DEFINED;
time_buffer->ticks = 0;
- local_result = _TOD_Validate( time_buffer );
-
- if ( !rtems_is_status_successful( local_result ) )
- return( local_result );
+ if ( !_TOD_Validate( time_buffer ) )
+ return RTEMS_INVALID_CLOCK;
seconds = _TOD_To_seconds( time_buffer );
if ( seconds <= _TOD_Seconds_since_epoch )
- return( RTEMS_INVALID_CLOCK );
+ return RTEMS_INVALID_CLOCK;
_Thread_Disable_dispatch();
_Thread_Set_state( _Thread_Executing, STATES_WAITING_FOR_TIME );
@@ -836,5 +1044,57 @@ rtems_time_of_day *time_buffer
_Watchdog_Insert_seconds( &_Thread_Executing->Timer,
seconds - _TOD_Seconds_since_epoch, WATCHDOG_ACTIVATE_NOW );
_Thread_Enable_dispatch();
- return( RTEMS_SUCCESSFUL );
+ return RTEMS_SUCCESSFUL;
}
+
+/*PAGE
+ *
+ * _RTEMS_tasks_Initialize_user_tasks
+ *
+ * This routine creates and starts all configured user
+ * initialzation threads.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ */
+
+void _RTEMS_tasks_Initialize_user_tasks( void )
+{
+ unsigned32 index;
+ unsigned32 maximum;
+ rtems_id id;
+ rtems_status_code return_value;
+ rtems_initialization_tasks_table *user_tasks;
+
+ /*
+ * NOTE: This is slightly different from the Ada implementation.
+ */
+
+ user_tasks = _RTEMS_tasks_User_initialization_tasks;
+ maximum = _RTEMS_tasks_Number_of_initialization_tasks;
+
+ for ( index=0 ; index < maximum ; index++ ) {
+ return_value = rtems_task_create(
+ user_tasks[ index ].name,
+ user_tasks[ index ].initial_priority,
+ user_tasks[ index ].stack_size,
+ user_tasks[ index ].mode_set,
+ user_tasks[ index ].attribute_set,
+ &id
+ );
+
+ if ( !rtems_is_status_successful( return_value ) )
+ _Internal_error_Occurred( INTERNAL_ERROR_RTEMS_API, TRUE, return_value );
+
+ return_value = rtems_task_start(
+ id,
+ user_tasks[ index ].entry_point,
+ user_tasks[ index ].argument
+ );
+
+ if ( !rtems_is_status_successful( return_value ) )
+ _Internal_error_Occurred( INTERNAL_ERROR_RTEMS_API, TRUE, return_value );
+ }
+}
+