File indexing completed on 2025-05-11 08:24:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #include <rtems/libcsupport.h>
0034
0035 #include "tmacros.h"
0036
0037 const char rtems_test_name[] = "SP 64";
0038
0039
0040 rtems_task Init(rtems_task_argument argument);
0041
0042 uint32_t Area1[50] CPU_STRUCTURE_ALIGNMENT;
0043 uint32_t Area2[50] CPU_STRUCTURE_ALIGNMENT;
0044
0045 rtems_task Init(
0046 rtems_task_argument ignored
0047 )
0048 {
0049 rtems_id region1;
0050 rtems_id region2;
0051 rtems_status_code sc;
0052 bool ok;
0053 uintptr_t to_alloc;
0054 void *alloced;
0055 rtems_resource_snapshot snapshot;
0056 void *greedy;
0057
0058 TEST_BEGIN();
0059
0060 puts( "Allocate one region -- so second auto extends" );
0061 sc = rtems_region_create(
0062 rtems_build_name( 'R', 'N', '1', ' ' ),
0063 Area1,
0064 sizeof(Area1),
0065 8,
0066 RTEMS_DEFAULT_ATTRIBUTES,
0067 ®ion1
0068 );
0069 rtems_test_assert( sc == RTEMS_SUCCESSFUL );
0070
0071 greedy = rtems_workspace_greedy_allocate_all_except_largest( &to_alloc );
0072 rtems_resource_snapshot_take( &snapshot );
0073
0074 puts( "Init - rtems_region_create - auto-extend - RTEMS_UNSATISFIED" );
0075 while ( to_alloc > 8 ) {
0076 ok = rtems_workspace_allocate( to_alloc, &alloced );
0077 rtems_test_assert( ok );
0078
0079 sc = rtems_region_create(
0080 rtems_build_name( 'R', 'N', '2', ' ' ),
0081 Area2,
0082 sizeof(Area2),
0083 8,
0084 RTEMS_DEFAULT_ATTRIBUTES,
0085 ®ion2
0086 );
0087
0088 rtems_workspace_free( alloced );
0089
0090 if ( sc == RTEMS_SUCCESSFUL )
0091 break;
0092
0093 rtems_test_assert( sc == RTEMS_TOO_MANY );
0094
0095
0096
0097
0098 ok = rtems_resource_snapshot_check( &snapshot );
0099 rtems_test_assert( ok );
0100
0101 to_alloc -= 8;
0102 }
0103
0104 rtems_test_assert( sc == RTEMS_SUCCESSFUL );
0105
0106
0107
0108
0109 puts( "Init - rtems_region_delete - OK" );
0110 sc = rtems_region_delete( region2 );
0111 rtems_test_assert( sc == RTEMS_SUCCESSFUL );
0112
0113 puts( "Init - verify workspace has same memory" );
0114 ok = rtems_resource_snapshot_check( &snapshot );
0115 rtems_test_assert( ok );
0116 rtems_workspace_greedy_free( greedy );
0117
0118 TEST_END();
0119 rtems_test_exit(0);
0120 }
0121
0122
0123
0124 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0125 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
0126
0127 #define CONFIGURE_MAXIMUM_TASKS 1
0128 #define CONFIGURE_MAXIMUM_REGIONS rtems_resource_unlimited( 2 )
0129 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0130
0131 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0132
0133 #define CONFIGURE_MEMORY_OVERHEAD 1
0134
0135 #define CONFIGURE_INIT
0136 #include <rtems/confdefs.h>
0137
0138