Changeset 3899bc1a in rtems
- Timestamp:
- 11/24/18 10:51:28 (4 years ago)
- Branches:
- 5, master
- Children:
- 1c2d178
- Parents:
- 359a3a3
- git-author:
- Sebastian Huber <sebastian.huber@…> (11/24/18 10:51:28)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (12/07/18 13:22:01)
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/include/rtems/score/objectimpl.h
r359a3a3 r3899bc1a 121 121 */ 122 122 typedef struct { 123 /** This is the minimum valid id of this object class. */124 Objects_Id minimum_id;125 123 /** This is the maximum valid id of this object class. */ 126 124 Objects_Id maximum_id; … … 191 189 #define _Objects_Maximum_nodes 1 192 190 #endif 191 192 /** 193 * This is the minimum object ID index associated with an object. 194 */ 195 #define OBJECTS_INDEX_MINIMUM 1U 193 196 194 197 /** … … 833 836 834 837 /** 838 * Returns the identifier with the minimum index for the specified identifier. 839 * 840 * The specified identifier must have valid API, class and node fields. 841 * 842 * @param[in] id The identifier to be processed. 843 * 844 * @return The corresponding ID with the minimum index. 845 */ 846 RTEMS_INLINE_ROUTINE Objects_Id _Objects_Get_minimum_id( Objects_Id id ) 847 { 848 id &= ~OBJECTS_INDEX_MASK; 849 id += (Objects_Id) OBJECTS_INDEX_MINIMUM << OBJECTS_INDEX_START_BIT; 850 return id; 851 } 852 853 /** 835 854 * This function sets the pointer to the local_table object 836 855 * referenced by the index. … … 857 876 * occur in normal situations. 858 877 */ 878 _Assert( index >= OBJECTS_INDEX_MINIMUM ); 859 879 _Assert( index <= information->maximum ); 860 880 861 information->local_table[ index ] = the_object;881 information->local_table[ index - OBJECTS_INDEX_MINIMUM ] = the_object; 862 882 } 863 883 -
cpukit/posix/src/killinfo.c
r359a3a3 r3899bc1a 211 211 object_table = the_info->local_table; 212 212 213 for ( index = 1 ; index <= maximum ; index++) {213 for ( index = 0 ; index < maximum ; ++index ) { 214 214 the_thread = (Thread_Control *) object_table[ index ]; 215 215 -
cpukit/rtems/src/ratemonreportstatistics.c
r359a3a3 r3899bc1a 36 36 { 37 37 rtems_status_code status; 38 rtems_id maximum_id; 38 39 rtems_id id; 39 40 rtems_rate_monotonic_period_statistics the_stats; … … 68 69 * is a period that is inactive, we just get an error back. No big deal. 69 70 */ 70 for ( id=_Rate_monotonic_Information.minimum_id ; 71 id <= _Rate_monotonic_Information.maximum_id ; 72 id++ ) { 71 maximum_id = _Rate_monotonic_Information.maximum_id; 72 for ( 73 id = _Objects_Get_minimum_id( maximum_id ) ; 74 id <= maximum_id ; 75 ++id 76 ) { 73 77 status = rtems_rate_monotonic_get_statistics( id, &the_stats ); 74 78 if ( status != RTEMS_SUCCESSFUL ) -
cpukit/rtems/src/ratemonresetall.c
r359a3a3 r3899bc1a 26 26 void rtems_rate_monotonic_reset_all_statistics( void ) 27 27 { 28 Objects_Id id; 28 rtems_id maximum_id; 29 rtems_id id; 29 30 30 31 /* … … 38 39 * is a period that is inactive, we just get an error back. No big deal. 39 40 */ 40 for ( id=_Rate_monotonic_Information.minimum_id ; 41 id <= _Rate_monotonic_Information.maximum_id ; 42 id++ ) { 41 maximum_id = _Rate_monotonic_Information.maximum_id; 42 for ( 43 id = _Objects_Get_minimum_id( maximum_id ) ; 44 id <= maximum_id ; 45 ++id 46 ) { 43 47 (void) rtems_rate_monotonic_reset_statistics( id ); 44 48 } -
cpukit/rtems/src/rtemsobjectgetclassinfo.c
r359a3a3 r3899bc1a 45 45 * Return information about this object class to the user. 46 46 */ 47 info->minimum_id = obj_info->minimum_id;47 info->minimum_id = _Objects_Get_minimum_id( obj_info->maximum_id ); 48 48 info->maximum_id = obj_info->maximum_id; 49 49 info->auto_extend = obj_info->auto_extend; -
cpukit/score/src/objectallocate.c
r359a3a3 r3899bc1a 63 63 */ 64 64 65 if ( !the_object) {65 if ( the_object == NULL ) { 66 66 _Objects_Extend_information( information ); 67 67 the_object = _Objects_Get_inactive( information ); 68 68 } 69 69 70 if ( the_object ) {71 uint32_tblock;70 if ( the_object != NULL ) { 71 Objects_Maximum block; 72 72 73 block = (uint32_t) _Objects_Get_index( the_object->id ) - 74 _Objects_Get_index( information->minimum_id ); 73 block = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM; 75 74 block /= information->objects_per_block; 76 75 -
cpukit/score/src/objectextendinformation.c
r359a3a3 r3899bc1a 49 49 uint32_t index_base; 50 50 uint32_t index_end; 51 uint32_t minimum_index;52 51 uint32_t index; 53 52 uint32_t maximum; … … 66 65 */ 67 66 do_extend = true; 68 minimum_index = _Objects_Get_index( information->minimum_id ); 69 index_base = minimum_index; 67 index_base = 0; 70 68 block = 0; 71 69 72 /* if ( information->maximum < minimum_index ) */73 70 if ( information->object_blocks == NULL ) 74 71 block_count = 0; … … 150 147 */ 151 148 object_blocks_size = block_count * sizeof( *object_blocks ); 152 local_table_size = ( maximum + minimum_index )* sizeof( *local_table );149 local_table_size = maximum * sizeof( *local_table ); 153 150 table_size = object_blocks_size 154 151 + local_table_size … … 182 179 block_count--; 183 180 184 if ( information->maximum > minimum_index) {181 if ( information->maximum > 0 ) { 185 182 /* 186 183 * Copy each section of the table over. This has to be performed as … … 200 197 local_table, 201 198 information->local_table, 202 ( information->maximum + minimum_index )* sizeof( *local_table )199 information->maximum * sizeof( *local_table ) 203 200 ); 204 } else {205 /*206 * Deal with the special case of the 0 to minimum_index207 */208 for ( index = 0; index < minimum_index; index++ ) {209 local_table[ index ] = NULL;210 }211 201 } 212 202 … … 257 247 information->the_class, 258 248 _Objects_Local_node, 259 index 249 index + OBJECTS_INDEX_MINIMUM 260 250 ); 261 251 -
cpukit/score/src/objectfree.c
r359a3a3 r3899bc1a 38 38 39 39 objects_per_block = information->objects_per_block; 40 block = _Objects_Get_index( the_object->id ); 41 block -= _Objects_Get_index( information->minimum_id ); 40 block = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM; 42 41 block /= objects_per_block; 43 42 -
cpukit/score/src/objectgetlocal.c
r359a3a3 r3899bc1a 32 32 ) 33 33 { 34 uint32_t index; 34 Objects_Id delta; 35 Objects_Id maximum_id; 36 Objects_Id end; 35 37 36 index = id - information->minimum_id + 1; 38 maximum_id = information->maximum_id; 39 delta = maximum_id - id; 40 end = _Objects_Get_index( maximum_id ); 37 41 38 if ( information->maximum >= index ) { 42 if ( RTEMS_PREDICT_TRUE( delta < end ) ) { 43 ISR_Level level; 39 44 Objects_Control *the_object; 40 45 41 _ISR_lock_ISR_disable( lock_context ); 46 _ISR_Local_disable( level ); 47 _ISR_lock_Context_set_level( lock_context, level ); 42 48 43 the_object = information->local_table[ index ]; 44 if ( the_object != NULL ) { 49 the_object = 50 information->local_table[ end - OBJECTS_INDEX_MINIMUM - delta ]; 51 if ( RTEMS_PREDICT_TRUE( the_object != NULL ) ) { 45 52 /* ISR disabled on behalf of caller */ 46 53 return the_object; 47 54 } 48 55 49 _ISR_ lock_ISR_enable( lock_context);56 _ISR_Local_enable( level ); 50 57 } 51 58 -
cpukit/score/src/objectgetnext.c
r359a3a3 r3899bc1a 37 37 38 38 if (_Objects_Get_index(id) == OBJECTS_ID_INITIAL_INDEX) 39 next_id = information->minimum_id;39 next_id = _Objects_Get_minimum_id( information->maximum_id ); 40 40 else 41 41 next_id = id; -
cpukit/score/src/objectgetnoprotection.c
r359a3a3 r3899bc1a 26 26 ) 27 27 { 28 Objects_Control *the_object; 29 uint32_t index; 28 Objects_Id delta; 29 Objects_Id maximum_id; 30 Objects_Id end; 30 31 31 /* 32 * You can't just extract the index portion or you can get tricked 33 * by a value between 1 and maximum. 34 */ 35 index = id - information->minimum_id + 1; 32 maximum_id = information->maximum_id; 33 delta = maximum_id - id; 34 end = _Objects_Get_index( maximum_id ); 36 35 37 if ( information->maximum >= index ) { 38 if ( (the_object = information->local_table[ index ]) != NULL ) { 39 return the_object; 40 } 36 if ( RTEMS_PREDICT_TRUE( delta < end ) ) { 37 return information->local_table[ end - OBJECTS_INDEX_MINIMUM - delta ]; 41 38 } 42 39 -
cpukit/score/src/objectinitializeinformation.c
r359a3a3 r3899bc1a 38 38 ) 39 39 { 40 static Objects_Control *null_local_table = NULL; 41 uint32_t minimum_index; 42 Objects_Maximum maximum_per_allocation; 40 Objects_Maximum maximum_per_allocation; 43 41 44 42 information->the_api = the_api; … … 49 47 information->object_blocks = 0; 50 48 information->inactive = 0; 49 information->local_table = NULL; 51 50 52 51 /* … … 78 77 */ 79 78 information->objects_per_block = maximum_per_allocation; 80 81 /*82 * Provide a null local table entry for the case of any empty table.83 */84 information->local_table = &null_local_table;85 86 /*87 * Calculate minimum and maximum Id's88 */89 minimum_index = (maximum_per_allocation == 0) ? 0 : 1;90 information->minimum_id =91 _Objects_Build_id( the_api, the_class, _Objects_Local_node, minimum_index );92 79 93 80 /* -
cpukit/score/src/objectnametoid.c
r359a3a3 r3899bc1a 30 30 bool search_local_node; 31 31 Objects_Control *the_object; 32 uint32_tindex;32 Objects_Maximum index; 33 33 #if defined(RTEMS_MULTIPROCESSING) 34 34 Objects_Name name_for_mp; … … 53 53 54 54 if ( search_local_node ) { 55 for ( index = 1; index <= information->maximum; index++) {55 for ( index = 0; index < information->maximum; ++index ) { 56 56 the_object = information->local_table[ index ]; 57 57 if ( !the_object ) -
cpukit/score/src/objectnametoidstring.c
r359a3a3 r3899bc1a 53 53 } 54 54 55 for ( index = 1; index <= information->maximum; index++) {55 for ( index = 0; index < information->maximum; ++index ) { 56 56 Objects_Control *the_object; 57 57 -
cpukit/score/src/objectshrinkinformation.c
r359a3a3 r3899bc1a 29 29 { 30 30 Objects_Maximum objects_per_block; 31 Objects_Maximum index_base;32 31 Objects_Maximum block_count; 33 32 Objects_Maximum block; 33 Objects_Maximum index_base; 34 34 35 35 _Assert( _Objects_Allocator_is_owner() ); … … 40 40 41 41 objects_per_block = information->objects_per_block; 42 index_base = _Objects_Get_index( information->minimum_id );43 block_count = ( information->maximum - index_base ) / objects_per_block;42 block_count = information->maximum / objects_per_block; 43 index_base = 0; 44 44 45 45 for ( block = 0; block < block_count; block++ ) { … … 47 47 Chain_Node *node; 48 48 const Chain_Node *tail; 49 uint32_tindex_end;49 Objects_Maximum index_end; 50 50 51 51 node = _Chain_First( &information->Inactive ); … … 58 58 59 59 object = (Objects_Control *) node; 60 index = _Objects_Get_index( object->id ) ;60 index = _Objects_Get_index( object->id ) - OBJECTS_INDEX_MINIMUM; 61 61 62 62 /* -
cpukit/score/src/threaditerate.c
r359a3a3 r3899bc1a 40 40 } 41 41 42 for ( i = 1 ; i <=information->maximum ; ++i ) {42 for ( i = 0 ; i < information->maximum ; ++i ) { 43 43 Thread_Control *the_thread; 44 44 -
testsuites/sptests/spconfig02/init.c
r359a3a3 r3899bc1a 19 19 #include <rtems.h> 20 20 #include <rtems/score/objectimpl.h> 21 #include <rtems/sysinit.h> 21 22 22 23 #include <tmacros.h> … … 26 27 static const rtems_name name = rtems_build_name('N', 'A', 'M', 'E'); 27 28 28 static void test_barrier (void)29 static void test_barrier_create(void) 29 30 { 30 31 rtems_status_code sc; … … 35 36 } 36 37 37 static void test_message_queue(void) 38 static void test_barrier_delete(void) 39 { 40 rtems_status_code sc; 41 rtems_id id; 42 43 sc = rtems_barrier_delete(0); 44 rtems_test_assert(sc == RTEMS_INVALID_ID); 45 46 id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_BARRIERS, 1, 0); 47 sc = rtems_barrier_delete(id); 48 rtems_test_assert(sc == RTEMS_INVALID_ID); 49 } 50 51 static void test_barrier_get(void) 52 { 53 rtems_status_code sc; 54 rtems_id id; 55 56 sc = rtems_barrier_wait(0, RTEMS_NO_TIMEOUT); 57 rtems_test_assert(sc == RTEMS_INVALID_ID); 58 59 id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_BARRIERS, 1, 0); 60 sc = rtems_barrier_wait(id, RTEMS_NO_TIMEOUT); 61 rtems_test_assert(sc == RTEMS_INVALID_ID); 62 } 63 64 static void test_message_queue_create(void) 38 65 { 39 66 rtems_status_code sc; … … 48 75 ); 49 76 rtems_test_assert(sc == RTEMS_TOO_MANY); 77 } 78 79 static void test_message_queue_delete(void) 80 { 81 rtems_status_code sc; 82 rtems_id id; 50 83 51 84 sc = rtems_message_queue_delete(0); … … 57 90 } 58 91 59 static void test_partition(void) 92 static void test_message_queue_get(void) 93 { 94 rtems_status_code sc; 95 rtems_id id; 96 uint32_t count; 97 98 sc = rtems_message_queue_flush(0, &count); 99 rtems_test_assert(sc == RTEMS_INVALID_ID); 100 101 id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_MESSAGE_QUEUES, 1, 0); 102 sc = rtems_message_queue_flush(id, &count); 103 rtems_test_assert(sc == RTEMS_INVALID_ID); 104 } 105 106 static void test_partition_create(void) 60 107 { 61 108 rtems_status_code sc; … … 72 119 ); 73 120 rtems_test_assert(sc == RTEMS_TOO_MANY); 121 } 122 123 static void test_partition_delete(void) 124 { 125 rtems_status_code sc; 126 rtems_id id; 74 127 75 128 sc = rtems_partition_delete(0); … … 81 134 } 82 135 83 static void test_rate_monotonic(void) 136 static void test_partition_get(void) 137 { 138 rtems_status_code sc; 139 rtems_id id; 140 141 sc = rtems_partition_return_buffer(0, NULL); 142 rtems_test_assert(sc == RTEMS_INVALID_ID); 143 144 id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PARTITIONS, 1, 0); 145 sc = rtems_partition_return_buffer(id, NULL); 146 rtems_test_assert(sc == RTEMS_INVALID_ID); 147 } 148 149 static void test_rate_monotonic_create(void) 84 150 { 85 151 rtems_status_code sc; … … 88 154 sc = rtems_rate_monotonic_create(name, &id); 89 155 rtems_test_assert(sc == RTEMS_TOO_MANY); 156 } 157 158 static void test_rate_monotonic_delete(void) 159 { 160 rtems_status_code sc; 161 rtems_id id; 90 162 91 163 sc = rtems_rate_monotonic_delete(0); … … 97 169 } 98 170 99 static void test_region(void) 171 static void test_rate_monotonic_get(void) 172 { 173 rtems_status_code sc; 174 rtems_id id; 175 176 sc = rtems_rate_monotonic_cancel(0); 177 rtems_test_assert(sc == RTEMS_INVALID_ID); 178 179 id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PERIODS, 1, 0); 180 sc = rtems_rate_monotonic_cancel(id); 181 rtems_test_assert(sc == RTEMS_INVALID_ID); 182 } 183 184 static void test_region_create(void) 100 185 { 101 186 rtems_status_code sc; … … 112 197 ); 113 198 rtems_test_assert(sc == RTEMS_TOO_MANY); 199 } 200 201 static void test_region_delete(void) 202 { 203 rtems_status_code sc; 204 rtems_id id; 114 205 115 206 sc = rtems_region_delete(0); … … 121 212 } 122 213 123 static void test_semaphore(void) 214 static void test_region_get(void) 215 { 216 rtems_status_code sc; 217 rtems_id id; 218 219 sc = rtems_region_return_segment(0, NULL); 220 rtems_test_assert(sc == RTEMS_INVALID_ID); 221 222 id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_REGIONS, 1, 0); 223 sc = rtems_region_return_segment(id, NULL); 224 rtems_test_assert(sc == RTEMS_INVALID_ID); 225 } 226 227 static void test_semaphore_create(void) 124 228 { 125 229 rtems_status_code sc; … … 134 238 ); 135 239 rtems_test_assert(sc == RTEMS_TOO_MANY); 240 } 241 242 static void test_semaphore_delete(void) 243 { 244 rtems_status_code sc; 245 rtems_id id; 136 246 137 247 sc = rtems_semaphore_delete(0); … … 143 253 } 144 254 145 static void test_task(void) 255 static void test_semaphore_get(void) 256 { 257 rtems_status_code sc; 258 rtems_id id; 259 260 sc = rtems_semaphore_release(0); 261 rtems_test_assert(sc == RTEMS_INVALID_ID); 262 263 id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_SEMAPHORES, 1, 0); 264 sc = rtems_semaphore_release(id); 265 rtems_test_assert(sc == RTEMS_INVALID_ID); 266 } 267 268 static void test_task_create(void) 146 269 { 147 270 rtems_status_code sc; … … 157 280 ); 158 281 rtems_test_assert(sc == RTEMS_TOO_MANY); 282 } 283 284 static void test_task_delete(void) 285 { 286 rtems_status_code sc; 287 rtems_id id; 159 288 160 289 id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, 1, 0); … … 163 292 } 164 293 165 static void test_timer(void) 294 static void test_task_get(void) 295 { 296 rtems_status_code sc; 297 rtems_id id; 298 299 id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, 1, 0); 300 sc = rtems_task_resume(id); 301 rtems_test_assert(sc == RTEMS_INVALID_ID); 302 } 303 304 static void test_timer_create(void) 166 305 { 167 306 rtems_status_code sc; … … 170 309 sc = rtems_timer_create(name, &id); 171 310 rtems_test_assert(sc == RTEMS_TOO_MANY); 311 } 312 313 static void test_timer_delete(void) 314 { 315 rtems_status_code sc; 316 rtems_id id; 172 317 173 318 sc = rtems_timer_delete(0); … … 179 324 } 180 325 181 static void test_user_extensions(void) 326 static void test_timer_get(void) 327 { 328 rtems_status_code sc; 329 rtems_id id; 330 331 sc = rtems_timer_reset(0); 332 rtems_test_assert(sc == RTEMS_INVALID_ID); 333 334 id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS, 1, 0); 335 sc = rtems_timer_reset(id); 336 rtems_test_assert(sc == RTEMS_INVALID_ID); 337 } 338 339 static void test_user_extensions_create(void) 182 340 { 183 341 rtems_status_code sc; … … 188 346 sc = rtems_extension_create(name, &table, &id); 189 347 rtems_test_assert(sc == RTEMS_TOO_MANY); 348 } 349 350 static void test_user_extensions_delete(void) 351 { 352 rtems_status_code sc; 353 rtems_id id; 190 354 191 355 sc = rtems_extension_delete(0); … … 247 411 static void Init(rtems_task_argument arg) 248 412 { 249 rtems_print_printer_printk(&rtems_test_printer); 250 TEST_BEGIN(); 251 test_barrier(); 252 test_message_queue(); 253 test_partition(); 254 test_rate_monotonic(); 255 test_region(); 256 test_semaphore(); 257 test_task(); 258 test_timer(); 259 test_user_extensions(); 413 test_barrier_create(); 414 test_barrier_delete(); 415 test_barrier_get(); 416 test_message_queue_create(); 417 test_message_queue_delete(); 418 test_message_queue_get(); 419 test_partition_create(); 420 test_partition_delete(); 421 test_partition_get(); 422 test_rate_monotonic_create(); 423 test_rate_monotonic_delete(); 424 test_rate_monotonic_get(); 425 test_region_create(); 426 test_region_delete(); 427 test_region_get(); 428 test_semaphore_create(); 429 test_semaphore_delete(); 430 test_semaphore_get(); 431 test_task_create(); 432 test_task_delete(); 433 test_task_get(); 434 test_timer_create(); 435 test_timer_delete(); 436 test_timer_get(); 437 test_user_extensions_create(); 438 test_user_extensions_delete(); 260 439 test_some_id_to_name(); 261 440 TEST_END(); … … 263 442 } 264 443 444 static void before_object_information_initialization(void) 445 { 446 rtems_print_printer_printk(&rtems_test_printer); 447 TEST_BEGIN(); 448 test_barrier_get(); 449 test_message_queue_get(); 450 test_partition_get(); 451 test_rate_monotonic_get(); 452 test_semaphore_get(); 453 test_task_get(); 454 test_timer_get(); 455 } 456 457 RTEMS_SYSINIT_ITEM( 458 before_object_information_initialization, 459 RTEMS_SYSINIT_INITIAL_EXTENSIONS, 460 RTEMS_SYSINIT_ORDER_LAST 461 ); 462 265 463 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER 266 464
Note: See TracChangeset
for help on using the changeset viewer.