rtems: Remove location from _Partition_Get()

Use _Objects_Get_local() for _Partition_Get() to get rid of the location
parameter.  Move remote object handling to partition MPCI support.
This commit is contained in:
Sebastian Huber
2016-05-20 16:16:59 +02:00
parent 516ee758df
commit 0a00b2b5f6
6 changed files with 148 additions and 134 deletions
+4 -6
View File
@@ -181,17 +181,15 @@ RTEMS_INLINE_ROUTINE void _Partition_Free (
_Objects_Free( &_Partition_Information, &the_partition->Object );
}
RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get (
RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get(
Objects_Id id,
Objects_Locations *location,
ISR_lock_Context *lock_context
)
{
return (Partition_Control *) _Objects_Get_isr_disable(
&_Partition_Information,
return (Partition_Control *) _Objects_Get_local(
id,
location,
lock_context
lock_context,
&_Partition_Information
);
}
+17 -8
View File
@@ -64,6 +64,11 @@ typedef struct {
Objects_Id proxy_id;
} Partition_MP_Packet;
RTEMS_INLINE_ROUTINE bool _Partition_MP_Is_remote( Objects_Id id )
{
return _Objects_MP_Is_remote( id, &_Partition_Information );
}
/**
* @brief Partition_MP_Send_process_packet
*
@@ -80,15 +85,19 @@ void _Partition_MP_Send_process_packet (
);
/**
* @brief Partition_MP_Send_request_packet
*
* This routine performs a remote procedure call so that a
* directive operation can be initiated on another node.
* @brief Issues a remote rtems_partition_get_buffer() request.
*/
rtems_status_code _Partition_MP_Send_request_packet (
Partition_MP_Remote_operations operation,
Objects_Id partition_id,
void *buffer
rtems_status_code _Partition_MP_Get_buffer(
rtems_id id,
void **buffer
);
/**
* @brief Issues a remote rtems_partition_return_buffer() request.
*/
rtems_status_code _Partition_MP_Return_buffer(
rtems_id id,
void *buffer
);
/**
+36 -41
View File
@@ -26,57 +26,52 @@ rtems_status_code rtems_partition_delete(
)
{
Partition_Control *the_partition;
Objects_Locations location;
ISR_lock_Context lock_context;
_Objects_Allocator_lock();
the_partition = _Partition_Get( id, &location, &lock_context );
switch ( location ) {
the_partition = _Partition_Get( id, &lock_context );
case OBJECTS_LOCAL:
_Partition_Acquire_critical( the_partition, &lock_context );
if ( the_partition->number_of_used_blocks == 0 ) {
_Objects_Close( &_Partition_Information, &the_partition->Object );
#if defined(RTEMS_MULTIPROCESSING)
if ( _Attributes_Is_global( the_partition->attribute_set ) ) {
_Objects_MP_Close(
&_Partition_Information,
the_partition->Object.id
);
_Partition_MP_Send_process_packet(
PARTITION_MP_ANNOUNCE_DELETE,
the_partition->Object.id,
0, /* Not used */
0 /* Not used */
);
}
#endif
_Partition_Release( the_partition, &lock_context );
_Partition_Destroy( the_partition );
_Partition_Free( the_partition );
_Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
}
_Partition_Release( the_partition, &lock_context );
_Objects_Allocator_unlock();
return RTEMS_RESOURCE_IN_USE;
if ( the_partition == NULL ) {
_Objects_Allocator_unlock();
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
_Objects_Allocator_unlock();
if ( _Partition_MP_Is_remote( id ) ) {
return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
}
#endif
case OBJECTS_ERROR:
break;
return RTEMS_INVALID_ID;
}
_Objects_Allocator_unlock();
_Partition_Acquire_critical( the_partition, &lock_context );
return RTEMS_INVALID_ID;
if ( the_partition->number_of_used_blocks != 0 ) {
_Partition_Release( the_partition, &lock_context );
_Objects_Allocator_unlock();
return RTEMS_RESOURCE_IN_USE;
}
_Objects_Close( &_Partition_Information, &the_partition->Object );
_Partition_Release( the_partition, &lock_context );
#if defined(RTEMS_MULTIPROCESSING)
if ( _Attributes_Is_global( the_partition->attribute_set ) ) {
_Objects_MP_Close(
&_Partition_Information,
the_partition->Object.id
);
_Partition_MP_Send_process_packet(
PARTITION_MP_ANNOUNCE_DELETE,
the_partition->Object.id,
0, /* Not used */
0 /* Not used */
);
}
#endif
_Partition_Destroy( the_partition );
_Partition_Free( the_partition );
_Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
}
+23 -35
View File
@@ -26,45 +26,33 @@ rtems_status_code rtems_partition_get_buffer(
)
{
Partition_Control *the_partition;
Objects_Locations location;
ISR_lock_Context lock_context;
void *the_buffer;
if ( !buffer )
if ( buffer == NULL ) {
return RTEMS_INVALID_ADDRESS;
the_partition = _Partition_Get( id, &location, &lock_context );
switch ( location ) {
case OBJECTS_LOCAL:
_Partition_Acquire_critical( the_partition, &lock_context );
the_buffer = _Partition_Allocate_buffer( the_partition );
if ( the_buffer != NULL ) {
the_partition->number_of_used_blocks += 1;
_Partition_Release( the_partition, &lock_context );
*buffer = the_buffer;
return RTEMS_SUCCESSFUL;
}
_Partition_Release( the_partition, &lock_context );
return RTEMS_UNSATISFIED;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
_Thread_Executing->Wait.return_argument = buffer;
return(
_Partition_MP_Send_request_packet(
PARTITION_MP_GET_BUFFER_REQUEST,
id,
0 /* Not used */
)
);
#endif
case OBJECTS_ERROR:
break;
}
return RTEMS_INVALID_ID;
the_partition = _Partition_Get( id, &lock_context );
if ( the_partition == NULL ) {
#if defined(RTEMS_MULTIPROCESSING)
return _Partition_MP_Get_buffer( id, buffer );
#else
return RTEMS_INVALID_ID;
#endif
}
_Partition_Acquire_critical( the_partition, &lock_context );
the_buffer = _Partition_Allocate_buffer( the_partition );
if ( the_buffer == NULL ) {
_Partition_Release( the_partition, &lock_context );
return RTEMS_UNSATISFIED;
}
the_partition->number_of_used_blocks += 1;
_Partition_Release( the_partition, &lock_context );
*buffer = the_buffer;
return RTEMS_SUCCESSFUL;
}
+52 -18
View File
@@ -33,6 +33,19 @@ static Partition_MP_Packet *_Partition_MP_Get_packet( void )
return (Partition_MP_Packet *) _MPCI_Get_packet();
}
static void _Partition_MP_Initialize_packet(
Partition_MP_Packet *the_packet,
Objects_Id id,
Partition_MP_Remote_operations operation
)
{
the_packet->Prefix.the_class = MP_PACKET_PARTITION;
the_packet->Prefix.length = sizeof( *the_packet );
the_packet->Prefix.to_convert = sizeof( *the_packet );
the_packet->Prefix.id = id;
the_packet->operation = operation;
}
/*
* _Partition_MP_Send_process_packet
*
@@ -54,14 +67,10 @@ void _Partition_MP_Send_process_packet (
case PARTITION_MP_ANNOUNCE_DELETE:
case PARTITION_MP_EXTRACT_PROXY:
the_packet = _Partition_MP_Get_packet();
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;
the_packet->Prefix.id = partition_id;
the_packet->name = name;
the_packet->proxy_id = proxy_id;
the_packet = _Partition_MP_Get_packet();
_Partition_MP_Initialize_packet( the_packet, partition_id, operation );
the_packet->name = name;
the_packet->proxy_id = proxy_id;
if ( operation == PARTITION_MP_EXTRACT_PROXY )
node = _Objects_Get_node( partition_id );
@@ -84,26 +93,26 @@ void _Partition_MP_Send_process_packet (
*
*/
rtems_status_code _Partition_MP_Send_request_packet (
Partition_MP_Remote_operations operation,
static rtems_status_code _Partition_MP_Send_request_packet (
Objects_Id partition_id,
void *buffer
void *buffer,
Partition_MP_Remote_operations operation
)
{
Partition_MP_Packet *the_packet;
if ( !_Partition_MP_Is_remote( partition_id ) ) {
return RTEMS_INVALID_ID;
}
switch ( operation ) {
case PARTITION_MP_GET_BUFFER_REQUEST:
case PARTITION_MP_RETURN_BUFFER_REQUEST:
the_packet = _Partition_MP_Get_packet();
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;
the_packet->Prefix.id = partition_id;
the_packet->buffer = buffer;
the_packet = _Partition_MP_Get_packet();
_Partition_MP_Initialize_packet( the_packet, partition_id, operation );
the_packet->buffer = buffer;
return
_MPCI_Send_request_packet(
@@ -130,6 +139,31 @@ rtems_status_code _Partition_MP_Send_request_packet (
return RTEMS_SUCCESSFUL;
}
rtems_status_code _Partition_MP_Get_buffer(
rtems_id id,
void **buffer
)
{
_Thread_Get_executing()->Wait.return_argument = buffer;
return _Partition_MP_Send_request_packet(
id,
buffer,
PARTITION_MP_GET_BUFFER_REQUEST
);
}
rtems_status_code _Partition_MP_Return_buffer(
rtems_id id,
void *buffer
)
{
return _Partition_MP_Send_request_packet(
id,
buffer,
PARTITION_MP_RETURN_BUFFER_REQUEST
);
}
/*
* _Partition_MP_Send_response_packet
*
+16 -26
View File
@@ -22,37 +22,27 @@ rtems_status_code rtems_partition_return_buffer(
)
{
Partition_Control *the_partition;
Objects_Locations location;
ISR_lock_Context lock_context;
the_partition = _Partition_Get( id, &location, &lock_context );
switch ( location ) {
case OBJECTS_LOCAL:
_Partition_Acquire_critical( the_partition, &lock_context );
if ( _Partition_Is_buffer_valid( buffer, the_partition ) ) {
_Partition_Free_buffer( the_partition, buffer );
the_partition->number_of_used_blocks -= 1;
_Partition_Release( the_partition, &lock_context );
return RTEMS_SUCCESSFUL;
}
_Partition_Release( the_partition, &lock_context );
return RTEMS_INVALID_ADDRESS;
the_partition = _Partition_Get( id, &lock_context );
if ( the_partition == NULL ) {
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
return _Partition_MP_Send_request_packet(
PARTITION_MP_RETURN_BUFFER_REQUEST,
id,
buffer
);
return _Partition_MP_Return_buffer( id, buffer );
#else
return RTEMS_INVALID_ID;
#endif
case OBJECTS_ERROR:
break;
}
return RTEMS_INVALID_ID;
_Partition_Acquire_critical( the_partition, &lock_context );
if ( !_Partition_Is_buffer_valid( buffer, the_partition ) ) {
_Partition_Release( the_partition, &lock_context );
return RTEMS_INVALID_ADDRESS;
}
_Partition_Free_buffer( the_partition, buffer );
the_partition->number_of_used_blocks -= 1;
_Partition_Release( the_partition, &lock_context );
return RTEMS_SUCCESSFUL;
}