Changeset 842db5f3 in rtems


Ignore:
Timestamp:
May 17, 1999, 11:15:20 PM (22 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
1dc030f
Parents:
be47df9
Message:

Split Partition Manager into one routine per file.

Files:
10 added
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/rtems/src/Makefile.in

    rbe47df9 r842db5f3  
    3232  timerfirewhere timerident timerreset
    3333
    34 REGION_PIECES=\
    35   region regioncreate regiondelete regionextend regiongetsegment \
    36   regiongetsegmentsize regionident regionreturnsegemnt regionreturnsegemnt
    37 
    3834MESSAGE_QUEUE_PIECES=\
    3935  msg msgqallocate msgqbroadcast msgqcreate msgqdelete \
     
    5248  ratemonident ratemonperiod ratemontimeout
    5349
    54 C_PIECES=attr $(CLOCK_PIECES) dpmem $(EVENT_PIECES) intr intrbody \
    55    $(MESSAGE_QUEUE_PIECES) \
    56    part $(RATEMON_PIECES)  $(REGION_PIECES) $(SEMAPHORE_PIECES) signal \
    57    $(TASK_PIECES) $(TIMER_PIECES) $(MP_PIECES)
     50REGION_PIECES=\
     51  region regioncreate regiondelete regionextend regiongetsegment \
     52  regiongetsegmentsize regionident regionreturnsegemnt regionreturnsegemnt
     53
     54PARTITION_PIECES=\
     55  part partcreate partdelete partgetbuffer partident partreturnbuffer
     56
     57C_PIECES=\
     58  attr $(TASK_PIECES) $(RATEMON_PIECES) \
     59  intr intrbody \
     60  $(CLOCK_PIECES) $(TIMER_PIECES) \
     61  $(SEMAPHORE_PIECES) $(MESSAGE_QUEUE_PIECES) \
     62  $(EVENT_PIECES) signal
     63  $(PARTITION_PIECES) $(REGION_PIECES) dpmem \
     64  $(MP_PIECES)
    5865C_FILES=$(C_PIECES:%=%.c)
    5966C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
  • c/src/exec/rtems/src/part.c

    rbe47df9 r842db5f3  
    6363
    6464}
    65 
    66 /*PAGE
    67  *
    68  *  rtems_partition_create
    69  *
    70  *  This directive creates a partiton of fixed sized buffers from the
    71  *  given contiguous memory area.
    72  *
    73  *  Input parameters:
    74  *    name             - user defined partition name
    75  *    starting_address - physical start address of partition
    76  *    length           - physical length in bytes
    77  *    buffer_size      - size of buffers in bytes
    78  *    attribute_set    - partition attributes
    79  *    id               - pointer to partition id
    80  *
    81  *  Output parameters:
    82  *    id                - partition id
    83  *    RTEMS_SUCCESSFUL - if successful
    84  *    error code        - if unsuccessful
    85  */
    86 
    87 rtems_status_code rtems_partition_create(
    88   rtems_name          name,
    89   void               *starting_address,
    90   unsigned32          length,
    91   unsigned32          buffer_size,
    92   rtems_attribute  attribute_set,
    93   Objects_Id         *id
    94 )
    95 {
    96   register Partition_Control *the_partition;
    97 
    98   if ( !rtems_is_name_valid( name ) )
    99     return RTEMS_INVALID_NAME;
    100 
    101   if ( length == 0 || buffer_size == 0 || length < buffer_size ||
    102          !_Partition_Is_buffer_size_aligned( buffer_size ) )
    103     return RTEMS_INVALID_SIZE;
    104 
    105   if ( !_Addresses_Is_aligned( starting_address ) )
    106      return RTEMS_INVALID_ADDRESS;
    107 
    108 #if defined(RTEMS_MULTIPROCESSING)
    109   if ( _Attributes_Is_global( attribute_set ) &&
    110        !_System_state_Is_multiprocessing )
    111     return RTEMS_MP_NOT_CONFIGURED;
    112 #endif
    113 
    114   _Thread_Disable_dispatch();               /* prevents deletion */
    115 
    116   the_partition = _Partition_Allocate();
    117 
    118   if ( !the_partition ) {
    119     _Thread_Enable_dispatch();
    120     return RTEMS_TOO_MANY;
    121   }
    122 
    123 #if defined(RTEMS_MULTIPROCESSING)
    124   if ( _Attributes_Is_global( attribute_set ) &&
    125        !( _Objects_MP_Allocate_and_open( &_Partition_Information, name,
    126                             the_partition->Object.id, FALSE ) ) ) {
    127     _Partition_Free( the_partition );
    128     _Thread_Enable_dispatch();
    129     return RTEMS_TOO_MANY;
    130   }
    131 #endif
    132 
    133   the_partition->starting_address      = starting_address;
    134   the_partition->length                = length;
    135   the_partition->buffer_size           = buffer_size;
    136   the_partition->attribute_set         = attribute_set;
    137   the_partition->number_of_used_blocks = 0;
    138 
    139   _Chain_Initialize( &the_partition->Memory, starting_address,
    140                         length / buffer_size, buffer_size );
    141 
    142   _Objects_Open( &_Partition_Information, &the_partition->Object, &name );
    143 
    144   *id = the_partition->Object.id;
    145 #if defined(RTEMS_MULTIPROCESSING)
    146   if ( _Attributes_Is_global( attribute_set ) )
    147     _Partition_MP_Send_process_packet(
    148       PARTITION_MP_ANNOUNCE_CREATE,
    149       the_partition->Object.id,
    150       name,
    151       0                  /* Not used */
    152     );
    153 #endif
    154 
    155   _Thread_Enable_dispatch();
    156   return RTEMS_SUCCESSFUL;
    157 }
    158 
    159 /*PAGE
    160  *
    161  *  rtems_partition_ident
    162  *
    163  *  This directive returns the system ID associated with
    164  *  the partition name.
    165  *
    166  *  Input parameters:
    167  *    name - user defined partition name
    168  *    node - node(s) to be searched
    169  *    id   - pointer to partition id
    170  *
    171  *  Output parameters:
    172  *    *id               - partition id
    173  *    RTEMS_SUCCESSFUL - if successful
    174  *    error code        - if unsuccessful
    175  */
    176 
    177 rtems_status_code rtems_partition_ident(
    178   rtems_name    name,
    179   unsigned32    node,
    180   Objects_Id   *id
    181 )
    182 {
    183   Objects_Name_to_id_errors  status;
    184 
    185   status = _Objects_Name_to_id( &_Partition_Information, &name, node, id );
    186 
    187   return _Status_Object_name_errors_to_status[ status ];
    188 }
    189 
    190 /*PAGE
    191  *
    192  *  rtems_partition_delete
    193  *
    194  *  This directive allows a thread to delete a partition specified by
    195  *  the partition identifier, provided that none of its buffers are
    196  *  still allocated.
    197  *
    198  *  Input parameters:
    199  *    id - partition id
    200  *
    201  *  Output parameters:
    202  *    RTEMS_SUCCESSFUL - if successful
    203  *    error code        - if unsuccessful
    204  */
    205 
    206 rtems_status_code rtems_partition_delete(
    207   Objects_Id id
    208 )
    209 {
    210   register Partition_Control *the_partition;
    211   Objects_Locations                  location;
    212 
    213   the_partition = _Partition_Get( id, &location );
    214   switch ( location ) {
    215     case OBJECTS_REMOTE:
    216 #if defined(RTEMS_MULTIPROCESSING)
    217       _Thread_Dispatch();
    218       return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
    219 #endif
    220 
    221     case OBJECTS_ERROR:
    222       return RTEMS_INVALID_ID;
    223 
    224     case OBJECTS_LOCAL:
    225       if ( the_partition->number_of_used_blocks == 0 ) {
    226         _Objects_Close( &_Partition_Information, &the_partition->Object );
    227         _Partition_Free( the_partition );
    228 #if defined(RTEMS_MULTIPROCESSING)
    229         if ( _Attributes_Is_global( the_partition->attribute_set ) ) {
    230 
    231           _Objects_MP_Close(
    232             &_Partition_Information,
    233             the_partition->Object.id
    234           );
    235 
    236           _Partition_MP_Send_process_packet(
    237             PARTITION_MP_ANNOUNCE_DELETE,
    238             the_partition->Object.id,
    239             0,                         /* Not used */
    240             0                          /* Not used */
    241           );
    242         }
    243 #endif
    244 
    245         _Thread_Enable_dispatch();
    246         return RTEMS_SUCCESSFUL;
    247       }
    248       _Thread_Enable_dispatch();
    249       return RTEMS_RESOURCE_IN_USE;
    250   }
    251 
    252   return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    253 }
    254 
    255 /*PAGE
    256  *
    257  *  rtems_partition_get_buffer
    258  *
    259  *  This directive will obtain a buffer from a buffer partition.
    260  *
    261  *  Input parameters:
    262  *    id     - partition id
    263  *    buffer - pointer to buffer address
    264  *
    265  *  Output parameters:
    266  *    buffer            - pointer to buffer address filled in
    267  *    RTEMS_SUCCESSFUL - if successful
    268  *    error code        - if unsuccessful
    269  */
    270 
    271 rtems_status_code rtems_partition_get_buffer(
    272   Objects_Id   id,
    273   void       **buffer
    274 )
    275 {
    276   register Partition_Control *the_partition;
    277   Objects_Locations           location;
    278   void                       *the_buffer;
    279 
    280   the_partition = _Partition_Get( id, &location );
    281   switch ( location ) {
    282     case OBJECTS_REMOTE:
    283 #if defined(RTEMS_MULTIPROCESSING)
    284       _Thread_Executing->Wait.return_argument = buffer;
    285       return(
    286         _Partition_MP_Send_request_packet(
    287           PARTITION_MP_GET_BUFFER_REQUEST,
    288           id,
    289           0           /* Not used */
    290         )
    291       );
    292 #endif
    293 
    294     case OBJECTS_ERROR:
    295       return RTEMS_INVALID_ID;
    296 
    297     case OBJECTS_LOCAL:
    298       the_buffer = _Partition_Allocate_buffer( the_partition );
    299       if ( the_buffer ) {
    300         the_partition->number_of_used_blocks += 1;
    301         _Thread_Enable_dispatch();
    302         *buffer = the_buffer;
    303         return RTEMS_SUCCESSFUL;
    304       }
    305       _Thread_Enable_dispatch();
    306       return RTEMS_UNSATISFIED;
    307   }
    308 
    309   return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    310 }
    311 
    312 /*PAGE
    313  *
    314  *  rtems_partition_return_buffer
    315  *
    316  *  This directive will return the given buffer to the specified
    317  *  buffer partition.
    318  *
    319  *  Input parameters:
    320  *    id     - partition id
    321  *    buffer - pointer to buffer address
    322  *
    323  *  Output parameters:
    324  *    RTEMS_SUCCESSFUL - if successful
    325  *    error code - if unsuccessful
    326  */
    327 
    328 rtems_status_code rtems_partition_return_buffer(
    329   Objects_Id  id,
    330   void       *buffer
    331 )
    332 {
    333   register Partition_Control *the_partition;
    334   Objects_Locations           location;
    335 
    336   the_partition = _Partition_Get( id, &location );
    337   switch ( location ) {
    338 
    339     case OBJECTS_REMOTE:
    340 #if defined(RTEMS_MULTIPROCESSING)
    341       return _Partition_MP_Send_request_packet(
    342           PARTITION_MP_RETURN_BUFFER_REQUEST,
    343           id,
    344           buffer
    345         );
    346 #endif
    347 
    348     case OBJECTS_ERROR:
    349       return RTEMS_INVALID_ID;
    350 
    351     case OBJECTS_LOCAL:
    352       if ( _Partition_Is_buffer_valid( buffer, the_partition ) ) {
    353         _Partition_Free_buffer( the_partition, buffer );
    354         the_partition->number_of_used_blocks -= 1;
    355         _Thread_Enable_dispatch();
    356         return RTEMS_SUCCESSFUL;
    357       }
    358       _Thread_Enable_dispatch();
    359       return RTEMS_INVALID_ADDRESS;
    360   }
    361 
    362   return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    363 }
  • cpukit/rtems/src/part.c

    rbe47df9 r842db5f3  
    6363
    6464}
    65 
    66 /*PAGE
    67  *
    68  *  rtems_partition_create
    69  *
    70  *  This directive creates a partiton of fixed sized buffers from the
    71  *  given contiguous memory area.
    72  *
    73  *  Input parameters:
    74  *    name             - user defined partition name
    75  *    starting_address - physical start address of partition
    76  *    length           - physical length in bytes
    77  *    buffer_size      - size of buffers in bytes
    78  *    attribute_set    - partition attributes
    79  *    id               - pointer to partition id
    80  *
    81  *  Output parameters:
    82  *    id                - partition id
    83  *    RTEMS_SUCCESSFUL - if successful
    84  *    error code        - if unsuccessful
    85  */
    86 
    87 rtems_status_code rtems_partition_create(
    88   rtems_name          name,
    89   void               *starting_address,
    90   unsigned32          length,
    91   unsigned32          buffer_size,
    92   rtems_attribute  attribute_set,
    93   Objects_Id         *id
    94 )
    95 {
    96   register Partition_Control *the_partition;
    97 
    98   if ( !rtems_is_name_valid( name ) )
    99     return RTEMS_INVALID_NAME;
    100 
    101   if ( length == 0 || buffer_size == 0 || length < buffer_size ||
    102          !_Partition_Is_buffer_size_aligned( buffer_size ) )
    103     return RTEMS_INVALID_SIZE;
    104 
    105   if ( !_Addresses_Is_aligned( starting_address ) )
    106      return RTEMS_INVALID_ADDRESS;
    107 
    108 #if defined(RTEMS_MULTIPROCESSING)
    109   if ( _Attributes_Is_global( attribute_set ) &&
    110        !_System_state_Is_multiprocessing )
    111     return RTEMS_MP_NOT_CONFIGURED;
    112 #endif
    113 
    114   _Thread_Disable_dispatch();               /* prevents deletion */
    115 
    116   the_partition = _Partition_Allocate();
    117 
    118   if ( !the_partition ) {
    119     _Thread_Enable_dispatch();
    120     return RTEMS_TOO_MANY;
    121   }
    122 
    123 #if defined(RTEMS_MULTIPROCESSING)
    124   if ( _Attributes_Is_global( attribute_set ) &&
    125        !( _Objects_MP_Allocate_and_open( &_Partition_Information, name,
    126                             the_partition->Object.id, FALSE ) ) ) {
    127     _Partition_Free( the_partition );
    128     _Thread_Enable_dispatch();
    129     return RTEMS_TOO_MANY;
    130   }
    131 #endif
    132 
    133   the_partition->starting_address      = starting_address;
    134   the_partition->length                = length;
    135   the_partition->buffer_size           = buffer_size;
    136   the_partition->attribute_set         = attribute_set;
    137   the_partition->number_of_used_blocks = 0;
    138 
    139   _Chain_Initialize( &the_partition->Memory, starting_address,
    140                         length / buffer_size, buffer_size );
    141 
    142   _Objects_Open( &_Partition_Information, &the_partition->Object, &name );
    143 
    144   *id = the_partition->Object.id;
    145 #if defined(RTEMS_MULTIPROCESSING)
    146   if ( _Attributes_Is_global( attribute_set ) )
    147     _Partition_MP_Send_process_packet(
    148       PARTITION_MP_ANNOUNCE_CREATE,
    149       the_partition->Object.id,
    150       name,
    151       0                  /* Not used */
    152     );
    153 #endif
    154 
    155   _Thread_Enable_dispatch();
    156   return RTEMS_SUCCESSFUL;
    157 }
    158 
    159 /*PAGE
    160  *
    161  *  rtems_partition_ident
    162  *
    163  *  This directive returns the system ID associated with
    164  *  the partition name.
    165  *
    166  *  Input parameters:
    167  *    name - user defined partition name
    168  *    node - node(s) to be searched
    169  *    id   - pointer to partition id
    170  *
    171  *  Output parameters:
    172  *    *id               - partition id
    173  *    RTEMS_SUCCESSFUL - if successful
    174  *    error code        - if unsuccessful
    175  */
    176 
    177 rtems_status_code rtems_partition_ident(
    178   rtems_name    name,
    179   unsigned32    node,
    180   Objects_Id   *id
    181 )
    182 {
    183   Objects_Name_to_id_errors  status;
    184 
    185   status = _Objects_Name_to_id( &_Partition_Information, &name, node, id );
    186 
    187   return _Status_Object_name_errors_to_status[ status ];
    188 }
    189 
    190 /*PAGE
    191  *
    192  *  rtems_partition_delete
    193  *
    194  *  This directive allows a thread to delete a partition specified by
    195  *  the partition identifier, provided that none of its buffers are
    196  *  still allocated.
    197  *
    198  *  Input parameters:
    199  *    id - partition id
    200  *
    201  *  Output parameters:
    202  *    RTEMS_SUCCESSFUL - if successful
    203  *    error code        - if unsuccessful
    204  */
    205 
    206 rtems_status_code rtems_partition_delete(
    207   Objects_Id id
    208 )
    209 {
    210   register Partition_Control *the_partition;
    211   Objects_Locations                  location;
    212 
    213   the_partition = _Partition_Get( id, &location );
    214   switch ( location ) {
    215     case OBJECTS_REMOTE:
    216 #if defined(RTEMS_MULTIPROCESSING)
    217       _Thread_Dispatch();
    218       return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
    219 #endif
    220 
    221     case OBJECTS_ERROR:
    222       return RTEMS_INVALID_ID;
    223 
    224     case OBJECTS_LOCAL:
    225       if ( the_partition->number_of_used_blocks == 0 ) {
    226         _Objects_Close( &_Partition_Information, &the_partition->Object );
    227         _Partition_Free( the_partition );
    228 #if defined(RTEMS_MULTIPROCESSING)
    229         if ( _Attributes_Is_global( the_partition->attribute_set ) ) {
    230 
    231           _Objects_MP_Close(
    232             &_Partition_Information,
    233             the_partition->Object.id
    234           );
    235 
    236           _Partition_MP_Send_process_packet(
    237             PARTITION_MP_ANNOUNCE_DELETE,
    238             the_partition->Object.id,
    239             0,                         /* Not used */
    240             0                          /* Not used */
    241           );
    242         }
    243 #endif
    244 
    245         _Thread_Enable_dispatch();
    246         return RTEMS_SUCCESSFUL;
    247       }
    248       _Thread_Enable_dispatch();
    249       return RTEMS_RESOURCE_IN_USE;
    250   }
    251 
    252   return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    253 }
    254 
    255 /*PAGE
    256  *
    257  *  rtems_partition_get_buffer
    258  *
    259  *  This directive will obtain a buffer from a buffer partition.
    260  *
    261  *  Input parameters:
    262  *    id     - partition id
    263  *    buffer - pointer to buffer address
    264  *
    265  *  Output parameters:
    266  *    buffer            - pointer to buffer address filled in
    267  *    RTEMS_SUCCESSFUL - if successful
    268  *    error code        - if unsuccessful
    269  */
    270 
    271 rtems_status_code rtems_partition_get_buffer(
    272   Objects_Id   id,
    273   void       **buffer
    274 )
    275 {
    276   register Partition_Control *the_partition;
    277   Objects_Locations           location;
    278   void                       *the_buffer;
    279 
    280   the_partition = _Partition_Get( id, &location );
    281   switch ( location ) {
    282     case OBJECTS_REMOTE:
    283 #if defined(RTEMS_MULTIPROCESSING)
    284       _Thread_Executing->Wait.return_argument = buffer;
    285       return(
    286         _Partition_MP_Send_request_packet(
    287           PARTITION_MP_GET_BUFFER_REQUEST,
    288           id,
    289           0           /* Not used */
    290         )
    291       );
    292 #endif
    293 
    294     case OBJECTS_ERROR:
    295       return RTEMS_INVALID_ID;
    296 
    297     case OBJECTS_LOCAL:
    298       the_buffer = _Partition_Allocate_buffer( the_partition );
    299       if ( the_buffer ) {
    300         the_partition->number_of_used_blocks += 1;
    301         _Thread_Enable_dispatch();
    302         *buffer = the_buffer;
    303         return RTEMS_SUCCESSFUL;
    304       }
    305       _Thread_Enable_dispatch();
    306       return RTEMS_UNSATISFIED;
    307   }
    308 
    309   return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    310 }
    311 
    312 /*PAGE
    313  *
    314  *  rtems_partition_return_buffer
    315  *
    316  *  This directive will return the given buffer to the specified
    317  *  buffer partition.
    318  *
    319  *  Input parameters:
    320  *    id     - partition id
    321  *    buffer - pointer to buffer address
    322  *
    323  *  Output parameters:
    324  *    RTEMS_SUCCESSFUL - if successful
    325  *    error code - if unsuccessful
    326  */
    327 
    328 rtems_status_code rtems_partition_return_buffer(
    329   Objects_Id  id,
    330   void       *buffer
    331 )
    332 {
    333   register Partition_Control *the_partition;
    334   Objects_Locations           location;
    335 
    336   the_partition = _Partition_Get( id, &location );
    337   switch ( location ) {
    338 
    339     case OBJECTS_REMOTE:
    340 #if defined(RTEMS_MULTIPROCESSING)
    341       return _Partition_MP_Send_request_packet(
    342           PARTITION_MP_RETURN_BUFFER_REQUEST,
    343           id,
    344           buffer
    345         );
    346 #endif
    347 
    348     case OBJECTS_ERROR:
    349       return RTEMS_INVALID_ID;
    350 
    351     case OBJECTS_LOCAL:
    352       if ( _Partition_Is_buffer_valid( buffer, the_partition ) ) {
    353         _Partition_Free_buffer( the_partition, buffer );
    354         the_partition->number_of_used_blocks -= 1;
    355         _Thread_Enable_dispatch();
    356         return RTEMS_SUCCESSFUL;
    357       }
    358       _Thread_Enable_dispatch();
    359       return RTEMS_INVALID_ADDRESS;
    360   }
    361 
    362   return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    363 }
Note: See TracChangeset for help on using the changeset viewer.