Changeset 842db5f3 in rtems
- Timestamp:
- May 17, 1999, 11:15:20 PM (22 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 1dc030f
- Parents:
- be47df9
- Files:
-
- 10 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/rtems/src/Makefile.in
rbe47df9 r842db5f3 32 32 timerfirewhere timerident timerreset 33 33 34 REGION_PIECES=\35 region regioncreate regiondelete regionextend regiongetsegment \36 regiongetsegmentsize regionident regionreturnsegemnt regionreturnsegemnt37 38 34 MESSAGE_QUEUE_PIECES=\ 39 35 msg msgqallocate msgqbroadcast msgqcreate msgqdelete \ … … 52 48 ratemonident ratemonperiod ratemontimeout 53 49 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) 50 REGION_PIECES=\ 51 region regioncreate regiondelete regionextend regiongetsegment \ 52 regiongetsegmentsize regionident regionreturnsegemnt regionreturnsegemnt 53 54 PARTITION_PIECES=\ 55 part partcreate partdelete partgetbuffer partident partreturnbuffer 56 57 C_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) 58 65 C_FILES=$(C_PIECES:%=%.c) 59 66 C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) -
c/src/exec/rtems/src/part.c
rbe47df9 r842db5f3 63 63 64 64 } 65 66 /*PAGE67 *68 * rtems_partition_create69 *70 * This directive creates a partiton of fixed sized buffers from the71 * given contiguous memory area.72 *73 * Input parameters:74 * name - user defined partition name75 * starting_address - physical start address of partition76 * length - physical length in bytes77 * buffer_size - size of buffers in bytes78 * attribute_set - partition attributes79 * id - pointer to partition id80 *81 * Output parameters:82 * id - partition id83 * RTEMS_SUCCESSFUL - if successful84 * error code - if unsuccessful85 */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 *id94 )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 #endif113 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 #endif132 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 #endif154 155 _Thread_Enable_dispatch();156 return RTEMS_SUCCESSFUL;157 }158 159 /*PAGE160 *161 * rtems_partition_ident162 *163 * This directive returns the system ID associated with164 * the partition name.165 *166 * Input parameters:167 * name - user defined partition name168 * node - node(s) to be searched169 * id - pointer to partition id170 *171 * Output parameters:172 * *id - partition id173 * RTEMS_SUCCESSFUL - if successful174 * error code - if unsuccessful175 */176 177 rtems_status_code rtems_partition_ident(178 rtems_name name,179 unsigned32 node,180 Objects_Id *id181 )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 /*PAGE191 *192 * rtems_partition_delete193 *194 * This directive allows a thread to delete a partition specified by195 * the partition identifier, provided that none of its buffers are196 * still allocated.197 *198 * Input parameters:199 * id - partition id200 *201 * Output parameters:202 * RTEMS_SUCCESSFUL - if successful203 * error code - if unsuccessful204 */205 206 rtems_status_code rtems_partition_delete(207 Objects_Id id208 )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 #endif220 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.id234 );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 #endif244 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 /*PAGE256 *257 * rtems_partition_get_buffer258 *259 * This directive will obtain a buffer from a buffer partition.260 *261 * Input parameters:262 * id - partition id263 * buffer - pointer to buffer address264 *265 * Output parameters:266 * buffer - pointer to buffer address filled in267 * RTEMS_SUCCESSFUL - if successful268 * error code - if unsuccessful269 */270 271 rtems_status_code rtems_partition_get_buffer(272 Objects_Id id,273 void **buffer274 )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 #endif293 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 /*PAGE313 *314 * rtems_partition_return_buffer315 *316 * This directive will return the given buffer to the specified317 * buffer partition.318 *319 * Input parameters:320 * id - partition id321 * buffer - pointer to buffer address322 *323 * Output parameters:324 * RTEMS_SUCCESSFUL - if successful325 * error code - if unsuccessful326 */327 328 rtems_status_code rtems_partition_return_buffer(329 Objects_Id id,330 void *buffer331 )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 buffer345 );346 #endif347 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 63 63 64 64 } 65 66 /*PAGE67 *68 * rtems_partition_create69 *70 * This directive creates a partiton of fixed sized buffers from the71 * given contiguous memory area.72 *73 * Input parameters:74 * name - user defined partition name75 * starting_address - physical start address of partition76 * length - physical length in bytes77 * buffer_size - size of buffers in bytes78 * attribute_set - partition attributes79 * id - pointer to partition id80 *81 * Output parameters:82 * id - partition id83 * RTEMS_SUCCESSFUL - if successful84 * error code - if unsuccessful85 */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 *id94 )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 #endif113 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 #endif132 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 #endif154 155 _Thread_Enable_dispatch();156 return RTEMS_SUCCESSFUL;157 }158 159 /*PAGE160 *161 * rtems_partition_ident162 *163 * This directive returns the system ID associated with164 * the partition name.165 *166 * Input parameters:167 * name - user defined partition name168 * node - node(s) to be searched169 * id - pointer to partition id170 *171 * Output parameters:172 * *id - partition id173 * RTEMS_SUCCESSFUL - if successful174 * error code - if unsuccessful175 */176 177 rtems_status_code rtems_partition_ident(178 rtems_name name,179 unsigned32 node,180 Objects_Id *id181 )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 /*PAGE191 *192 * rtems_partition_delete193 *194 * This directive allows a thread to delete a partition specified by195 * the partition identifier, provided that none of its buffers are196 * still allocated.197 *198 * Input parameters:199 * id - partition id200 *201 * Output parameters:202 * RTEMS_SUCCESSFUL - if successful203 * error code - if unsuccessful204 */205 206 rtems_status_code rtems_partition_delete(207 Objects_Id id208 )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 #endif220 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.id234 );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 #endif244 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 /*PAGE256 *257 * rtems_partition_get_buffer258 *259 * This directive will obtain a buffer from a buffer partition.260 *261 * Input parameters:262 * id - partition id263 * buffer - pointer to buffer address264 *265 * Output parameters:266 * buffer - pointer to buffer address filled in267 * RTEMS_SUCCESSFUL - if successful268 * error code - if unsuccessful269 */270 271 rtems_status_code rtems_partition_get_buffer(272 Objects_Id id,273 void **buffer274 )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 #endif293 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 /*PAGE313 *314 * rtems_partition_return_buffer315 *316 * This directive will return the given buffer to the specified317 * buffer partition.318 *319 * Input parameters:320 * id - partition id321 * buffer - pointer to buffer address322 *323 * Output parameters:324 * RTEMS_SUCCESSFUL - if successful325 * error code - if unsuccessful326 */327 328 rtems_status_code rtems_partition_return_buffer(329 Objects_Id id,330 void *buffer331 )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 buffer345 );346 #endif347 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.