Changeset 0a00b2b in rtems


Ignore:
Timestamp:
May 20, 2016, 11:24:11 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
641b44c
Parents:
516ee75
git-author:
Sebastian Huber <sebastian.huber@…> (05/20/16 11:24:11)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/20/16 14:16:59)
Message:

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.

Location:
cpukit/rtems
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/include/rtems/rtems/partimpl.h

    r516ee75 r0a00b2b  
    182182}
    183183
    184 RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get (
     184RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get(
    185185  Objects_Id         id,
    186   Objects_Locations *location,
    187186  ISR_lock_Context  *lock_context
    188187)
    189188{
    190   return (Partition_Control *) _Objects_Get_isr_disable(
    191     &_Partition_Information,
     189  return (Partition_Control *) _Objects_Get_local(
    192190    id,
    193     location,
    194     lock_context
     191    lock_context,
     192    &_Partition_Information
    195193  );
    196194}
  • cpukit/rtems/include/rtems/rtems/partmp.h

    r516ee75 r0a00b2b  
    6565}   Partition_MP_Packet;
    6666
     67RTEMS_INLINE_ROUTINE bool _Partition_MP_Is_remote( Objects_Id id )
     68{
     69  return _Objects_MP_Is_remote( id, &_Partition_Information );
     70}
     71
    6772/**
    6873 *  @brief Partition_MP_Send_process_packet
     
    8186
    8287/**
    83  *  @brief Partition_MP_Send_request_packet
    84  *
    85  *  This routine performs a remote procedure call so that a
    86  *  directive operation can be initiated on another node.
     88 * @brief Issues a remote rtems_partition_get_buffer() request.
    8789 */
    88 rtems_status_code _Partition_MP_Send_request_packet (
    89   Partition_MP_Remote_operations  operation,
    90   Objects_Id                      partition_id,
    91   void                           *buffer
     90rtems_status_code _Partition_MP_Get_buffer(
     91  rtems_id   id,
     92  void     **buffer
     93);
     94
     95/**
     96 * @brief Issues a remote rtems_partition_return_buffer() request.
     97 */
     98rtems_status_code _Partition_MP_Return_buffer(
     99  rtems_id  id,
     100  void     *buffer
    92101);
    93102
  • cpukit/rtems/src/partdelete.c

    r516ee75 r0a00b2b  
    2727{
    2828  Partition_Control *the_partition;
    29   Objects_Locations  location;
    3029  ISR_lock_Context   lock_context;
    3130
    3231  _Objects_Allocator_lock();
    33   the_partition = _Partition_Get( id, &location, &lock_context );
    34   switch ( location ) {
     32  the_partition = _Partition_Get( id, &lock_context );
    3533
    36     case OBJECTS_LOCAL:
    37       _Partition_Acquire_critical( the_partition, &lock_context );
     34  if ( the_partition == NULL ) {
     35    _Objects_Allocator_unlock();
    3836
    39       if ( the_partition->number_of_used_blocks == 0 ) {
    40         _Objects_Close( &_Partition_Information, &the_partition->Object );
    4137#if defined(RTEMS_MULTIPROCESSING)
    42         if ( _Attributes_Is_global( the_partition->attribute_set ) ) {
    43 
    44           _Objects_MP_Close(
    45             &_Partition_Information,
    46             the_partition->Object.id
    47           );
    48 
    49           _Partition_MP_Send_process_packet(
    50             PARTITION_MP_ANNOUNCE_DELETE,
    51             the_partition->Object.id,
    52             0,                         /* Not used */
    53             0                          /* Not used */
    54           );
    55         }
     38    if ( _Partition_MP_Is_remote( id ) ) {
     39      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
     40    }
    5641#endif
    5742
    58         _Partition_Release( the_partition, &lock_context );
    59         _Partition_Destroy( the_partition );
    60         _Partition_Free( the_partition );
    61         _Objects_Allocator_unlock();
    62         return RTEMS_SUCCESSFUL;
    63       }
     43    return RTEMS_INVALID_ID;
     44  }
    6445
    65       _Partition_Release( the_partition, &lock_context );
    66       _Objects_Allocator_unlock();
    67       return RTEMS_RESOURCE_IN_USE;
     46  _Partition_Acquire_critical( the_partition, &lock_context );
     47
     48  if ( the_partition->number_of_used_blocks != 0 ) {
     49    _Partition_Release( the_partition, &lock_context );
     50    _Objects_Allocator_unlock();
     51    return RTEMS_RESOURCE_IN_USE;
     52  }
     53
     54  _Objects_Close( &_Partition_Information, &the_partition->Object );
     55  _Partition_Release( the_partition, &lock_context );
    6856
    6957#if defined(RTEMS_MULTIPROCESSING)
    70     case OBJECTS_REMOTE:
    71       _Objects_Allocator_unlock();
    72       return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
     58  if ( _Attributes_Is_global( the_partition->attribute_set ) ) {
     59    _Objects_MP_Close(
     60      &_Partition_Information,
     61      the_partition->Object.id
     62    );
     63
     64    _Partition_MP_Send_process_packet(
     65      PARTITION_MP_ANNOUNCE_DELETE,
     66      the_partition->Object.id,
     67      0,                         /* Not used */
     68      0                          /* Not used */
     69    );
     70  }
    7371#endif
    7472
    75     case OBJECTS_ERROR:
    76       break;
    77   }
    78 
     73  _Partition_Destroy( the_partition );
     74  _Partition_Free( the_partition );
    7975  _Objects_Allocator_unlock();
    80 
    81   return RTEMS_INVALID_ID;
     76  return RTEMS_SUCCESSFUL;
    8277}
  • cpukit/rtems/src/partgetbuffer.c

    r516ee75 r0a00b2b  
    2727{
    2828  Partition_Control *the_partition;
    29   Objects_Locations  location;
    3029  ISR_lock_Context   lock_context;
    3130  void              *the_buffer;
    3231
    33   if ( !buffer )
     32  if ( buffer == NULL ) {
    3433    return RTEMS_INVALID_ADDRESS;
    35 
    36   the_partition = _Partition_Get( id, &location, &lock_context );
    37   switch ( location ) {
    38 
    39     case OBJECTS_LOCAL:
    40       _Partition_Acquire_critical( the_partition, &lock_context );
    41 
    42       the_buffer = _Partition_Allocate_buffer( the_partition );
    43       if ( the_buffer != NULL ) {
    44         the_partition->number_of_used_blocks += 1;
    45         _Partition_Release( the_partition, &lock_context );
    46         *buffer = the_buffer;
    47         return RTEMS_SUCCESSFUL;
    48       }
    49 
    50       _Partition_Release( the_partition, &lock_context );
    51       return RTEMS_UNSATISFIED;
    52 
    53 #if defined(RTEMS_MULTIPROCESSING)
    54     case OBJECTS_REMOTE:
    55       _Thread_Executing->Wait.return_argument = buffer;
    56       return(
    57         _Partition_MP_Send_request_packet(
    58           PARTITION_MP_GET_BUFFER_REQUEST,
    59           id,
    60           0           /* Not used */
    61         )
    62       );
    63 #endif
    64 
    65     case OBJECTS_ERROR:
    66       break;
    6734  }
    6835
    69   return RTEMS_INVALID_ID;
     36  the_partition = _Partition_Get( id, &lock_context );
     37
     38  if ( the_partition == NULL ) {
     39#if defined(RTEMS_MULTIPROCESSING)
     40    return _Partition_MP_Get_buffer( id, buffer );
     41#else
     42    return RTEMS_INVALID_ID;
     43#endif
     44  }
     45
     46  _Partition_Acquire_critical( the_partition, &lock_context );
     47  the_buffer = _Partition_Allocate_buffer( the_partition );
     48
     49  if ( the_buffer == NULL ) {
     50    _Partition_Release( the_partition, &lock_context );
     51    return RTEMS_UNSATISFIED;
     52  }
     53
     54  the_partition->number_of_used_blocks += 1;
     55  _Partition_Release( the_partition, &lock_context );
     56  *buffer = the_buffer;
     57  return RTEMS_SUCCESSFUL;
    7058}
  • cpukit/rtems/src/partmp.c

    r516ee75 r0a00b2b  
    3232{
    3333  return (Partition_MP_Packet *) _MPCI_Get_packet();
     34}
     35
     36static void _Partition_MP_Initialize_packet(
     37  Partition_MP_Packet            *the_packet,
     38  Objects_Id                      id,
     39  Partition_MP_Remote_operations  operation
     40)
     41{
     42  the_packet->Prefix.the_class  = MP_PACKET_PARTITION;
     43  the_packet->Prefix.length     = sizeof( *the_packet );
     44  the_packet->Prefix.to_convert = sizeof( *the_packet );
     45  the_packet->Prefix.id         = id;
     46  the_packet->operation         = operation;
    3447}
    3548
     
    5568    case PARTITION_MP_EXTRACT_PROXY:
    5669
    57       the_packet                    = _Partition_MP_Get_packet();
    58       the_packet->Prefix.the_class  = MP_PACKET_PARTITION;
    59       the_packet->Prefix.length     = sizeof ( Partition_MP_Packet );
    60       the_packet->Prefix.to_convert = sizeof ( Partition_MP_Packet );
    61       the_packet->operation         = operation;
    62       the_packet->Prefix.id         = partition_id;
    63       the_packet->name              = name;
    64       the_packet->proxy_id          = proxy_id;
     70      the_packet = _Partition_MP_Get_packet();
     71      _Partition_MP_Initialize_packet( the_packet, partition_id, operation );
     72      the_packet->name     = name;
     73      the_packet->proxy_id = proxy_id;
    6574
    6675      if ( operation == PARTITION_MP_EXTRACT_PROXY )
     
    8594 */
    8695
    87 rtems_status_code _Partition_MP_Send_request_packet (
    88   Partition_MP_Remote_operations  operation,
     96static rtems_status_code _Partition_MP_Send_request_packet (
    8997  Objects_Id                      partition_id,
    90   void                           *buffer
     98  void                           *buffer,
     99  Partition_MP_Remote_operations  operation
    91100)
    92101{
    93102  Partition_MP_Packet *the_packet;
     103
     104  if ( !_Partition_MP_Is_remote( partition_id ) ) {
     105    return RTEMS_INVALID_ID;
     106  }
    94107
    95108  switch ( operation ) {
     
    98111    case PARTITION_MP_RETURN_BUFFER_REQUEST:
    99112
    100       the_packet                    = _Partition_MP_Get_packet();
    101       the_packet->Prefix.the_class  = MP_PACKET_PARTITION;
    102       the_packet->Prefix.length     = sizeof ( Partition_MP_Packet );
    103       the_packet->Prefix.to_convert = sizeof ( Partition_MP_Packet );
    104       the_packet->operation         = operation;
    105       the_packet->Prefix.id         = partition_id;
    106       the_packet->buffer            = buffer;
     113      the_packet = _Partition_MP_Get_packet();
     114      _Partition_MP_Initialize_packet( the_packet, partition_id, operation );
     115      the_packet->buffer = buffer;
    107116
    108117      return
     
    131140}
    132141
     142rtems_status_code _Partition_MP_Get_buffer(
     143  rtems_id   id,
     144  void     **buffer
     145)
     146{
     147  _Thread_Get_executing()->Wait.return_argument = buffer;
     148  return _Partition_MP_Send_request_packet(
     149    id,
     150    buffer,
     151    PARTITION_MP_GET_BUFFER_REQUEST
     152  );
     153}
     154
     155rtems_status_code _Partition_MP_Return_buffer(
     156  rtems_id  id,
     157  void     *buffer
     158)
     159{
     160  return _Partition_MP_Send_request_packet(
     161    id,
     162    buffer,
     163    PARTITION_MP_RETURN_BUFFER_REQUEST
     164  );
     165}
     166
    133167/*
    134168 *  _Partition_MP_Send_response_packet
  • cpukit/rtems/src/partreturnbuffer.c

    r516ee75 r0a00b2b  
    2323{
    2424  Partition_Control *the_partition;
    25   Objects_Locations  location;
    2625  ISR_lock_Context   lock_context;
    2726
    28   the_partition = _Partition_Get( id, &location, &lock_context );
    29   switch ( location ) {
     27  the_partition = _Partition_Get( id, &lock_context );
    3028
    31     case OBJECTS_LOCAL:
    32       _Partition_Acquire_critical( the_partition, &lock_context );
    33 
    34       if ( _Partition_Is_buffer_valid( buffer, the_partition ) ) {
    35         _Partition_Free_buffer( the_partition, buffer );
    36         the_partition->number_of_used_blocks -= 1;
    37         _Partition_Release( the_partition, &lock_context );
    38         return RTEMS_SUCCESSFUL;
    39       }
    40 
    41       _Partition_Release( the_partition, &lock_context );
    42       return RTEMS_INVALID_ADDRESS;
    43 
     29  if ( the_partition == NULL ) {
    4430#if defined(RTEMS_MULTIPROCESSING)
    45     case OBJECTS_REMOTE:
    46       return _Partition_MP_Send_request_packet(
    47           PARTITION_MP_RETURN_BUFFER_REQUEST,
    48           id,
    49           buffer
    50         );
     31    return _Partition_MP_Return_buffer( id, buffer );
     32#else
     33    return RTEMS_INVALID_ID;
    5134#endif
    52 
    53     case OBJECTS_ERROR:
    54       break;
    5535  }
    5636
    57   return RTEMS_INVALID_ID;
     37  _Partition_Acquire_critical( the_partition, &lock_context );
     38
     39  if ( !_Partition_Is_buffer_valid( buffer, the_partition ) ) {
     40    _Partition_Release( the_partition, &lock_context );
     41    return RTEMS_INVALID_ADDRESS;
     42  }
     43
     44  _Partition_Free_buffer( the_partition, buffer );
     45  the_partition->number_of_used_blocks -= 1;
     46  _Partition_Release( the_partition, &lock_context );
     47  return RTEMS_SUCCESSFUL;
    5848}
Note: See TracChangeset for help on using the changeset viewer.