[PATCH 11/11] score: Simplify _Thread_Get_interrupt_disable()
Sebastian Huber
sebastian.huber at embedded-brains.de
Tue May 3 12:49:47 UTC 2016
Remove the object location parameter.
---
cpukit/rtems/include/rtems/rtems/eventmp.h | 31 ++--------
cpukit/rtems/src/eventmp.c | 89 ++++++++++++++-------------
cpukit/rtems/src/eventsend.c | 43 +++++--------
cpukit/rtems/src/systemeventsend.c | 46 ++++++--------
cpukit/score/include/rtems/score/threadimpl.h | 3 +-
cpukit/score/src/threadget.c | 5 +-
6 files changed, 87 insertions(+), 130 deletions(-)
diff --git a/cpukit/rtems/include/rtems/rtems/eventmp.h b/cpukit/rtems/include/rtems/rtems/eventmp.h
index fdcdf4d..a80e60c 100644
--- a/cpukit/rtems/include/rtems/rtems/eventmp.h
+++ b/cpukit/rtems/include/rtems/rtems/eventmp.h
@@ -41,25 +41,6 @@ extern "C" {
*/
/**@{*/
-/**
- * The following enumerated type defines the list of
- * remote event operations.
- */
-typedef enum {
- EVENT_MP_SEND_REQUEST = 0,
- EVENT_MP_SEND_RESPONSE = 1
-} Event_MP_Remote_operations;
-
-/**
- * The following data structure defines the packet used to perform
- * remote event operations.
- */
-typedef struct {
- rtems_packet_prefix Prefix;
- Event_MP_Remote_operations operation;
- rtems_event_set event_in;
-} Event_MP_Packet;
-
/*
* @brief Event_MP_Send_process_packet
*
@@ -71,15 +52,11 @@ typedef struct {
*/
/**
- * @brief Event MP Send Packet Request
- *
- * This routine performs a remote procedure call so that a
- * directive operation can be initiated on another node.
+ * @brief Issues a remote rtems_event_send() request.
*/
-rtems_status_code _Event_MP_Send_request_packet (
- Event_MP_Remote_operations operation,
- Objects_Id event_id,
- rtems_event_set event_in
+rtems_status_code _Event_MP_Send(
+ rtems_id id,
+ rtems_event_set event_in
);
/**
diff --git a/cpukit/rtems/src/eventmp.c b/cpukit/rtems/src/eventmp.c
index 74fe1ff..83e1384 100644
--- a/cpukit/rtems/src/eventmp.c
+++ b/cpukit/rtems/src/eventmp.c
@@ -19,66 +19,67 @@
#endif
#include <rtems/rtems/eventimpl.h>
-#include <rtems/score/objectimpl.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/statesimpl.h>
+/**
+ * The following enumerated type defines the list of
+ * remote event operations.
+ */
+typedef enum {
+ EVENT_MP_SEND_REQUEST = 0,
+ EVENT_MP_SEND_RESPONSE = 1
+} Event_MP_Remote_operations;
+
+/**
+ * The following data structure defines the packet used to perform
+ * remote event operations.
+ */
+typedef struct {
+ rtems_packet_prefix Prefix;
+ Event_MP_Remote_operations operation;
+ rtems_event_set event_in;
+} Event_MP_Packet;
+
RTEMS_STATIC_ASSERT(
sizeof(Event_MP_Packet) <= MP_PACKET_MINIMUM_PACKET_SIZE,
Event_MP_Packet
);
-static Event_MP_Packet *_Event_MP_Get_packet( void )
+static Event_MP_Packet *_Event_MP_Get_packet( Objects_Id id )
{
+ if ( !_Thread_MP_Is_remote( id ) ) {
+ return NULL;
+ }
+
return (Event_MP_Packet *) _MPCI_Get_packet();
}
-/*
- * _Event_MP_Send_process_packet
- *
- * This subprogram is not needed since there are no process
- * packets to be sent by this manager.
- *
- */
-
-rtems_status_code _Event_MP_Send_request_packet (
- Event_MP_Remote_operations operation,
- Objects_Id event_id,
- rtems_event_set event_in
+rtems_status_code _Event_MP_Send(
+ rtems_id id,
+ rtems_event_set event_in
)
{
Event_MP_Packet *the_packet;
- switch ( operation ) {
-
- case EVENT_MP_SEND_REQUEST:
-
- the_packet = _Event_MP_Get_packet();
- 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;
- the_packet->Prefix.id = event_id;
- the_packet->event_in = event_in;
-
- return (rtems_status_code)
- _MPCI_Send_request_packet(
- _Objects_Get_node( event_id ),
- &the_packet->Prefix,
- STATES_READY,
- RTEMS_TIMEOUT
- );
-
- break;
-
- case EVENT_MP_SEND_RESPONSE:
- break;
-
+ the_packet = _Event_MP_Get_packet( id );
+ if ( the_packet == NULL ) {
+ return RTEMS_INVALID_ID;
}
- /*
- * The following line is included to satisfy compilers which
- * produce warnings when a function does not end with a return.
- */
- return RTEMS_SUCCESSFUL;
+
+ the_packet->Prefix.the_class = MP_PACKET_EVENT;
+ the_packet->Prefix.length = sizeof ( *the_packet );
+ the_packet->Prefix.to_convert = sizeof ( *the_packet );
+ the_packet->operation = EVENT_MP_SEND_REQUEST;
+ the_packet->Prefix.id = id;
+ the_packet->event_in = event_in;
+
+ return (rtems_status_code) _MPCI_Send_request_packet(
+ _Objects_Get_node( id ),
+ &the_packet->Prefix,
+ STATES_READY,
+ RTEMS_TIMEOUT
+ );
}
static void _Event_MP_Send_response_packet (
diff --git a/cpukit/rtems/src/eventsend.c b/cpukit/rtems/src/eventsend.c
index a6476a2..087ebb8 100644
--- a/cpukit/rtems/src/eventsend.c
+++ b/cpukit/rtems/src/eventsend.c
@@ -27,37 +27,26 @@ rtems_status_code rtems_event_send(
rtems_event_set event_in
)
{
- rtems_status_code sc;
- Thread_Control *thread;
- Objects_Locations location;
+ Thread_Control *the_thread;
RTEMS_API_Control *api;
ISR_lock_Context lock_context;
- thread = _Thread_Get_interrupt_disable( id, &location, &lock_context );
- switch ( location ) {
- case OBJECTS_LOCAL:
- api = thread->API_Extensions[ THREAD_API_RTEMS ];
- sc = _Event_Surrender(
- thread,
- event_in,
- &api->Event,
- THREAD_WAIT_CLASS_EVENT,
- &lock_context
- );
- break;
-#ifdef RTEMS_MULTIPROCESSING
- case OBJECTS_REMOTE:
- sc = _Event_MP_Send_request_packet(
- EVENT_MP_SEND_REQUEST,
- id,
- event_in
- );
- break;
+ the_thread = _Thread_Get_interrupt_disable( id, &lock_context );
+
+ if ( the_thread == NULL ) {
+#if defined(RTEMS_MULTIPROCESSING)
+ return _Event_MP_Send( id, event_in );
+#else
+ return RTEMS_INVALID_ID;
#endif
- default:
- sc = RTEMS_INVALID_ID;
- break;
}
- return sc;
+ api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
+ return _Event_Surrender(
+ the_thread,
+ event_in,
+ &api->Event,
+ THREAD_WAIT_CLASS_EVENT,
+ &lock_context
+ );
}
diff --git a/cpukit/rtems/src/systemeventsend.c b/cpukit/rtems/src/systemeventsend.c
index 5b2116c..97bcabd 100644
--- a/cpukit/rtems/src/systemeventsend.c
+++ b/cpukit/rtems/src/systemeventsend.c
@@ -7,10 +7,10 @@
*/
/*
- * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2012, 2016 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
- * Obere Lagerstr. 30
+ * Dornierstr. 4
* 82178 Puchheim
* Germany
* <rtems at embedded-brains.de>
@@ -33,34 +33,28 @@ rtems_status_code rtems_event_system_send(
rtems_event_set event_in
)
{
- rtems_status_code sc;
- Thread_Control *thread;
- Objects_Locations location;
+ Thread_Control *the_thread;
RTEMS_API_Control *api;
ISR_lock_Context lock_context;
- thread = _Thread_Get_interrupt_disable( id, &location, &lock_context );
- switch ( location ) {
- case OBJECTS_LOCAL:
- api = thread->API_Extensions[ THREAD_API_RTEMS ];
- sc = _Event_Surrender(
- thread,
- event_in,
- &api->System_event,
- THREAD_WAIT_CLASS_SYSTEM_EVENT,
- &lock_context
- );
- break;
-#ifdef RTEMS_MULTIPROCESSING
- case OBJECTS_REMOTE:
- _Thread_Dispatch();
- sc = RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
- break;
+ the_thread = _Thread_Get_interrupt_disable( id, &lock_context );
+
+ if ( the_thread == NULL ) {
+#if defined(RTEMS_MULTIPROCESSING)
+ if ( _Thread_MP_Is_remote( id ) ) {
+ return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
+ }
#endif
- default:
- sc = RTEMS_INVALID_ID;
- break;
+
+ return RTEMS_INVALID_ID;
}
- return sc;
+ api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
+ return _Event_Surrender(
+ the_thread,
+ event_in,
+ &api->System_event,
+ THREAD_WAIT_CLASS_SYSTEM_EVENT,
+ &lock_context
+ );
}
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index 1fea4da6c..1d0421f 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -532,11 +532,10 @@ Thread_Control *_Thread_Get (
/**
* @brief Gets a thread by its identifier.
*
- * @see _Objects_Get_isr_disable().
+ * @see _Objects_Get_local().
*/
Thread_Control *_Thread_Get_interrupt_disable(
Objects_Id id,
- Objects_Locations *location,
ISR_lock_Context *lock_context
);
diff --git a/cpukit/score/src/threadget.c b/cpukit/score/src/threadget.c
index 7e3963d..c650499 100644
--- a/cpukit/score/src/threadget.c
+++ b/cpukit/score/src/threadget.c
@@ -45,24 +45,21 @@ Thread_Control *_Thread_Get(
Thread_Control *_Thread_Get_interrupt_disable(
Objects_Id id,
- Objects_Locations *location,
ISR_lock_Context *lock_context
)
{
Objects_Information *information;
if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ) {
- *location = OBJECTS_LOCAL;
_ISR_lock_ISR_disable( lock_context );
return _Thread_Executing;
}
information = _Thread_Get_objects_information( id );
if ( information == NULL ) {
- *location = OBJECTS_ERROR;
return NULL;
}
return (Thread_Control *)
- _Objects_Get_isr_disable( information, id, location, lock_context );
+ _Objects_Get_local( id, lock_context, information );
}
--
1.8.4.5
More information about the devel
mailing list