score: Simplify _Thread_Get_interrupt_disable()

Remove the object location parameter.
This commit is contained in:
Sebastian Huber
2016-05-04 07:24:31 +02:00
parent 49a134dd87
commit a0dee7c7bf
6 changed files with 87 additions and 130 deletions
+4 -27
View File
@@ -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
);
/**
+45 -44
View File
@@ -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 (
+16 -27
View File
@@ -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
);
}
+20 -26
View File
@@ -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@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
);
}
@@ -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
);
+1 -4
View File
@@ -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 );
}